Esempio n. 1
0
    def test_create_gaintable_from_pointingtable_dynamic(self):
        comp = create_skycomponent(
            direction=self.phasecentre,
            flux=[[1.0]],
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'))

        pt = create_pointingtable_from_blockvisibility(self.vis)
        pt = simulate_pointingtable(pt,
                                    pointing_error=0.01,
                                    static_pointing_error=None,
                                    global_pointing_error=[0.0, 0.0])
        vp = create_vp(self.model, 'MID')
        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_dynamic')
            plt.show()
        assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                    1), gt[0].gain.shape
    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
Esempio n. 3
0
    def test_create_gaintable_from_pointingtable_global(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)[0]
        ]

        pt = create_pointingtable_from_blockvisibility(self.vis)
        pt = simulate_pointingtable(pt,
                                    pointing_error=0.0,
                                    static_pointing_error=0.0,
                                    global_pointing_error=[0.0001, 0.0001],
                                    config=self.vis.configuration)
        import matplotlib.pyplot as plt
        plt.clf()
        plt.plot(pt.pointing[..., 0].flat, pt.pointing[..., 1].flat, '.')
        plt.show()
        vp = create_vp(self.model, 'MID')
        gt = create_gaintable_from_pointingtable(self.vis, s3_components, pt,
                                                 vp)
        assert gt[0].gain.shape == (3, 63, 1, 1, 1), gt[0].gain.shape
        import matplotlib.pyplot as plt
        plt.clf()
        plt.plot(numpy.real(gt[0].gain.flat), numpy.imag(gt[0].gain.flat), '.')
        plt.show()
    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()
Esempio n. 5
0
    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)
            assert pt.pointing.shape == (3, 63, 1, 1, 2), pt.pointing.shape
Esempio n. 6
0
 def test_readwritepointingtable(self):
     self.vis = create_blockvisibility(self.lowcore, 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
Esempio n. 7
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(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', 'MID_GRASP']
        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(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                         '.',
                         label='Real')
                plt.plot(gt[0].time,
                         numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]),
                         '.',
                         label='Imaginary')
                plt.legend()
                plt.xlabel('Time (s)')
                plt.ylabel('Gain')
                plt.title('test_create_gaintable_from_pointingtable_%s' %
                          telescope)
                plt.show()
            assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1,
                                        1), gt[0].gain.shape