Ejemplo n.º 1
0
 def test_run_components(self):
     files = ["test_results/test_pipeline.log",
              "test_results/test_skymodel.hdf",
              "test_results/test_empty_vislist.hdf",
              "test_results/test_perfect_vislist.hdf",
              "test_results/test_perfect_restored.fits",
              "test_results/test_perfect_deconvolved.fits",
              "test_results/test_perfect_residual.fits"
              ]
     try:
         for f in files:
             os.remove(arl_path(f))
     except FileNotFoundError:
         pass
     
     config_files = ["tests/workflows/test_create_vislist.json",
                     "tests/workflows/test_create_skymodel.json",
                     "tests/workflows/test_predict_vislist.json",
                     "tests/workflows/test_continuum_imaging.json"]
     
     for config_file in config_files:
         component_wrapper(arl_path(config_file))
     
     for f in files:
         assert os.path.isfile(arl_path(f)), "File %s does not exist" % arl_path(f)
Ejemplo n.º 2
0
    def test_plot_gaintable_to_screen(self):
        screen = import_image_from_fits(
            arl_path('data/models/test_mpc_screen.fits'))
        beam = create_test_image(cellsize=0.0015,
                                 phasecentre=self.vis.phasecentre,
                                 frequency=self.frequency)

        beam = create_low_test_beam(beam)

        gleam_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.2)

        pb_gleam_components = apply_beam_to_skycomponent(
            gleam_components, beam)

        actual_components = filter_skycomponents_by_flux(pb_gleam_components,
                                                         flux_min=1.0)

        gaintables = create_gaintable_from_screen(self.vis, actual_components,
                                                  screen)
        assert len(gaintables) == len(actual_components), len(gaintables)
        assert gaintables[0].gain.shape == (3, 94, 1, 1,
                                            1), gaintables[0].gain.shape

        plot_gaintable_on_screen(
            self.vis,
            gaintables,
            plotfile=arl_path(
                'test_results/test_plot_gaintable_to_screen.png'))
Ejemplo n.º 3
0
def create_vp(model, telescope='MID', pointingcentre=None, padding=4, use_local=True):
    """
    Make an image like model and fill it with an analytical model of the voltage pattern
    :param model: Template image
    :param telescope: 'VLA' or 'ASKAP'
    :return: Primary beam image
    """
    if telescope == 'MID_GAUSS':
        log.debug("create_vp: Using numeric tapered Gaussian model for MID voltage pattern")
        
        return create_vp_generic_numeric(model, pointingcentre=pointingcentre, diameter=15.0, blockage=0.0,
                                         edge=0.07918124604762482, padding=padding, use_local=use_local)
    elif telescope == 'MID':
        log.debug("create_vp: Using no taper analytic model for MID voltage pattern")
        return create_vp_generic(model, pointingcentre=pointingcentre, diameter=15.0, blockage=0.0, use_local=use_local)
    elif telescope == 'MID_GRASP':
        log.debug("create_vp: Using GRASP model for MID voltage pattern")
        real_vp = import_image_from_fits(arl_path('data/models/MID_GRASP_VP_real.fits'))
        imag_vp = import_image_from_fits(arl_path('data/models/MID_GRASP_VP_imag.fits'))
        real_vp.data = real_vp.data + 1j * imag_vp.data
        real_vp.data /= numpy.max(numpy.abs(real_vp.data))
        return real_vp
    elif telescope == 'MEERKAT':
        return create_vp_generic(model, pointingcentre=pointingcentre, diameter=13.5, blockage=0.0, use_local=use_local)
    elif telescope[0:3] == 'LOW':
        return create_low_test_vp(model)
    elif telescope[0:3] == 'VLA':
        return create_vp_generic(model, pointingcentre=pointingcentre, diameter=25.0, blockage=1.8, use_local=use_local)
    elif telescope[0:5] == 'ASKAP':
        return create_vp_generic(model, pointingcentre=pointingcentre, diameter=12.0, blockage=1.0, use_local=use_local)
    else:
        raise NotImplementedError('Telescope %s has no voltage pattern model' % telescope)
