def test_create_gaintable_from_pointingtable(self):
        s3_components = create_test_skycomponents_from_s3(
            flux_limit=0.3,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=1.5 * numpy.pi / 180.0)
        s3_components = filter_skycomponents_by_flux(s3_components, 0.0, 10.0)

        pt = create_pointingtable_from_blockvisibility(self.vis)
        pt = simulate_pointingtable(pt,
                                    pointing_error=0.01,
                                    static_pointing_error=[0.001, 0.0001])
        vp = create_vp(self.model, 'MID')
        gt = simulate_gaintable_from_pointingtable(self.vis, s3_components, pt,
                                                   vp)
        if self.doplot:
            import matplotlib.pyplot as plt
            plt.clf()
            plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                     '.')
            plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                     '.')
            plt.title('test_create_gaintable_from_pointingtable')
            plt.show(block=False)
        assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                    1), gt[0].gain.shape
    def test_create_gaintable_from_pointingtable_GRASP(self):
        self.vis = create_blockvisibility(
            self.midcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('linear'))
        comp = create_skycomponent(
            direction=self.phasecentre,
            flux=[[1.0, 0.0, 0.0, 0.0]],
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesIQUV'))

        pt = create_pointingtable_from_blockvisibility(self.vis)
        pt = simulate_pointingtable(pt,
                                    pointing_error=0.0,
                                    static_pointing_error=None,
                                    global_pointing_error=[0.0, 0.01])
        vp = create_vp(self.model, 'MID_GRASP')
        gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt, vp)
        if self.doplot:
            import matplotlib.pyplot as plt
            plt.clf()
            plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                     '.')
            plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                     '.')
            plt.title(
                'test_create_gaintable_from_pointingtable_global_dynamic')
            plt.show(block=False)
        assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 2,
                                    2), gt[0].gain.shape
예제 #3
0
    def test_readwritepointingtable(self):
        self.vis = create_blockvisibility(
            self.midcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            polarisation_frame=PolarisationFrame("linear"),
            weight=1.0)
        pt = create_pointingtable_from_blockvisibility(self.vis,
                                                       timeslice='auto')
        pt = simulate_pointingtable(pt, pointing_error=0.1)

        config = {
            "buffer": {
                "directory": self.dir
            },
            "pointingtable": {
                "name": "test_bufferpointingtable.hdf",
                "data_model": "PointingTable"
            }
        }
        bdm = BufferPointingTable(config["buffer"], config["pointingtable"],
                                  pt)
        bdm.sync()
        new_bdm = BufferPointingTable(config["buffer"],
                                      config["pointingtable"])
        new_bdm.sync()
        newpt = bdm.memory_data_model

        assert pt.data.shape == newpt.data.shape
        assert numpy.max(numpy.abs(pt.pointing - newpt.pointing)) < 1e-15
    def test_create_gaintable_from_pointingtable_global(self):

        comp = create_skycomponent(
            direction=self.phasecentre,
            flux=[[1.0]],
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'))

        import matplotlib.pyplot as plt
        pt = create_pointingtable_from_blockvisibility(self.vis)
        pt = simulate_pointingtable(pt,
                                    pointing_error=0.0,
                                    static_pointing_error=None,
                                    global_pointing_error=[0.0, 0.01])
        vp = create_vp(self.model, 'MID')
        gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt, vp)
        if self.doplot:
            plt.clf()
            plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                     '.')
            plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                     '.')
            plt.title('test_create_gaintable_from_pointingtable_global')
            plt.show(block=False)
        assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                    1), gt[0].gain.shape
예제 #5
0
    def test_simulate_gaintable_from_time_series(self):
        numpy.random.seed(18051955)
        offset_phasecentre = SkyCoord(ra=+15.0 * u.deg,
                                      dec=-44.58 * u.deg,
                                      frame='icrs',
                                      equinox='J2000')
        component = [
            Skycomponent(frequency=self.frequency,
                         direction=offset_phasecentre,
                         polarisation_frame=PolarisationFrame("stokesI"),
                         flux=[[1.0]])
        ]

        for type in ['wind']:

            pt = create_pointingtable_from_blockvisibility(self.vis)

            import matplotlib.pyplot as plt
            ant = 15
            plt.clf()
            plt.plot(pt.time, pt.nominal[:, ant, 0, 0, 0], '.')
            plt.plot(pt.time, pt.nominal[:, ant, 0, 0, 1], '.')
            plt.xlabel('Time (s)')
            plt.ylabel('Nominal (rad)')
            plt.title("Nominal pointing for %s" % (type))
            plt.show()

            for reference_pointing in [False, True]:
                pt = simulate_pointingtable_from_timeseries(
                    pt, type=type, reference_pointing=reference_pointing)

                import matplotlib.pyplot as plt
                ant = 15
                plt.clf()
                r2a = 180.0 * 3600.0 / numpy.pi
                plt.plot(pt.time, r2a * pt.pointing[:, ant, 0, 0, 0], '.')
                plt.plot(pt.time, r2a * pt.pointing[:, ant, 0, 0, 1], '.')
                plt.xlabel('Time (s)')
                plt.ylabel('Pointing (arcsec)')
                plt.title("Pointing for %s, reference pointing %s" %
                          (type, reference_pointing))
                plt.show()

                vp = create_vp(self.model, 'MID')
                gt = simulate_gaintable_from_pointingtable(
                    self.vis, component, pt, vp)
                assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                            1), gt[0].gain.shape

                plt.clf()
                plt.plot(gt[0].time,
                         1.0 / numpy.real(gt[0].gain[:, ant, 0, 0, 0]), '.')
                plt.xlabel('Time (s)')
                plt.ylabel('Gain')
                plt.title("Gain for %s, reference pointing %s" %
                          (type, reference_pointing))
                plt.show()
    def test_create_pointingtable(self):
        beam = create_test_image(cellsize=0.0015,
                                 phasecentre=self.vis.phasecentre,
                                 frequency=self.frequency)

        for telescope in ['MID', 'LOW', 'ASKAP']:
            vp = create_vp(beam, telescope)
            pt = create_pointingtable_from_blockvisibility(self.vis, vp)
            pt = simulate_pointingtable(pt,
                                        0.1,
                                        static_pointing_error=[0.01, 0.001])
            assert pt.pointing.shape == (self.ntimes, self.nants, 1, 1,
                                         2), pt.pointing.shape
