def setUp(self):
        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')

        self.vnchan = 7
        self.lowcore = create_named_configuration('LOWBD2', rmax=300.0)
        self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7)
        self.frequency = numpy.linspace(8e7, 1.2e8, self.vnchan)
        self.startfrequency = numpy.array([8e7])
        self.channel_bandwidth = numpy.array(
            self.vnchan * [(1.0 - 1.0e-7) *
                           (self.frequency[1] - self.frequency[0])])
        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-60.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = create_visibility(
            self.lowcore,
            times=self.times,
            frequency=self.frequency,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('stokesI'),
            channel_bandwidth=self.channel_bandwidth)
        self.model = create_image_from_visibility(
            self.vis,
            npixel=128,
            cellsize=0.001,
            nchan=self.vnchan,
            frequency=self.startfrequency)
Exemplo n.º 2
0
    def setUp(self):
        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')

        self.lowcore = create_named_configuration('LOWBD2-CORE')
        self.times = (numpy.pi / 43200.0) * numpy.arange(0.0, 300.0, 100.0)
        self.frequency = numpy.linspace(1.0e8, 1.1e8, 3)
        self.channel_bandwidth = numpy.array([1e7, 1e7, 1e7])
        # Define the component and give it some spectral behaviour
        f = numpy.array([100.0, 20.0, -10.0, 1.0])
        self.flux = numpy.array([f, 0.8 * f, 0.6 * f])

        # The phase centre is absolute and the component is specified relative (for now).
        # This means that the component should end up at the position phasecentre+compredirection
        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.compabsdirection = SkyCoord(ra=+181.0 * u.deg,
                                         dec=-35.0 * u.deg,
                                         frame='icrs',
                                         equinox='J2000')
        self.comp = Skycomponent(direction=self.compabsdirection,
                                 frequency=self.frequency,
                                 flux=self.flux)