Ejemplo n.º 4
0
    def test_copy_ms(self):
        if run_ms_tests == False:
            return

        msfile = arl_path("data/vis/ASKAP_example.ms")
        msoutfile = arl_path("data/vis/ASKAP_output.ms")

        vis_by_channel = list()
        v = create_blockvisibility_from_ms(msfile)
        export_blockvisility_to_ms(msoutfile,v)                # vis_by_channel.append(integrate_visibility_by_channel(v[0]))
 def setUp(self):
     from data_models.parameters import arl_path
     
     self.doplot = True
     
     self.midcore = create_named_configuration('MID', rmax=100.0)
     self.nants = len(self.midcore.names)
     self.dir = arl_path('test_results')
     self.ntimes = 100
     interval = 10.0
     self.times = numpy.arange(0.0, float(self.ntimes)) * interval
     self.times *= numpy.pi / 43200.0
     
     self.frequency = numpy.array([1.4e9])
     self.channel_bandwidth = numpy.array([1e7])
     self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-45.0 * u.deg, frame='icrs', equinox='J2000')
     self.vis = create_blockvisibility(self.midcore, 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.001, polarisation_frame=PolarisationFrame("stokesI"),
                               frequency=self.frequency, channel_bandwidth=self.channel_bandwidth,
                               phasecentre=self.phasecentre)
    def setUp(self):

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

        self.persist = True
        self.verbosity = 0
    def test_create_list_spectral_average_arlexecute(self):
        if not self.casacore_available:
            return

        msfile = arl_path("data/vis/ASKAP_example.ms")

        from workflows.arlexecute.execution_support.arlexecute import arlexecute
        arlexecute.set_client(use_dask=False)

        nchan_ave = 16
        nchan = 192

        def create_and_average(schan):
            max_chan = min(nchan, schan + nchan_ave)
            bv = create_blockvisibility_from_ms(msfile, range(schan, max_chan))
            return integrate_visibility_by_channel(bv[0])

        vis_by_channel_workflow = \
            [arlexecute.execute(create_and_average)(schan) for schan in range(0, nchan, nchan_ave)]

        vis_by_channel = arlexecute.compute(vis_by_channel_workflow)
        arlexecute.close()

        assert len(vis_by_channel) == 12
        for v in vis_by_channel:
            assert v.vis.data.shape[-1] == 4
            assert v.polarisation_frame.type == "linear"
            assert v.vis.data.shape[-2] == 1