예제 #7
0
 def test_readwritepointingtable(self):
     self.vis = create_blockvisibility(self.mid, self.times, self.frequency,
                                       channel_bandwidth=self.channel_bandwidth,
                                       phasecentre=self.phasecentre,
                                       polarisation_frame=PolarisationFrame("linear"),
                                       weight=1.0)
     gt = create_pointingtable_from_blockvisibility(self.vis, timeslice='auto')
     gt = simulate_pointingtable(gt, pointing_error=0.001)
     export_pointingtable_to_hdf5(gt, '%s/test_data_model_helpers_pointingtable.hdf' % self.dir)
     newgt = import_pointingtable_from_hdf5('%s/test_data_model_helpers_pointingtable.hdf' % self.dir)
 
     for key in gt.data.dtype.fields:
         assert numpy.max(numpy.abs(newgt.data[key] - gt.data[key])) < 1e-15
 
     assert gt.data.shape == newgt.data.shape
     assert numpy.max(numpy.abs(gt.pointing - newgt.pointing)) < 1e-15
예제 #8
0
    def test_create_gaintable_from_pointingtable(self):
        s3_components = create_test_skycomponents_from_s3(
            flux_limit=5.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.2)

        pt = create_pointingtable_from_blockvisibility(self.vis)
        pt = simulate_pointingtable(pt,
                                    pointing_error=0.01,
                                    static_pointing_error=[0.001, 0.0001])
        vp = create_vp(self.model, 'MID')
        gt = simulate_gaintable_from_pointingtable(self.vis, s3_components, pt,
                                                   vp)
        assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                    1), gt[0].gain.shape
    def test_create_gaintable_from_pointingtable_circlecut_stokesI(self):
        self.sidelobe = SkyCoord(ra=+15.0 * u.deg,
                                 dec=-49.4 * u.deg,
                                 frame='icrs',
                                 equinox='J2000')
        comp = create_skycomponent(
            direction=self.sidelobe,
            flux=[[1.0]],
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'))

        telescopes = ['MID', 'MID_GAUSS']
        for telescope in telescopes:
            pt = create_pointingtable_from_blockvisibility(self.vis)
            pt = simulate_pointingtable(pt,
                                        pointing_error=0.0,
                                        global_pointing_error=[0.0, 0.0])
            vp = create_vp(self.model, telescope)
            gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt,
                                                       vp)
            if self.doplot:
                import matplotlib.pyplot as plt
                plt.clf()
                plt.plot(gt[0].time,
                         numpy.real(gt[0].gain[:, 0, 0, 0, 0]),
                         '.',
                         label='stokesI Real')
                plt.plot(gt[0].time,
                         numpy.imag(gt[0].gain[:, 0, 0, 0, 0]),
                         '.',
                         label='stokesI Imaginary')
                plt.legend()
                plt.xlabel('Time (s)')
                plt.ylabel('Gain')
                plt.title('test_create_gaintable_from_pointingtable_%s' %
                          telescope)
                plt.show(block=False)
            assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                        1), gt[0].gain.shape
    def test_create_gaintable_from_pointingtable_circlecut_stokesIQUV(self):
        self.vis = create_blockvisibility(
            self.midcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('linear'))
        self.sidelobe = SkyCoord(ra=+15.0 * u.deg,
                                 dec=-49.3 * u.deg,
                                 frame='icrs',
                                 equinox='J2000')
        comp = create_skycomponent(
            direction=self.sidelobe,
            flux=[[1.0, 0.0, 0.0, 0.0]],
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesIQUV'))

        telescopes = ['MID_FEKO_B2']
        for telescope in telescopes:
            pt = create_pointingtable_from_blockvisibility(self.vis)
            pt = simulate_pointingtable(pt,
                                        pointing_error=0.0,
                                        global_pointing_error=[0.0, 0.0])
            vp = create_vp(self.model, telescope)
            gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt,
                                                       vp)
            if self.doplot:
                import matplotlib.pyplot as plt
                plt.clf()
                plt.plot(gt[0].time,
                         numpy.real(gt[0].gain[:, 0, 0, 0, 0]),
                         '.',
                         label='XX')
                plt.plot(gt[0].time,
                         numpy.real(gt[0].gain[:, 0, 0, 1, 1]),
                         '.',
                         label='YY')
                plt.legend()
                plt.xlabel('Time (s)')
                plt.ylabel('Gain')
                plt.title(
                    'test_create_gaintable_from_pointingtable_parallel_%s' %
                    telescope)
                plt.show(block=False)
                plt.clf()
                plt.plot(gt[0].time,
                         numpy.real(gt[0].gain[:, 0, 0, 0, 1]),
                         '.',
                         label='XY')
                plt.plot(gt[0].time,
                         numpy.real(gt[0].gain[:, 0, 0, 1, 0]),
                         '.',
                         label='YX')
                plt.legend()
                plt.xlabel('Time (s)')
                plt.ylabel('Gain')
                plt.title('test_create_gaintable_from_pointingtable_cross_%s' %
                          telescope)
                plt.show(block=False)

            assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 2,
                                        2), gt[0].gain.shape