|
| 1 | +""" Unit tests for pointing |
| 2 | +
|
| 3 | +""" |
| 4 | + |
| 5 | +import logging |
| 6 | +import unittest |
| 7 | + |
| 8 | +import astropy.units as u |
| 9 | +import numpy |
| 10 | +from astropy.coordinates import SkyCoord |
| 11 | + |
| 12 | +from data_models.polarisation import PolarisationFrame |
| 13 | + |
| 14 | +from processing_components.skycomponent.operations import create_skycomponent |
| 15 | +from processing_components.calibration.pointing import create_pointingtable_from_blockvisibility |
| 16 | +from processing_components.imaging.primary_beams import create_vp |
| 17 | +from processing_components.simulation.configurations import create_named_configuration |
| 18 | +from processing_components.simulation.pointing import create_gaintable_from_pointingtable |
| 19 | +from processing_components.simulation.testing_support import create_test_image, simulate_pointingtable |
| 20 | +from processing_components.simulation.testing_support import create_test_skycomponents_from_s3 |
| 21 | +from processing_components.visibility.base import create_blockvisibility |
| 22 | +from processing_library.image.operations import create_image |
| 23 | + |
| 24 | +log = logging.getLogger(__name__) |
| 25 | + |
| 26 | + |
| 27 | +class TestPointing(unittest.TestCase): |
| 28 | + def setUp(self): |
| 29 | + from data_models.parameters import arl_path |
| 30 | + |
| 31 | + self.doplot = True |
| 32 | + |
| 33 | + self.midcore = create_named_configuration('MID', rmax=300.0) |
| 34 | + self.nants = len(self.midcore.names) |
| 35 | + self.dir = arl_path('test_results') |
| 36 | + self.ntimes = 300 |
| 37 | + self.times = numpy.linspace(-12.0, 12.0, self.ntimes) * numpy.pi / (12.0) |
| 38 | + |
| 39 | + self.frequency = numpy.array([1e9]) |
| 40 | + self.channel_bandwidth = numpy.array([1e7]) |
| 41 | + self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-90.0 * u.deg, frame='icrs', equinox='J2000') |
| 42 | + self.vis = create_blockvisibility(self.midcore, self.times, self.frequency, |
| 43 | + channel_bandwidth=self.channel_bandwidth, |
| 44 | + phasecentre=self.phasecentre, weight=1.0, |
| 45 | + polarisation_frame=PolarisationFrame('stokesI')) |
| 46 | + self.vis.data['vis'] *= 0.0 |
| 47 | + |
| 48 | + # Create model |
| 49 | + self.model = create_image(npixel=2048, cellsize=0.00015, polarisation_frame=PolarisationFrame("stokesI"), |
| 50 | + frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, |
| 51 | + phasecentre=self.phasecentre) |
| 52 | + |
| 53 | + def test_create_gaintable_from_pointingtable_roll(self): |
| 54 | + self.sidelobe = SkyCoord(ra=+15.0 * u.deg, dec=-88.5 * u.deg, frame='icrs', equinox='J2000') |
| 55 | + comp = create_skycomponent(direction=self.sidelobe, flux=[[1.0]], frequency=self.frequency, |
| 56 | + polarisation_frame=PolarisationFrame('stokesI')) |
| 57 | + |
| 58 | + for telescope in ['MID', 'MID_GAUSS', 'MID_GRASP']: |
| 59 | + pt = create_pointingtable_from_blockvisibility(self.vis) |
| 60 | + pt = simulate_pointingtable(pt, pointing_error=0.0, |
| 61 | + static_pointing_error=0.0, |
| 62 | + global_pointing_error=[0.0, 0.0]) |
| 63 | + vp = create_vp(self.model, telescope) |
| 64 | + gt = create_gaintable_from_pointingtable(self.vis, [comp], pt, vp) |
| 65 | + if self.doplot: |
| 66 | + import matplotlib.pyplot as plt |
| 67 | + plt.clf() |
| 68 | + plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') |
| 69 | + plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') |
| 70 | + plt.title('test_create_gaintable_from_pointingtable_%s' % telescope) |
| 71 | + plt.show() |
| 72 | + assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape |
| 73 | + |
| 74 | + |
| 75 | +if __name__ == '__main__': |
| 76 | + unittest.main() |
0 commit comments