Ejemplo n.º 8
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 / (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)
Ejemplo n.º 9
0
    def setUp(self):

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

        self.m31image = create_test_image(cellsize=0.0001)
        self.cellsize = 180.0 * 0.0001 / numpy.pi
    def setUp(self):
        client = get_dask_Client(memory_limit=4 * 1024 * 1024 * 1024,
                                 n_workers=4,
                                 dashboard_address=None)
        global arlexecute
        arlexecute = ARLExecuteBase(use_dask=True)
        arlexecute.set_client(client, verbose=True)

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

        self.frequency = numpy.linspace(1e8, 1.5e8, 3)
        self.channel_bandwidth = numpy.array([2.5e7, 2.5e7, 2.5e7])
        self.flux = numpy.array([[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

        self.persist = False
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
    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)
 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'))
Ejemplo n.º 14
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'))
    def setUp(self):

        client = get_dask_Client(memory_limit=4 * 1024 * 1024 * 1024)
        arlexecute.set_client(client)

        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')
Ejemplo n.º 16
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)
Ejemplo n.º 17
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
Ejemplo n.º 18
0
    def test_invert(self):

        uvfitsfile = arl_path("data/vis/ASKAP_example.fits")

        nchan_ave = 32
        nchan = 192
        for schan in range(0, nchan, nchan_ave):
            max_chan = min(nchan, schan + nchan_ave)
            bv = create_blockvisibility_from_uvfits(uvfitsfile,
                                                    range(schan, max_chan))[0]
            vis = convert_blockvisibility_to_visibility(bv)
            from processing_components.visibility.operations import convert_visibility_to_stokesI
            vis = convert_visibility_to_stokesI(vis)
            model = create_image_from_visibility(
                vis,
                npixel=256,
                polarisation_frame=PolarisationFrame('stokesI'))
            dirty, sumwt = invert_2d(vis, model, context='2d')
            assert (numpy.max(numpy.abs(dirty.data))) > 0.0
            assert dirty.shape == (nchan_ave, 1, 256, 256)
            import matplotlib.pyplot as plt
            from processing_components.image.operations import show_image
            show_image(dirty)
            plt.show()
            if self.persist:
                export_image_to_fits(
                    dirty, '%s/test_visibility_uvfits_dirty.fits' % self.dir)
Ejemplo n.º 19
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'))
    def setUp(self):

        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')
        # Set up MPI
        self.comm = MPI.COMM_WORLD
        self.rank = self.comm.Get_rank()
        self.size = self.comm.Get_size()
    def setUp(self):

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

        arlexecute.set_client(use_dask=False)

        numpy.random.seed(180555)
Ejemplo n.º 22
0
 def setUp(self):
     client = get_dask_Client(memory_limit=4 * 1024 * 1024 * 1024, n_workers=4, dashboard_address=None)
     global arlexecute
     arlexecute = ARLExecuteBase(use_dask=True)
     arlexecute.set_client(client, verbose=True)
     from data_models.parameters import arl_path
     self.dir = arl_path('test_results')
     self.persist = True
Ejemplo n.º 23
0
def create_test_image(
    canonical=True,
    cellsize=None,
    frequency=None,
    channel_bandwidth=None,
    phasecentre=None,
    polarisation_frame=PolarisationFrame("stokesI")) -> Image:
    """Create a useful test image

    This is the test image M31 widely used in ALMA and other simulations. It is actually part of an Halpha region in
    M31.

    :param canonical: Make the image into a 4 dimensional image
    :param cellsize:
    :param frequency: Frequency (array) in Hz
    :param channel_bandwidth: Channel bandwidth (array) in Hz
    :param phasecentre: Phase centre of image (SkyCoord)
    :param polarisation_frame: Polarisation frame
    :return: Image
    """
    if frequency is None:
        frequency = [1e8]
    im = import_image_from_fits(arl_path("data/models/M31.MOD"))
    if canonical:

        if polarisation_frame is None:
            im.polarisation_frame = PolarisationFrame("stokesI")
        elif isinstance(polarisation_frame, PolarisationFrame):
            im.polarisation_frame = polarisation_frame
        else:
            raise ValueError("polarisation_frame is not valid")

        im = replicate_image(im,
                             frequency=frequency,
                             polarisation_frame=im.polarisation_frame)
        if cellsize is not None:
            im.wcs.wcs.cdelt[0] = -180.0 * cellsize / numpy.pi
            im.wcs.wcs.cdelt[1] = +180.0 * cellsize / numpy.pi
        if frequency is not None:
            im.wcs.wcs.crval[3] = frequency[0]
        if channel_bandwidth is not None:
            im.wcs.wcs.cdelt[3] = channel_bandwidth[0]
        else:
            if len(frequency) > 1:
                im.wcs.wcs.cdelt[3] = frequency[1] - frequency[0]
            else:
                im.wcs.wcs.cdelt[3] = 0.001 * frequency[0]
        im.wcs.wcs.radesys = 'ICRS'
        im.wcs.wcs.equinox = 2000.00

    if phasecentre is not None:
        im.wcs.wcs.crval[0] = phasecentre.ra.deg
        im.wcs.wcs.crval[1] = phasecentre.dec.deg
        # WCS is 1 relative
        im.wcs.wcs.crpix[0] = im.data.shape[3] // 2 + 1
        im.wcs.wcs.crpix[1] = im.data.shape[2] // 2 + 1

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

        self.frequency = numpy.array([1e8])
        self.channel_bandwidth = numpy.array([1e6])
        self.phasecentre = SkyCoord(ra=+0.0 * u.deg,
                                    dec=-55.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
 def setUp(self):
 
     from data_models.parameters import arl_path
     self.dir = arl_path('test_results')
     
     self.frequency = numpy.linspace(1e8, 1.5e8, 3)
     self.channel_bandwidth = numpy.array([2.5e7, 2.5e7, 2.5e7])
     self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000')
     self.times = numpy.linspace(-300.0, 300.0, 3) * numpy.pi / 43200.0
     arlexecute.set_client(use_dask=False)
def create_named_configuration(name: str = 'LOWBD2', **kwargs) -> Configuration:
    """ Standard configurations e.g. LOWBD2, MIDBD2

    :param name: name of Configuration LOWBD2, LOWBD1, LOFAR, VLAA, ASKAP
    :param rmax: Maximum distance of station from the average (m)
    :return:
    
    For LOWBD2, setting rmax gives the following number of stations
    100.0       13
    300.0       94
    1000.0      251
    3000.0      314
    10000.0     398
    30000.0     476
    100000.0    512
    """
    
    if name == 'LOWBD2':
        location = EarthLocation(lon="116.4999", lat="-26.7000", height=300.0)
        fc = create_configuration_from_file(antfile=arl_path("data/configurations/LOWBD2.csv"),
                                            location=location, mount='xy', names='LOWBD2_%d',
                                            diameter=35.0, name=name, **kwargs)
    elif name == 'LOWBD1':
        location = EarthLocation(lon="116.4999", lat="-26.7000", height=300.0)
        fc = create_configuration_from_file(antfile=arl_path("data/configurations/LOWBD1.csv"),
                                            location=location, mount='xy', names='LOWBD1_%d',
                                            diameter=35.0, name=name, **kwargs)
    elif name == 'LOWBD2-CORE':
        location = EarthLocation(lon="116.4999", lat="-26.7000", height=300.0)
        fc = create_configuration_from_file(antfile=arl_path("data/configurations/LOWBD2-CORE.csv"),
                                            location=location, mount='xy', names='LOWBD2_%d',
                                            diameter=35.0, name=name, **kwargs)
    elif name == 'ASKAP':
        location = EarthLocation(lon="+116.6356824", lat="-26.7013006", height=377.0)
        fc = create_configuration_from_file(antfile=arl_path("data/configurations/A27CR3P6B.in.csv"),
                                            mount='equatorial', names='ASKAP_%d',
                                            diameter=12.0, name=name, location=location, **kwargs)
    elif name == 'LOFAR':
        assert get_parameter(kwargs, "meta", False) is False
        fc = create_LOFAR_configuration(antfile=arl_path("data/configurations/LOFAR.csv"))
    elif name == 'VLAA':
        location = EarthLocation(lon="-107.6184", lat="34.0784", height=2124.0)
        fc = create_configuration_from_file(antfile=arl_path("data/configurations/VLA_A_hor_xyz.csv"),
                                            location=location,
                                            mount='altaz',
                                            names='VLA_%d',
                                            diameter=25.0, name=name, **kwargs)
    elif name == 'VLAA_north':
        location = EarthLocation(lon="-107.6184", lat="90.000", height=2124.0)
        fc = create_configuration_from_file(antfile=arl_path("data/configurations/VLA_A_hor_xyz.csv"),
                                            location=location,
                                            mount='altaz',
                                            names='VLA_%d',
                                            diameter=25.0, name=name, **kwargs)
    else:
        raise ValueError("No such Configuration %s" % name)
    return fc
Ejemplo n.º 27
0
    def progress(res, tl_list, gt_list, it, context='MPCCAL'):
        print('Iteration %d' % it)

        print(
            qa_image(res,
                     context='%s residual image: iteration %d' %
                     (context, it)))
        export_image_to_fits(
            res,
            arl_path(
                "test_results/low-sims-mpc-%s-residual_iteration%d_rmax%.1f.fits"
                % (context, it, rmax)))
        show_image(res,
                   title='%s residual image: iteration %d' % (context, it))
        plt.show(block=block_plots)

        combined_model = calculate_skymodel_equivalent_image(tl_list)
        print(
            qa_image(combined_model,
                     context='Combined model: iteration %d' % it))
        export_image_to_fits(
            combined_model,
            arl_path(
                "test_results/low-sims-mpc-%s-model_iteration%d_rmax%.1f.fits"
                % (context, it, rmax)))

        plt.clf()
        for i in range(len(tl_list)):
            plt.plot(
                numpy.angle(tl_list[i].gaintable.gain[:, :, 0, 0,
                                                      0]).flatten(),
                numpy.angle(gt_list[i]['T'].gain[:, :, 0, 0, 0]).flatten(),
                '.')
        plt.xlabel('Current phase')
        plt.ylabel('Update to phase')
        plt.title("%s iteration%d: Change in phase" % (context, it))
        plt.savefig(
            arl_path(
                "test_results/low-sims-mpc-%s-skymodel-phase-change_iteration%d.jpg"
                % (context, it)))
        plt.show(block=block_plots)
        return tl_list
Ejemplo n.º 28
0
    def test_initialise_config(self):
        config = initialise_config_wrapper(arl_path("tests/processing_components/test_json_helpers.json"))
        for key in ['execute', 'component', 'logging', 'inputs', 'outputs', 'imaging', 'image', 'deconvolution',
                    'create_vislist']:
            assert key in config.keys(), "Key %s not in configuration"
            
        log = logging.getLogger(__name__)
        initialise_logging_wrapper(config)

        log.info('Test message')
        log.info(str(config))
Ejemplo n.º 29
0
 def test_create_list(self):
     
     if not self.casacore_available:
         return
     
     msfile = arl_path("data/vis/xcasa.ms")
     self.vis = create_blockvisibility_from_ms(msfile)
     
     for v in self.vis:
         assert v.vis.data.shape[-1] == 4
         assert v.polarisation_frame.type == "circular"
def create_low_test_beam(model: Image) -> Image:
    """Create a test power beam for LOW using an image from OSKAR

    :param model: Template image
    :return: Image
    """

    beam = import_image_from_fits(arl_path('data/models/SKA1_LOW_beam.fits'))

    # Scale the image cellsize to account for the different in frequencies. Eventually we will want to
    # use a frequency cube
    log.info("create_low_test_beam: primary beam is defined at %.3f MHz" %
             (beam.wcs.wcs.crval[2] * 1e-6))

    nchan, npol, ny, nx = model.shape

    # We need to interpolate each frequency channel separately. The beam is assumed to just scale with
    # frequency.

    reprojected_beam = create_empty_image_like(model)

    for chan in range(nchan):

        model2dwcs = model.wcs.sub(2).deepcopy()
        model2dshape = [model.shape[2], model.shape[3]]
        beam2dwcs = beam.wcs.sub(2).deepcopy()

        # The frequency axis is the second to last in the beam
        frequency = model.wcs.sub(['spectral']).wcs_pix2world([chan], 0)[0]
        fscale = beam.wcs.wcs.crval[2] / frequency

        beam2dwcs.wcs.cdelt = fscale * beam.wcs.sub(2).wcs.cdelt
        beam2dwcs.wcs.crpix = beam.wcs.sub(2).wcs.crpix
        beam2dwcs.wcs.crval = model.wcs.sub(2).wcs.crval
        beam2dwcs.wcs.ctype = model.wcs.sub(2).wcs.ctype
        model2dwcs.wcs.crpix = [
            model.shape[2] // 2 + 1, model.shape[3] // 2 + 1
        ]

        beam2d = create_image_from_array(beam.data[0, 0, :, :], beam2dwcs,
                                         model.polarisation_frame)
        reprojected_beam2d, footprint = reproject_image(beam2d,
                                                        model2dwcs,
                                                        shape=model2dshape)
        assert numpy.max(
            footprint.data) > 0.0, "No overlap between beam and model"

        reprojected_beam2d.data *= reprojected_beam2d.data
        reprojected_beam2d.data[footprint.data <= 0.0] = 0.0
        for pol in range(npol):
            reprojected_beam.data[chan,
                                  pol, :, :] = reprojected_beam2d.data[:, :]

    return reprojected_beam