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)
Пример #2
0
    def test_useFunction(self):
        def square(x):
            return x**2

        arlexecute.set_client(use_dask=False)
        graph = arlexecute.execute(square)(numpy.arange(10))
        assert (arlexecute.compute(graph) == numpy.array(
            [0, 1, 4, 9, 16, 25, 36, 49, 64, 81])).all()
        arlexecute.close()
Пример #3
0
 def test_create_simulate_vis_graph(self):
     arlexecute.set_client(use_dask=True)
     vis_list = simulate_component(frequency=self.frequency,
                                   channel_bandwidth=self.channel_bandwidth)
     assert len(vis_list) == len(self.frequency)
     vt = vis_list[0].compute()
     assert isinstance(vt, BlockVisibility)
     assert vt.nvis > 0
     arlexecute.close()
Пример #4
0
    def test_useDaskSync(self):
        def square(x):
            return x**2

        arlexecute.set_client(use_dask=True)
        graph = arlexecute.execute(square)(numpy.arange(10))
        result = arlexecute.compute(graph, sync=True)
        assert (result == numpy.array([0, 1, 4, 9, 16, 25, 36, 49, 64,
                                       81])).all()
        arlexecute.close()
Пример #5
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_graph = arlexecute.execute(create_test_image)(
            frequency=self.frequency,
            phasecentre=self.phasecentre,
            cellsize=0.001,
            polarisation_frame=PolarisationFrame('stokesI'))
    logging.basicConfig(
        filename='%s/gleam-pipeline.log' % results_dir,
        filemode='a',
        format=
        '%(thread)s %(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
        datefmt='%H:%M:%S',
        level=logging.INFO)


if __name__ == '__main__':
    pp = pprint.PrettyPrinter()

    log = logging.getLogger()
    logging.info("Starting ical-pipeline")

    arlexecute.set_client(get_dask_Client())
    arlexecute.run(init_logging)

    import pickle

    # Load data from previous simulation
    vislist = import_blockvisibility_from_hdf5('gleam_simulation_vislist.hdf')

    print(vislist[0])

    cellsize = 0.001
    npixel = 1024
    pol_frame = PolarisationFrame("stokesI")

    model_list = [
        arlexecute.execute(create_image_from_visibility)(
Пример #7
0
    def actualSetUp(self,
                    add_errors=False,
                    freqwin=1,
                    block=False,
                    dospectral=True,
                    dopol=False,
                    zerow=False):

        arlexecute.set_client(use_dask=True)

        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_graph = [
            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_graph = [
            arlexecute.execute(create_unittest_components)(
                self.model_graph[freqwin], flux[freqwin, :][numpy.newaxis, :])
            for freqwin, _ in enumerate(self.frequency)
        ]

        self.model_graph = [
            arlexecute.execute(insert_skycomponent,
                               nout=1)(self.model_graph[freqwin],
                                       self.components_graph[freqwin])
            for freqwin, _ in enumerate(self.frequency)
        ]

        self.vis_list = [
            arlexecute.execute(predict_skycomponent_visibility)(
                self.vis_list[freqwin], self.components_graph[freqwin])
            for freqwin, _ in enumerate(self.frequency)
        ]

        # Calculate the model convolved with a Gaussian.
        self.model = arlexecute.compute(self.model_graph[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_graph[0],
                                             sync=True)
Пример #8
0
 def test_setup_errors(self):
     with self.assertRaises(AssertionError):
         arlexecute.set_client(client=1)