예제 #1
0
    def setUp(self):
        self.dir = './test_results'
        self.lowcore = create_named_configuration('LOWBD2-CORE')
        os.makedirs(self.dir, exist_ok=True)
        self.times = (numpy.pi / (12.0)) * numpy.linspace(-3.0, 3.0, 7)
        self.frequency = numpy.array([1e8])
        self.channel_bandwidth = numpy.array([1e6])
        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-60.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = create_visibility(
            self.lowcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('stokesI'))
        self.vis.data['vis'] *= 0.0

        # Create model
        self.model = create_test_image(cellsize=0.0015,
                                       phasecentre=self.vis.phasecentre,
                                       frequency=self.frequency)
        self.model.data[self.model.data > 1.0] = 1.0
        self.vis = predict_2d(self.vis, self.model)
        assert numpy.max(numpy.abs(self.vis.vis)) > 0.0
        export_image_to_fits(
            self.model, '%s/test_solve_skycomponent_model.fits' % (self.dir))
        self.bigmodel = create_image_from_visibility(self.vis,
                                                     cellsize=0.0015,
                                                     npixel=512)
예제 #2
0
    def setUp(self):
        self.dir = './test_results'
        os.makedirs(self.dir, exist_ok=True)
        lowcore = create_named_configuration('LOWBD2-CORE')
        times = numpy.arange(-3.0, +3.0, 1.0) * numpy.pi / 12.0
        vnchan = 8
        frequency = numpy.linspace(0.8e8, 1.20e8, vnchan)
        channel_bandwidth = numpy.array(vnchan * [frequency[1] - frequency[0]])

        # Define the component and give it some polarisation and spectral behaviour
        f = numpy.array([100.0, 20.0, -10.0, 1.0])
        self.flux = numpy.array(
            [f, 0.9 * f, 0.8 * f, 0.7 * f, 0.6 * f, 0.5 * f, 0.4 * f, 0.3 * f])

        self.phasecentre = SkyCoord(ra=+15.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.compabsdirection = SkyCoord(ra=17.0 * u.deg,
                                         dec=-36.5 * u.deg,
                                         frame='icrs',
                                         equinox='J2000')

        self.comp = create_skycomponent(flux=self.flux,
                                        frequency=frequency,
                                        direction=self.compabsdirection)
        self.image = create_test_image(
            frequency=frequency,
            phasecentre=self.phasecentre,
            cellsize=0.001,
            polarisation_frame=PolarisationFrame('stokesIQUV'))

        self.blockvis = create_blockvisibility_iterator(
            lowcore,
            times=times,
            frequency=frequency,
            channel_bandwidth=channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1,
            polarisation_frame=PolarisationFrame('linear'),
            integration_time=1.0,
            number_integrations=1,
            predict=predict_2d,
            components=self.comp,
            phase_error=0.1,
            amplitude_error=0.01,
            sleep=1.0)

        self.vis = create_blockvisibility(
            lowcore,
            times=times,
            frequency=frequency,
            channel_bandwidth=channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1,
            polarisation_frame=PolarisationFrame('stokesIQUV'),
            integration_time=1.0)

        self.vis = predict_2d(self.vis, self.image)
예제 #3
0
    def test_predict_2d(self):
        # Test if the 2D prediction works
        #
        # Set w=0 so that the two-dimensional transform should agree exactly with the component transform.
        # Good check on the grid correction in the image->vis direction
        # Set all w to zero
        self.actualSetUp()
        self.componentvis = create_visibility(
            self.lowcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0)
        self.componentvis.data['uvw'][:, 2] = 0.0
        # Predict the visibility using direct evaluation
        predict_skycomponent_visibility(self.componentvis, self.components)

        self.modelvis = create_visibility(
            self.lowcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=self.vis_pol)
        self.modelvis.data['uvw'][:, 2] = 0.0
        predict_2d(self.modelvis, self.model, **self.params)
        self.residualvis = create_visibility(
            self.lowcore,
            self.times,
            self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=self.vis_pol)
        self.residualvis.data['uvw'][:, 2] = 0.0
        self.residualvis.data[
            'vis'] = self.modelvis.data['vis'] - self.componentvis.data['vis']

        self._checkdirty(self.residualvis,
                         'test_predict_2d',
                         fluxthreshold=4.0)
예제 #4
0
 def test_insert_skycomponent(self):
     sc = create_skycomponent(direction=self.phasecentre, flux=numpy.array([[1.0]]), frequency=self.frequency,
                              polarisation_frame = PolarisationFrame('stokesI'))
     
     log.debug(self.model.wcs)
     log.debug(str(sc))
     # The actual phase centre of a numpy FFT is at nx //2, nx //2 (0 rel).
     self.model.data *= 0.0
     insert_skycomponent(self.model, sc)
     npixel = self.model.shape[3]
     rpix = numpy.round(self.model.wcs.wcs.crpix).astype('int')
     assert rpix[0] == npixel // 2
     assert rpix[1] == npixel // 2
     assert self.model.data[0,0,rpix[1],rpix[0]] == 1.0
     self.vis = predict_2d(self.vis, self.model)
     assert self.vis.vis.imag.all() == 0.0
    def test_insert_skycomponent(self):
        sc = create_skycomponent(
            direction=self.phasecentre,
            flux=numpy.array([[1.0]]),
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'))

        self.model.data *= 0.0
        insert_skycomponent(self.model, sc)
        npixel = self.model.shape[3]
        # WCS is 1-relative
        rpix = numpy.round(self.model.wcs.wcs.crpix).astype('int') - 1
        assert rpix[0] == npixel // 2
        assert rpix[1] == npixel // 2
        # The phase centre is at rpix[0], rpix[1] in 0-relative pixels
        assert self.model.data[0, 0, rpix[1], rpix[0]] == 1.0
        # If we predict the visibility, then the imaginary part must be zero. This is determined entirely
        # by shift_vis_to_image in arl.imaging.base
        self.vis = predict_2d(self.vis, self.model)
        # The actual phase centre of a numpy FFT is at nx //2, nx //2 (0 rel).
        assert self.vis.vis.imag.all() == 0.0
예제 #6
0
    def test_predict_2d(self):
        # Test if the 2D prediction works
        #
        # Set w=0 so that the two-dimensional transform should agree exactly with the component transform.
        # Good check on the grid correction in the image->vis direction
        # Set all w to zero
        self.actualSetUp()
        self.componentvis.data['uvw'][:, 2] = 0.0
        # Predict the visibility using direct evaluation
        self.componentvis.data['vis'][...] = 0.0
        self.componentvis = predict_skycomponent_visibility(
            self.componentvis, self.components)

        self.modelvis = copy_visibility(self.componentvis, zero=True)
        self.modelvis.data['uvw'][:, 2] = 0.0
        self.modelvis = predict_2d(self.modelvis, self.model, **self.params)
        self.residualvis = copy_visibility(self.componentvis, zero=True)
        self.residualvis.data['uvw'][:, 2] = 0.0
        self.residualvis.data[
            'vis'] = self.modelvis.data['vis'] - self.componentvis.data['vis']

        self._checkdirty(self.residualvis, 'predict_2d')