Exemplo n.º 3
0
 def setUp(self):
     
     arlexecute.set_client(use_dask=False)
     
     from data_models.parameters import arl_path
     self.dir = arl_path('test_results')
     self.lowcore = create_named_configuration('LOWBD2-CORE')
     self.times = numpy.linspace(-3, +3, 13) * (numpy.pi / 12.0)
     
     self.frequency = numpy.array([1e8])
     self.channel_bandwidth = numpy.array([1e7])
     
     # Define the component and give it some polarisation and spectral behaviour
     f = numpy.array([100.0])
     self.flux = numpy.array([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(direction=self.compabsdirection, flux=self.flux, frequency=self.frequency,
                                     polarisation_frame=PolarisationFrame('stokesI'))
     self.image = create_test_image(frequency=self.frequency, phasecentre=self.phasecentre,
                                    cellsize=0.001,
                                    polarisation_frame=PolarisationFrame('stokesI'))
     self.image.data[self.image.data < 0.0] = 0.0
     
     self.image_workflow = arlexecute.execute(create_test_image)(frequency=self.frequency,
                                                              phasecentre=self.phasecentre,
                                                              cellsize=0.001,
                                                              polarisation_frame=PolarisationFrame('stokesI'))
Exemplo n.º 4
0
 def createVis(self, config, dec=-35.0, rmax=None):
     self.config = create_named_configuration(config, rmax=rmax)
     self.phasecentre = SkyCoord(ra=+15 * u.deg, dec=dec * u.deg, frame='icrs', equinox='J2000')
     self.vis = create_visibility(self.config, self.times, self.frequency,
                                  channel_bandwidth=self.channel_bandwidth,
                                  phasecentre=self.phasecentre, weight=1.0,
                                  polarisation_frame=PolarisationFrame('stokesI'))
Exemplo n.º 5
0
    def setUp(self):
        from data_models.parameters import arl_path
        self.lowcore = create_named_configuration('LOWBD2', rmax=300.0)
        self.dir = arl_path('test_results')
        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_blockvisibility(
            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.mask = create_test_image(cellsize=0.0015,
                                      phasecentre=self.vis.phasecentre,
                                      frequency=self.frequency)
        self.mask.data[self.mask.data > 0.1] = 1.0
        self.mask.data[self.mask.data <= 0.1] = 0.0
 def setUp(self):
     from data_models.parameters import arl_path
     self.lowcore = create_named_configuration('LOWBD2-CORE')
     self.dir = arl_path('test_results')
     self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7)
     self.image_frequency = numpy.linspace(0.9e8, 1.1e8, 5)
     self.component_frequency = numpy.linspace(0.8e8, 1.2e8, 7)
     self.channel_bandwidth = numpy.array(5*[1e7])
     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.image_frequency,
                                  channel_bandwidth=self.channel_bandwidth,
                                  phasecentre=self.phasecentre, weight=1.0,
                                  polarisation_frame=PolarisationFrame('stokesI'), zerow=True)
     self.vis.data['vis'] *= 0.0
     
     # Create model
     self.model = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.image_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
     
     dphasecentre = SkyCoord(ra=+181.0 * u.deg, dec=-58.0 * u.deg, frame='icrs', equinox='J2000')
     flux = [[numpy.power(f/1e8, -0.7)] for f in self.component_frequency]
     self.sc = create_skycomponent(direction=dphasecentre, flux=flux,
                                 frequency=self.component_frequency,
                                 polarisation_frame=PolarisationFrame('stokesI'))
Exemplo n.º 7
0
    def setUp(self):
        from data_models.parameters import arl_path
        dec = -40.0 * u.deg

        self.lowcore = create_named_configuration('LOWBD2', rmax=300.0)
        self.dir = arl_path('test_results')
        self.times = numpy.linspace(-10.0, 10.0,
                                    3) * numpy.pi / (3600.0 * 12.0)

        self.frequency = numpy.array([1e8])
        self.channel_bandwidth = numpy.array([1e6])
        self.phasecentre = SkyCoord(ra=+0.0 * u.deg,
                                    dec=dec,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = create_blockvisibility(
            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_image(
            npixel=512,
            cellsize=0.000015,
            polarisation_frame=PolarisationFrame("stokesI"),
            frequency=self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre)
Exemplo n.º 8
0
    def setUp(self):
        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')
        self.niter = 1000
        self.lowcore = create_named_configuration('LOWBD2-CORE')
        self.nchan = 5
        self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7)
        self.frequency = numpy.linspace(0.9e8, 1.1e8, self.nchan)
        self.channel_bandwidth = numpy.array(
            self.nchan * [self.frequency[1] - self.frequency[0]])
        self.phasecentre = SkyCoord(ra=+0.0 * u.deg,
                                    dec=-45.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = create_visibility(
            self.lowcore,
            self.times,
            self.frequency,
            self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('stokesI'),
            zerow=True)
        self.vis.data['vis'] *= 0.0

        # Create model
        self.test_model = create_low_test_image_from_gleam(
            npixel=512,
            cellsize=0.001,
            phasecentre=self.vis.phasecentre,
            frequency=self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            flux_limit=1.0)
        beam = create_low_test_beam(self.test_model)
        export_image_to_fits(beam,
                             "%s/test_deconvolve_mmclean_beam.fits" % self.dir)
        self.test_model.data *= beam.data
        export_image_to_fits(
            self.test_model,
            "%s/test_deconvolve_mmclean_model.fits" % self.dir)
        self.vis = predict_2d(self.vis, self.test_model)
        assert numpy.max(numpy.abs(self.vis.vis)) > 0.0
        self.model = create_image_from_visibility(
            self.vis,
            npixel=512,
            cellsize=0.001,
            polarisation_frame=PolarisationFrame('stokesI'))
        self.dirty, sumwt = invert_2d(self.vis, self.model)
        self.psf, sumwt = invert_2d(self.vis, self.model, dopsf=True)
        export_image_to_fits(
            self.dirty, "%s/test_deconvolve_mmclean-dirty.fits" % self.dir)
        export_image_to_fits(self.psf,
                             "%s/test_deconvolve_mmclean-psf.fits" % self.dir)
        window = numpy.ones(shape=self.model.shape, dtype=numpy.bool)
        window[..., 129:384, 129:384] = True
        self.innerquarter = create_image_from_array(
            window,
            self.model.wcs,
            polarisation_frame=PolarisationFrame('stokesI'))
Exemplo n.º 9
0
    def actualSetUp(self,
                    time=None,
                    frequency=None,
                    dospectral=False,
                    dopol=False):
        self.lowcore = create_named_configuration('LOWBD2', rmax=600)
        self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 5)

        if time is not None:
            self.times = time
        log.info("Times are %s" % (self.times))

        if dospectral:
            self.nchan = 3
            self.frequency = numpy.array([0.9e8, 1e8, 1.1e8])
            self.channel_bandwidth = numpy.array([1e7, 1e7, 1e7])
        else:
            self.frequency = numpy.array([1e8])
            self.channel_bandwidth = numpy.array([1e7])

        if dopol:
            self.vis_pol = PolarisationFrame('linear')
            self.image_pol = PolarisationFrame('stokesIQUV')
        else:
            self.vis_pol = PolarisationFrame('stokesI')
            self.image_pol = PolarisationFrame('stokesI')

        if dopol:
            f = numpy.array([100.0, 20.0, -10.0, 1.0])
        else:
            f = numpy.array([100.0])

        if dospectral:
            numpy.array([f, 0.8 * f, 0.6 * f])
        else:
            numpy.array([f])

        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-60.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.componentvis = 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.uvw = self.componentvis.data['uvw']
        self.componentvis.data['vis'] *= 0.0

        # Create model
        self.model = create_image_from_visibility(
            self.componentvis,
            npixel=self.npixel,
            cellsize=0.001,
            nchan=len(self.frequency),
            polarisation_frame=self.image_pol)
Exemplo n.º 10
0
    def setUp(self):

        self.lowcore = create_named_configuration('LOWBD2', rmax=750.0)

        self.times = numpy.linspace(-300.0, 300.0, 5) * numpy.pi / 43200.0

        self.frequency = numpy.array([1e8])
        self.channel_bandwidth = numpy.array([1e8])
        self.phasecentre = SkyCoord(ra=+15.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
Exemplo n.º 11
0
    def actualSetUp(self,
                    add_errors=False,
                    freqwin=1,
                    block=False,
                    dospectral=True,
                    dopol=False):

        self.npixel = 256
        self.low = create_named_configuration('LOWBD2', rmax=750.0)
        self.freqwin = freqwin
        self.vis_list = list()
        self.ntimes = 5
        self.times = numpy.linspace(-3.0, +3.0, self.ntimes) * numpy.pi / 12.0
        self.frequency = numpy.linspace(0.8e8, 1.2e8, self.freqwin)
        if freqwin > 1:
            self.channelwidth = numpy.array(
                freqwin * [self.frequency[1] - self.frequency[0]])
        else:
            self.channelwidth = numpy.array([1e6])

        if dopol:
            self.vis_pol = PolarisationFrame('linear')
            self.image_pol = PolarisationFrame('stokesIQUV')
            f = numpy.array([100.0, 20.0, -10.0, 1.0])
        else:
            self.vis_pol = PolarisationFrame('stokesI')
            self.image_pol = PolarisationFrame('stokesI')
            f = numpy.array([100.0])

        if dospectral:
            flux = numpy.array(
                [f * numpy.power(freq / 1e8, -0.7) for freq in self.frequency])
        else:
            flux = numpy.array([f])

        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-60.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = ingest_unittest_visibility(self.low,
                                              self.frequency,
                                              self.channelwidth,
                                              self.times,
                                              self.vis_pol,
                                              self.phasecentre,
                                              block=block)

        self.model = create_unittest_model(self.vis,
                                           self.image_pol,
                                           npixel=self.npixel)
Exemplo n.º 12
0
 def setUp(self):
     from data_models.parameters import arl_path
     self.dir = arl_path('test_results')
     
     self.frequency = numpy.linspace(0.8e8, 1.2e8, 5)
     self.channel_bandwidth = numpy.array([1e7, 1e7, 1e7, 1e7, 1e7])
     self.flux = numpy.array([[100.0], [100.0], [100.0], [100.0], [100.0]])
     self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000')
     self.config = create_named_configuration('LOWBD2-CORE')
     self.times = numpy.linspace(-300.0, 300.0, 3) * numpy.pi / 43200.0
     nants = self.config.xyz.shape[0]
     assert nants > 1
     assert len(self.config.names) == nants
     assert len(self.config.mount) == nants
 def actualSetUp(self, zerow=True):
     self.doplot = False
     self.npixel = 256
     self.cellsize = 0.0009
     self.low = create_named_configuration('LOWBD2', rmax=750.0)
     self.freqwin = 1
     self.vis_list = list()
     self.ntimes = 3
     self.times = numpy.linspace(-2.0, +2.0, self.ntimes) * numpy.pi / 12.0
     
     if self.freqwin == 1:
         self.frequency = numpy.array([1e8])
         self.channelwidth = numpy.array([4e7])
     else:
         self.frequency = numpy.linspace(0.8e8, 1.2e8, self.freqwin)
         self.channelwidth = numpy.array(self.freqwin * [self.frequency[1] - self.frequency[0]])
     
     self.vis_pol = PolarisationFrame('linear')
     self.image_pol = PolarisationFrame('stokesIQUV')
     
     f = numpy.array([100.0, 20.0, -10.0, 1.0])
     
     flux = numpy.array([f * numpy.power(freq / 1e8, -0.7) for freq in self.frequency])
     
     self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000')
     self.vis = ingest_unittest_visibility(self.low,
                                           self.frequency,
                                           self.channelwidth,
                                           self.times,
                                           self.vis_pol,
                                           self.phasecentre,
                                           block=False,
                                           zerow=zerow)
     
     self.model = create_unittest_model(self.vis, self.image_pol, cellsize=self.cellsize,
                                        npixel=self.npixel, nchan=self.freqwin)
     self.components = create_unittest_components(self.model, flux, applypb=False,
                                                  scale=0.5, single=False)
     self.model = insert_skycomponent(self.model, self.components)
     self.vis = predict_skycomponent_visibility(self.vis, self.components)
     
     # Calculate the model convolved with a Gaussian.
     self.cmodel = smooth_image(self.model)
     export_image_to_fits(self.model, '%s/test_gridding_model.fits' % self.dir)
     export_image_to_fits(self.cmodel, '%s/test_gridding_cmodel.fits' % self.dir)
     pb = create_pb_generic(self.model, diameter=35.0, blockage=0.0)
     self.cmodel.data *= pb.data
     export_image_to_fits(self.cmodel, '%s/test_gridding_cmodel_pb.fits' % self.dir)
     self.peak = numpy.unravel_index(numpy.argmax(numpy.abs(self.cmodel.data)), self.cmodel.shape)
    def setUp(self):

        self.lowcore = create_named_configuration('LOWBD2-CORE')

        self.times = numpy.linspace(-300.0, 300.0, 11) * numpy.pi / 43200.0

        self.frequency = numpy.linspace(1e8, 1.5e9, 7)

        self.channel_bandwidth = numpy.array(
            7 * [self.frequency[1] - self.frequency[0]])

        self.phasecentre = SkyCoord(ra=+15.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
Exemplo n.º 15
0
    def actualSetup(self,
                    sky_pol_frame='stokesIQUV',
                    data_pol_frame='linear',
                    f=None,
                    vnchan=1):
        self.lowcore = create_named_configuration('LOWBD2-CORE')
        self.times = (numpy.pi / 43200.0) * numpy.linspace(0.0, 30.0, 3)
        self.frequency = numpy.linspace(1.0e8, 1.1e8, vnchan)
        if vnchan > 1:
            self.channel_bandwidth = numpy.array(
                vnchan * [self.frequency[1] - self.frequency[0]])
        else:
            self.channel_bandwidth = numpy.array([2e7])

        if f is None:
            f = [100.0, 50.0, -10.0, 40.0]

        if sky_pol_frame == 'stokesI':
            f = [100.0]

        self.flux = numpy.outer(
            numpy.array(
                [numpy.power(freq / 1e8, -0.7) for freq in self.frequency]), f)

        # The phase centre is absolute and the component is specified relative (for now).
        # This means that the component should end up at the position phasecentre+compredirection
        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.compabsdirection = SkyCoord(ra=+181.0 * u.deg,
                                         dec=-35.0 * u.deg,
                                         frame='icrs',
                                         equinox='J2000')
        self.comp = Skycomponent(
            direction=self.compabsdirection,
            frequency=self.frequency,
            flux=self.flux,
            polarisation_frame=PolarisationFrame(sky_pol_frame))
        self.vis = create_blockvisibility(
            self.lowcore,
            self.times,
            self.frequency,
            phasecentre=self.phasecentre,
            channel_bandwidth=self.channel_bandwidth,
            weight=1.0,
            polarisation_frame=PolarisationFrame(data_pol_frame))
        self.vis = predict_skycomponent_visibility(self.vis, self.comp)
Exemplo n.º 16
0
 def test_predict_sky_components_coalesce(self):
     sc = create_low_test_skycomponents_from_gleam(flux_limit=10.0,
                                                   polarisation_frame=PolarisationFrame("stokesI"),
                                                   frequency=self.frequency, kind='cubic',
                                                   phasecentre=SkyCoord("17h20m31s", "-00d58m45s"),
                                                   radius=0.1)
     self.config = create_named_configuration('LOWBD2-CORE')
     self.phasecentre = SkyCoord("17h20m31s", "-00d58m45s")
     sampling_time = 3.76
     self.times = numpy.arange(0.0, + 300 * sampling_time, sampling_time)
     self.vis = create_blockvisibility(self.config, self.times, self.frequency, phasecentre=self.phasecentre,
                                       weight=1.0, polarisation_frame=PolarisationFrame('stokesI'),
                                       channel_bandwidth=self.channel_bandwidth)
     self.vis = predict_skycomponent_visibility(self.vis, sc)
     cvt = coalesce_visibility(self.vis, time_coal=1.0)
     assert cvt.cindex is not None
Exemplo n.º 17
0
    def setUp(self):

        self.lowcore = create_named_configuration('LOWBD2', rmax=300.0)
        self.times = (numpy.pi / 43200.0) * numpy.arange(0.0, 30 * 3.76, 3.76)
        df = 27343.75000
        self.frequency = numpy.array([1e8 - df, 1e8, 1e8 + df])
        self.channel_bandwidth = numpy.array([27343.75, 27343.75, 27343.75])
        self.phasecentre = SkyCoord(ra=+0.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.blockvis = create_blockvisibility(
            self.lowcore,
            self.times,
            self.frequency,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('stokesI'),
            channel_bandwidth=self.channel_bandwidth)
Exemplo n.º 18
0
 def actualSetup(self):
     self.lowcore = create_named_configuration('LOWBD2-CORE')
     self.times = (numpy.pi / 43200.0) * numpy.arange(0.0, 300.0, 30.0)
     self.times = [0.0]
     self.frequency = numpy.linspace(1.0e8, 1.1e8, 1)
     self.channel_bandwidth = numpy.array([1e7])
     # Define the component and give it some spectral behaviour
     f = numpy.array([100.0, 20.0, -10.0, 1.0])
     self.flux = numpy.array([f, 0.8 * f, 0.6 * f])
     
     f = numpy.array([100.0])
     self.flux = numpy.array([f])
     
     # The phase centre is absolute and the component is specified relative (for now).
     # This means that the component should end up at the position phasecentre+compredirection
     self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000')
     self.comp_actual_direction = SkyCoord(ra=+180.2 * u.deg, dec=-35.1 * u.deg, frame='icrs', equinox='J2000')
     self.comp_start_direction = SkyCoord(ra=+180.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000')
     self.comp = Skycomponent(direction=self.comp_actual_direction, frequency=self.frequency, flux=self.flux,
                              polarisation_frame=PolarisationFrame("stokesI"))
    def setUp(self):
        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')
        self.lowcore = create_named_configuration('LOWBD2-CORE')
        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'),
            zerow=True)
        self.vis.data['vis'] *= 0.0

        # Create model
        self.test_model = create_test_image(cellsize=0.001,
                                            phasecentre=self.vis.phasecentre,
                                            frequency=self.frequency)
        self.vis = predict_2d(self.vis, self.test_model)
        assert numpy.max(numpy.abs(self.vis.vis)) > 0.0
        self.model = create_image_from_visibility(
            self.vis,
            npixel=512,
            cellsize=0.001,
            polarisation_frame=PolarisationFrame('stokesI'))
        self.dirty, sumwt = invert_2d(self.vis, self.model)
        self.psf, sumwt = invert_2d(self.vis, self.model, dopsf=True)
        window = numpy.zeros(shape=self.model.shape, dtype=numpy.bool)
        window[..., 129:384, 129:384] = True
        self.innerquarter = create_image_from_array(
            window,
            self.model.wcs,
            polarisation_frame=PolarisationFrame('stokesI'))
    def setUp(self):
        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')
        self.lowcore = create_named_configuration('LOWBD2-CORE')
        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
        self.vis.data['uvw'][:, 2] = 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)
        residual, sumwt = invert_2d(self.vis, self.bigmodel)
        export_image_to_fits(
            residual,
            '%s/test_solve_skycomponent_msclean_dirty.fits' % (self.dir))
Exemplo n.º 21
0
    def actualSetup(self, sky_pol_frame='stokesIQUV', data_pol_frame='linear'):
        self.lowcore = create_named_configuration('LOWBD2', rmax=300.0)
        self.times = (numpy.pi / 43200.0) * numpy.arange(0.0, 300.0, 30.0)
        vnchan = 3
        self.frequency = numpy.linspace(1.0e8, 1.1e8, vnchan)
        self.channel_bandwidth = numpy.array(
            vnchan * [self.frequency[1] - self.frequency[0]])

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

        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-35.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.compabsdirection = SkyCoord(ra=+181.0 * u.deg,
                                         dec=-35.0 * u.deg,
                                         frame='icrs',
                                         equinox='J2000')
        if sky_pol_frame == 'stokesI':
            self.flux = self.flux[:, 0][:, numpy.newaxis]

        self.comp = Skycomponent(
            direction=self.compabsdirection,
            frequency=self.frequency,
            flux=self.flux,
            polarisation_frame=PolarisationFrame(sky_pol_frame))
        self.vis = create_blockvisibility(
            self.lowcore,
            self.times,
            self.frequency,
            phasecentre=self.phasecentre,
            channel_bandwidth=self.channel_bandwidth,
            weight=1.0,
            polarisation_frame=PolarisationFrame(data_pol_frame))
        self.vis = predict_skycomponent_visibility(self.vis, self.comp)
Exemplo n.º 22
0
 def test_unknown_configuration(self):
     with self.assertRaises(ValueError):
         self.config = create_named_configuration("SKA1-OWL")
    def ingest_visibility(self,
                          freq=None,
                          chan_width=None,
                          times=None,
                          add_errors=False,
                          block=True,
                          bandpass=False):
        if freq is None:
            freq = [1e8]
        if chan_width is None:
            chan_width = [1e6]
        if times is None:
            times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 5)

        lowcore = create_named_configuration('LOWBD2', rmax=750.0)
        frequency = numpy.array(freq)
        channel_bandwidth = numpy.array(chan_width)

        phasecentre = SkyCoord(ra=+180.0 * u.deg,
                               dec=-60.0 * u.deg,
                               frame='icrs',
                               equinox='J2000')
        if block:
            vt = create_blockvisibility(
                lowcore,
                times,
                frequency,
                channel_bandwidth=channel_bandwidth,
                weight=1.0,
                phasecentre=phasecentre,
                polarisation_frame=PolarisationFrame("stokesI"))
        else:
            vt = create_visibility(
                lowcore,
                times,
                frequency,
                channel_bandwidth=channel_bandwidth,
                weight=1.0,
                phasecentre=phasecentre,
                polarisation_frame=PolarisationFrame("stokesI"))
        cellsize = 0.001
        model = create_image_from_visibility(
            vt,
            npixel=self.npixel,
            cellsize=cellsize,
            npol=1,
            frequency=frequency,
            phasecentre=phasecentre,
            polarisation_frame=PolarisationFrame("stokesI"))
        nchan = len(self.frequency)
        flux = numpy.array(nchan * [[100.0]])
        facets = 4

        rpix = model.wcs.wcs.crpix - 1.0
        spacing_pixels = self.npixel // facets
        centers = [-1.5, -0.5, 0.5, 1.5]
        comps = list()
        for iy in centers:
            for ix in centers:
                p = int(round(rpix[0] + ix * spacing_pixels * numpy.sign(model.wcs.wcs.cdelt[0]))), \
                    int(round(rpix[1] + iy * spacing_pixels * numpy.sign(model.wcs.wcs.cdelt[1])))
                sc = pixel_to_skycoord(p[0], p[1], model.wcs, origin=1)
                comp = create_skycomponent(
                    direction=sc,
                    flux=flux,
                    frequency=frequency,
                    polarisation_frame=PolarisationFrame("stokesI"))
                comps.append(comp)
        if block:
            predict_skycomponent_visibility(vt, comps)
        else:
            predict_skycomponent_visibility(vt, comps)
        insert_skycomponent(model, comps)
        self.comps = comps
        self.model = copy_image(model)
        self.empty_model = create_empty_image_like(model)
        export_image_to_fits(
            model, '%s/test_pipeline_functions_model.fits' % (self.dir))

        if add_errors:
            # These will be the same for all calls
            numpy.random.seed(180555)
            gt = create_gaintable_from_blockvisibility(vt)
            gt = simulate_gaintable(gt, phase_error=1.0, amplitude_error=0.0)
            vt = apply_gaintable(vt, gt)

            if bandpass:
                bgt = create_gaintable_from_blockvisibility(vt, timeslice=1e5)
                bgt = simulate_gaintable(bgt,
                                         phase_error=0.01,
                                         amplitude_error=0.01,
                                         smooth_channels=4)
                vt = apply_gaintable(vt, bgt)

        return vt
Exemplo n.º 24
0
 def actualSetUp(self, add_errors=False, freqwin=1, block=False, dospectral=True, dopol=False, zerow=False):
     
     arlexecute.set_client(use_dask=False)
     
     self.npixel = 256
     self.low = create_named_configuration('LOWBD2', rmax=750.0)
     self.freqwin = freqwin
     self.vis_list = list()
     self.ntimes = 5
     self.times = numpy.linspace(-3.0, +3.0, self.ntimes) * numpy.pi / 12.0
     
     if freqwin > 1:
         self.frequency = numpy.linspace(0.8e8, 1.2e8, self.freqwin)
         self.channelwidth = numpy.array(freqwin * [self.frequency[1] - self.frequency[0]])
     else:
         self.frequency = numpy.array([0.8e8])
         self.channelwidth = numpy.array([1e6])
     
     if dopol:
         self.vis_pol = PolarisationFrame('linear')
         self.image_pol = PolarisationFrame('stokesIQUV')
         f = numpy.array([100.0, 20.0, -10.0, 1.0])
     else:
         self.vis_pol = PolarisationFrame('stokesI')
         self.image_pol = PolarisationFrame('stokesI')
         f = numpy.array([100.0])
     
     if dospectral:
         flux = numpy.array([f * numpy.power(freq / 1e8, -0.7) for freq in self.frequency])
     else:
         flux = numpy.array([f])
     
     self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000')
     self.vis_list = [arlexecute.execute(ingest_unittest_visibility)(self.low,
                                                                     [self.frequency[freqwin]],
                                                                     [self.channelwidth[freqwin]],
                                                                     self.times,
                                                                     self.vis_pol,
                                                                     self.phasecentre, block=block,
                                                                     zerow=zerow)
                      for freqwin, _ in enumerate(self.frequency)]
     
     self.model_list = [arlexecute.execute(create_unittest_model, nout=freqwin)(self.vis_list[freqwin],
                                                                                 self.image_pol,
                                                                                 npixel=self.npixel)
                         for freqwin, _ in enumerate(self.frequency)]
     
     self.components_list = [arlexecute.execute(create_unittest_components)(self.model_list[freqwin],
                                                                             flux[freqwin, :][numpy.newaxis, :])
                              for freqwin, _ in enumerate(self.frequency)]
     
     self.model_list = [arlexecute.execute(insert_skycomponent, nout=1)(self.model_list[freqwin],
                                                                         self.components_list[freqwin])
                         for freqwin, _ in enumerate(self.frequency)]
     
     self.vis_list = [arlexecute.execute(predict_skycomponent_visibility)(self.vis_list[freqwin],
                                                                          self.components_list[freqwin])
                      for freqwin, _ in enumerate(self.frequency)]
     
     # Calculate the model convolved with a Gaussian.
     self.model = arlexecute.compute(self.model_list[0], sync=True)
     
     self.cmodel = smooth_image(self.model)
     export_image_to_fits(self.model, '%s/test_imaging_model.fits' % self.dir)
     export_image_to_fits(self.cmodel, '%s/test_imaging_cmodel.fits' % self.dir)
     
     if add_errors and block:
         self.vis_list = [arlexecute.execute(insert_unittest_errors)(self.vis_list[i])
                          for i, _ in enumerate(self.frequency)]
     
     self.vis = arlexecute.compute(self.vis_list[0], sync=True)
     
     self.components = arlexecute.compute(self.components_list[0], sync=True)
 def actualSetup(self, vnchan=1, doiso=True, ntimes=5, flux_limit=2.0, zerow=True, fixed=False):
     
     nfreqwin = vnchan
     rmax = 300.0
     npixel = 512
     cellsize = 0.001
     frequency = numpy.linspace(0.8e8, 1.2e8, nfreqwin)
     if nfreqwin > 1:
         channel_bandwidth = numpy.array(nfreqwin * [frequency[1] - frequency[0]])
     else:
         channel_bandwidth = [0.4e8]
     times = numpy.linspace(-numpy.pi / 3.0, numpy.pi / 3.0, ntimes)
     
     phasecentre = SkyCoord(ra=-60.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000')
     
     lowcore = create_named_configuration('LOWBD2', rmax=rmax)
     
     block_vis = create_blockvisibility(lowcore, times, frequency=frequency, channel_bandwidth=channel_bandwidth,
                                        weight=1.0, phasecentre=phasecentre,
                                        polarisation_frame=PolarisationFrame("stokesI"), zerow=zerow)
     
     block_vis.data['uvw'][..., 2] = 0.0
     self.beam = create_image_from_visibility(block_vis, npixel=npixel, frequency=[numpy.average(frequency)],
                                              nchan=nfreqwin,
                                              channel_bandwidth=[numpy.sum(channel_bandwidth)], cellsize=cellsize,
                                              phasecentre=phasecentre)
     
     self.components = create_low_test_skycomponents_from_gleam(flux_limit=flux_limit, phasecentre=phasecentre,
                                                                frequency=frequency,
                                                                polarisation_frame=PolarisationFrame('stokesI'),
                                                                radius=npixel * cellsize)
     self.beam = create_low_test_beam(self.beam)
     self.components = apply_beam_to_skycomponent(self.components, self.beam, flux_limit=flux_limit)
     
     self.vis = copy_visibility(block_vis, zero=True)
     gt = create_gaintable_from_blockvisibility(block_vis, timeslice='auto')
     for i, sc in enumerate(self.components):
         if sc.flux[0, 0] > 10:
             sc.flux[...] /= 10.0
         component_vis = copy_visibility(block_vis, zero=True)
         gt = simulate_gaintable(gt, amplitude_error=0.0, phase_error=0.1, seed=None)
         component_vis = predict_skycomponent_visibility(component_vis, sc)
         component_vis = apply_gaintable(component_vis, gt)
         self.vis.data['vis'][...] += component_vis.data['vis'][...]
     
     # Do an isoplanatic selfcal
     self.model_vis = copy_visibility(self.vis, zero=True)
     self.model_vis = predict_skycomponent_visibility(self.model_vis, self.components)
     if doiso:
         gt = solve_gaintable(self.vis, self.model_vis, phase_only=True, timeslice='auto')
         self.vis = apply_gaintable(self.vis, gt, inverse=True)
     
     self.model_vis = convert_blockvisibility_to_visibility(self.model_vis)
     self.model_vis, _, _ = weight_visibility(self.model_vis, self.beam)
     self.dirty_model, sumwt = invert_arlexecute(self.model_vis, self.beam, context='2d')
     export_image_to_fits(self.dirty_model, "%s/test_modelpartition-model_dirty.fits" % self.dir)
     
     lvis = convert_blockvisibility_to_visibility(self.vis)
     lvis, _, _ = weight_visibility(lvis, self.beam)
     dirty, sumwt = invert_arlexecute(lvis, self.beam, context='2d')
     if doiso:
         export_image_to_fits(dirty, "%s/test_modelpartition-initial-iso-residual.fits" % self.dir)
     else:
         export_image_to_fits(dirty, "%s/test_modelpartition-initial-noiso-residual.fits" % self.dir)
     
     self.skymodels = [SkyModel(components=[cm], fixed=fixed) for cm in self.components]
Exemplo n.º 26
0
    def actualSetUp(self,
                    freqwin=1,
                    block=False,
                    dospectral=True,
                    dopol=False,
                    zerow=False):

        self.npixel = 512
        self.low = create_named_configuration('LOWBD2', rmax=750.0)
        self.freqwin = freqwin
        self.vis = list()
        self.ntimes = 5
        self.times = numpy.linspace(-3.0, +3.0, self.ntimes) * numpy.pi / 12.0

        if freqwin > 1:
            self.frequency = numpy.linspace(0.8e8, 1.2e8, self.freqwin)
            self.channelwidth = numpy.array(
                freqwin * [self.frequency[1] - self.frequency[0]])
        else:
            self.frequency = numpy.array([1e8])
            self.channelwidth = numpy.array([1e6])

        if dopol:
            self.vis_pol = PolarisationFrame('linear')
            self.image_pol = PolarisationFrame('stokesIQUV')
            f = numpy.array([100.0, 20.0, -10.0, 1.0])
        else:
            self.vis_pol = PolarisationFrame('stokesI')
            self.image_pol = PolarisationFrame('stokesI')
            f = numpy.array([100.0])

        if dospectral:
            flux = numpy.array(
                [f * numpy.power(freq / 1e8, -0.7) for freq in self.frequency])
        else:
            flux = numpy.array([f])

        self.phasecentre = SkyCoord(ra=+180.0 * u.deg,
                                    dec=-60.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = ingest_unittest_visibility(self.low, [self.frequency],
                                              [self.channelwidth],
                                              self.times,
                                              self.vis_pol,
                                              self.phasecentre,
                                              block=block,
                                              zerow=zerow)

        self.model = create_unittest_model(self.vis,
                                           self.image_pol,
                                           npixel=self.npixel)

        self.components = create_unittest_components(self.model, flux)

        self.model = insert_skycomponent(self.model, self.components)

        self.vis = predict_skycomponent_visibility(self.vis, self.components)

        # Calculate the model convolved with a Gaussian.

        self.cmodel = smooth_image(self.model)
        export_image_to_fits(self.model,
                             '%s/test_imaging_model.fits' % self.dir)
        export_image_to_fits(self.cmodel,
                             '%s/test_imaging_cmodel.fits' % self.dir)
Exemplo n.º 27
0
def simulate_arlexecute(config='LOWBD2',
                        phasecentre=SkyCoord(ra=+15.0 * u.deg,
                                             dec=-60.0 * u.deg,
                                             frame='icrs',
                                             equinox='J2000'),
                        frequency=None,
                        channel_bandwidth=None,
                        times=None,
                        polarisation_frame=PolarisationFrame("stokesI"),
                        order='frequency',
                        format='blockvis',
                        rmax=1000.0,
                        zerow=False):
    """ A component to simulate an observation

    The simulation step can generate a single BlockVisibility or a list of BlockVisibility's.
    The parameter keyword determines the way that the list is constructed.
    If order='frequency' then len(frequency) BlockVisibility's with all times are created.
    If order='time' then  len(times) BlockVisibility's with all frequencies are created.
    If order = 'both' then len(times) * len(times) BlockVisibility's are created each with
    a single time and frequency. If order = None then all data are created in one BlockVisibility.

    The output format can be either 'blockvis' (for calibration) or 'vis' (for imaging)

    :param config: Name of configuration: def LOWBDS-CORE
    :param phasecentre: Phase centre def: SkyCoord(ra=+15.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000')
    :param frequency: def [1e8]
    :param channel_bandwidth: def [1e6]
    :param times: Observing times in radians: def [0.0]
    :param polarisation_frame: def PolarisationFrame("stokesI")
    :param order: 'time' or 'frequency' or 'both' or None: def 'frequency'
    :param format: 'blockvis' or 'vis': def 'blockvis'
    :return: vis_list with different frequencies in different elements
    """
    if format == 'vis':
        create_vis = create_visibility
    else:
        create_vis = create_blockvisibility

    if times is None:
        times = [0.0]
    if channel_bandwidth is None:
        channel_bandwidth = [1e6]
    if frequency is None:
        frequency = [1e8]
    conf = create_named_configuration(config, rmax=rmax)

    if order == 'time':
        log.debug("simulate_arlexecute: Simulating distribution in %s" % order)
        vis_list = list()
        for i, time in enumerate(times):
            vis_list.append(
                arlexecute.execute(create_vis, nout=1)(
                    conf,
                    numpy.array([times[i]]),
                    frequency=frequency,
                    channel_bandwidth=channel_bandwidth,
                    weight=1.0,
                    phasecentre=phasecentre,
                    polarisation_frame=polarisation_frame,
                    zerow=zerow))

    elif order == 'frequency':
        log.debug("simulate_arlexecute: Simulating distribution in %s" % order)
        vis_list = list()
        for j, _ in enumerate(frequency):
            vis_list.append(
                arlexecute.execute(create_vis, nout=1)(
                    conf,
                    times,
                    frequency=numpy.array([frequency[j]]),
                    channel_bandwidth=numpy.array([channel_bandwidth[j]]),
                    weight=1.0,
                    phasecentre=phasecentre,
                    polarisation_frame=polarisation_frame,
                    zerow=zerow))

    elif order == 'both':
        log.debug(
            "simulate_arlexecute: Simulating distribution in time and frequency"
        )
        vis_list = list()
        for i, _ in enumerate(times):
            for j, _ in enumerate(frequency):
                vis_list.append(
                    arlexecute.execute(create_vis, nout=1)(
                        conf,
                        numpy.array([times[i]]),
                        frequency=numpy.array([frequency[j]]),
                        channel_bandwidth=numpy.array([channel_bandwidth[j]]),
                        weight=1.0,
                        phasecentre=phasecentre,
                        polarisation_frame=polarisation_frame,
                        zerow=zerow))

    elif order is None:
        log.debug("simulate_arlexecute: Simulating into single %s" % format)
        vis_list = list()
        vis_list.append(
            arlexecute.execute(create_vis,
                               nout=1)(conf,
                                       times,
                                       frequency=frequency,
                                       channel_bandwidth=channel_bandwidth,
                                       weight=1.0,
                                       phasecentre=phasecentre,
                                       polarisation_frame=polarisation_frame,
                                       zerow=zerow))
    else:
        raise NotImplementedError("order $s not known" % order)
    return vis_list
log.addHandler(logging.StreamHandler(sys.stdout))

# We create a graph to make the visibility. The parameter rmax determines the distance of the furthest antenna/stations used. All over parameters are determined from this number.

nfreqwin = 5
ntimes = 11
rmax = 300.0
frequency = numpy.linspace(0.8e8, 1.2e8, nfreqwin)
channel_bandwidth = numpy.array(nfreqwin * [frequency[1] - frequency[0]])
times = numpy.linspace(-numpy.pi / 3.0, numpy.pi / 3.0, ntimes)
phasecentre = SkyCoord(ra=+30.0 * u.deg,
                       dec=-60.0 * u.deg,
                       frame='icrs',
                       equinox='J2000')

lowcore = create_named_configuration('LOWBD2-CORE', rmax=rmax)

block_vis = create_blockvisibility(
    lowcore,
    times,
    frequency=frequency,
    channel_bandwidth=channel_bandwidth,
    weight=1.0,
    phasecentre=phasecentre,
    polarisation_frame=PolarisationFrame("stokesI"))

wprojection_planes = 1
advice = advise_wide_field(block_vis,
                           guard_band_image=4.0,
                           delA=0.02,
                           wprojection_planes=wprojection_planes)
Exemplo n.º 29
0
 def test_clip_configuration(self):
     for rmax in [
             100.0, 3000.0, 1000.0, 3000.0, 10000.0, 30000.0, 100000.0
     ]:
         self.config = create_named_configuration('LOWBD2', rmax=rmax)
         assert self.config.size() > 0.0