コード例 #1
0
 def actualSetUp(self, freqwin=1, block=True, dopol=False, zerow=False):
     
     self.npixel = 1024
     self.low = create_named_configuration('LOWBD2', rmax=550.0)
     self.freqwin = freqwin
     self.blockvis_list = list()
     self.ntimes = 5
     self.cellsize = 0.0005
     # Choose the interval so that the maximum change in w is smallish
     integration_time = numpy.pi * (24 / (12 * 60))
     self.times = numpy.linspace(-integration_time * (self.ntimes // 2), integration_time * (self.ntimes // 2),
                                 self.ntimes)
     
     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([1.0e8])
         self.channelwidth = numpy.array([4e7])
     
     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])
     
     self.phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=-40.0 * u.deg, frame='icrs', equinox='J2000')
     self.blockvis_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.blockvis_list = arlexecute.compute(self.blockvis_list, sync=True)
     self.vis_list = [arlexecute.execute(convert_blockvisibility_to_visibility)(bv) for bv in self.blockvis_list]
     self.vis_list = arlexecute.compute(self.vis_list, sync=True)
     
     self.skymodel_list = [arlexecute.execute(create_low_test_skymodel_from_gleam)
                           (npixel=self.npixel, cellsize=self.cellsize, frequency=[self.frequency[f]],
                            phasecentre=self.phasecentre,
                            polarisation_frame=PolarisationFrame("stokesI"),
                            flux_limit=0.6,
                            flux_threshold=1.0,
                            flux_max=5.0) for f, freq in enumerate(self.frequency)]
     
     self.skymodel_list = arlexecute.compute(self.skymodel_list, sync=True)
     assert isinstance(self.skymodel_list[0].image, Image), self.skymodel_list[0].image
     assert isinstance(self.skymodel_list[0].components[0], Skycomponent), self.skymodel_list[0].components[0]
     assert len(self.skymodel_list[0].components) == 19, len(self.skymodel_list[0].components)
     self.skymodel_list = expand_skymodel_by_skycomponents(self.skymodel_list[0])
     assert len(self.skymodel_list) == 20, len(self.skymodel_list)
     assert numpy.max(numpy.abs(self.skymodel_list[-1].image.data)) > 0.0, "Image is empty"
     self.vis_list = [copy_visibility(self.vis_list[0], zero=True) for i, _ in enumerate(self.skymodel_list)]
コード例 #2
0
    def actualSetUp(self, freqwin=3, block=False, dopol=False, zerow=False):

        self.npixel = 1024
        self.low = create_named_configuration('LOWBD2', rmax=750.0)
        self.freqwin = freqwin
        self.vis_list = list()
        self.ntimes = 5
        self.cellsize = 0.0005
        # Choose the interval so that the maximum change in w is smallish
        integration_time = numpy.pi * (24 / (12 * 60))
        self.times = numpy.linspace(-integration_time * (self.ntimes // 2),
                                    integration_time * (self.ntimes // 2),
                                    self.ntimes)

        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([1.0e8])
            self.channelwidth = numpy.array([4e7])

        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])

        self.phasecentre = SkyCoord(ra=+30.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)
        ]
コード例 #3
0
    def actualSetUp(self,
                    nfreqwin=3,
                    dospectral=True,
                    dopol=False,
                    amp_errors=None,
                    phase_errors=None,
                    zerow=True):

        if amp_errors is None:
            amp_errors = {'T': 0.0, 'G': 0.1}
        if phase_errors is None:
            phase_errors = {'T': 1.0, 'G': 0.0}

        self.npixel = 512
        self.low = create_named_configuration('LOWBD2', rmax=750.0)
        self.freqwin = nfreqwin
        self.vis_list = list()
        self.ntimes = 1
        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 self.freqwin > 1:
            self.channelwidth = numpy.array(
                self.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.blockvis_list = [
            arlexecute.execute(ingest_unittest_visibility,
                               nout=1)(self.low, [self.frequency[i]],
                                       [self.channelwidth[i]],
                                       self.times,
                                       self.vis_pol,
                                       self.phasecentre,
                                       block=True,
                                       zerow=zerow) for i in range(nfreqwin)
        ]
        self.blockvis_list = arlexecute.compute(self.blockvis_list, sync=True)

        for v in self.blockvis_list:
            v.data['vis'][...] = 1.0 + 0.0j

        self.error_blockvis_list = [
            arlexecute.execute(copy_visibility(v)) for v in self.blockvis_list
        ]
        gt = arlexecute.execute(create_gaintable_from_blockvisibility)(
            self.blockvis_list[0])
        gt = arlexecute.execute(simulate_gaintable)(gt,
                                                    phase_error=0.1,
                                                    amplitude_error=0.0,
                                                    smooth_channels=1,
                                                    leakage=0.0,
                                                    seed=180555)
        self.error_blockvis_list = [
            arlexecute.execute(apply_gaintable)(self.error_blockvis_list[i],
                                                gt)
            for i in range(self.freqwin)
        ]

        self.error_blockvis_list = arlexecute.compute(self.error_blockvis_list,
                                                      sync=True)

        assert numpy.max(
            numpy.abs(self.error_blockvis_list[0].vis -
                      self.blockvis_list[0].vis)) > 0.0
コード例 #4
0
    def actualSetUp(self,
                    add_errors=False,
                    freqwin=5,
                    block=False,
                    dospectral=True,
                    dopol=False,
                    amp_errors=None,
                    phase_errors=None,
                    zerow=True):

        if amp_errors is None:
            amp_errors = {'T': 0.0, 'G': 0.01, 'B': 0.01}
        if phase_errors is None:
            phase_errors = {'T': 1.0, 'G': 0.1, 'B': 0.01}

        self.npixel = 512
        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_list = [
            arlexecute.execute(ingest_unittest_visibility)(
                self.low, [self.frequency[i]], [self.channelwidth[i]],
                self.times,
                self.vis_pol,
                self.phasecentre,
                block=block,
                zerow=zerow) for i, _ in enumerate(self.frequency)
        ]

        self.model_imagelist = [
            arlexecute.execute(create_unittest_model,
                               nout=freqwin)(self.vis_list[0],
                                             self.image_pol,
                                             npixel=self.npixel)
            for i, _ in enumerate(self.frequency)
        ]

        self.components_list = [
            arlexecute.execute(create_unittest_components)(
                self.model_imagelist[i], flux[i, :][numpy.newaxis, :])
            for i, _ in enumerate(self.frequency)
        ]

        # Apply the LOW primary beam and insert into model
        self.model_imagelist = [
            arlexecute.execute(insert_skycomponent,
                               nout=1)(self.model_imagelist[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_imagelist = arlexecute.compute(self.model_imagelist,
                                                  sync=True)
        model = self.model_imagelist[0]
        self.cmodel = smooth_image(model)
        export_image_to_fits(model,
                             '%s/test_imaging_delayed_model.fits' % self.dir)
        export_image_to_fits(self.cmodel,
                             '%s/test_imaging_delayed_cmodel.fits' % self.dir)

        if add_errors and block:
            self.vis_list = [
                arlexecute.execute(insert_unittest_errors)(
                    self.vis_list[i],
                    amp_errors=amp_errors,
                    phase_errors=phase_errors)
                for i, _ in enumerate(self.frequency)
            ]

        self.vis_list = arlexecute.compute(self.vis_list, sync=True)

        self.vis_list = arlexecute.scatter(self.vis_list)
        self.model_imagelist = arlexecute.scatter(self.model_imagelist)
コード例 #5
0
def simulate_list_arlexecute_workflow(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_list_arlexecute_workflow: 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_list_arlexecute_workflow: 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_list_arlexecute_workflow: 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_list_arlexecute_workflow: 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
    def actualSetUp(self,
                    add_errors=False,
                    nfreqwin=7,
                    dospectral=True,
                    dopol=False,
                    zerow=True):

        self.npixel = 512
        self.low = create_named_configuration('LOWBD2', rmax=750.0)
        self.freqwin = nfreqwin
        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 self.freqwin > 1:
            self.channelwidth = numpy.array(
                self.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.blockvis_list = [
            arlexecute.execute(ingest_unittest_visibility,
                               nout=1)(self.low, [self.frequency[i]],
                                       [self.channelwidth[i]],
                                       self.times,
                                       self.vis_pol,
                                       self.phasecentre,
                                       block=True,
                                       zerow=zerow) for i in range(nfreqwin)
        ]
        self.blockvis_list = arlexecute.compute(self.blockvis_list, sync=True)
        self.blockvis_list = arlexecute.scatter(self.blockvis_list)

        self.vis_list = [
            arlexecute.execute(convert_blockvisibility_to_visibility,
                               nout=1)(bv) for bv in self.blockvis_list
        ]
        self.vis_list = arlexecute.compute(self.vis_list, sync=True)
        self.vis_list = arlexecute.scatter(self.vis_list)

        self.model_imagelist = [
            arlexecute.execute(create_unittest_model,
                               nout=1)(self.vis_list[i],
                                       self.image_pol,
                                       npixel=self.npixel,
                                       cellsize=0.0005)
            for i in range(nfreqwin)
        ]
        self.model_imagelist = arlexecute.compute(self.model_imagelist,
                                                  sync=True)
        self.model_imagelist = arlexecute.scatter(self.model_imagelist)

        self.components_list = [
            arlexecute.execute(create_unittest_components)(
                self.model_imagelist[freqwin],
                flux[freqwin, :][numpy.newaxis, :])
            for freqwin, m in enumerate(self.model_imagelist)
        ]
        self.components_list = arlexecute.compute(self.components_list,
                                                  sync=True)
        self.components_list = arlexecute.scatter(self.components_list)

        self.blockvis_list = [
            arlexecute.execute(predict_skycomponent_visibility)(
                self.blockvis_list[freqwin], self.components_list[freqwin])
            for freqwin, _ in enumerate(self.blockvis_list)
        ]
        self.blockvis_list = arlexecute.compute(self.blockvis_list, sync=True)
        self.vis = self.blockvis_list[0]
        self.blockvis_list = arlexecute.scatter(self.blockvis_list)

        self.model_imagelist = [
            arlexecute.execute(insert_skycomponent,
                               nout=1)(self.model_imagelist[freqwin],
                                       self.components_list[freqwin])
            for freqwin in range(nfreqwin)
        ]
        self.model_imagelist = arlexecute.compute(self.model_imagelist,
                                                  sync=True)
        model = self.model_imagelist[0]
        self.cmodel = smooth_image(model)
        if self.persist:
            export_image_to_fits(
                model, '%s/test_pipelines_arlexecute_model.fits' % self.dir)
            export_image_to_fits(
                self.cmodel,
                '%s/test_pipelines_arlexecute_cmodel.fits' % self.dir)

        if add_errors:
            gt = create_gaintable_from_blockvisibility(self.vis)
            gt = simulate_gaintable(gt,
                                    phase_error=0.1,
                                    amplitude_error=0.0,
                                    smooth_channels=1,
                                    leakage=0.0,
                                    seed=180555)
            self.blockvis_list = [
                arlexecute.execute(apply_gaintable,
                                   nout=1)(self.blockvis_list[i], gt)
                for i in range(self.freqwin)
            ]
            self.blockvis_list = arlexecute.compute(self.blockvis_list,
                                                    sync=True)
            self.blockvis_list = arlexecute.scatter(self.blockvis_list)

        self.vis_list = [
            arlexecute.execute(convert_blockvisibility_to_visibility)(bv)
            for bv in self.blockvis_list
        ]
        self.vis_list = arlexecute.compute(self.vis_list, sync=True)
        self.vis_list = arlexecute.scatter(self.vis_list)

        self.model_imagelist = [
            arlexecute.execute(create_unittest_model,
                               nout=1)(self.vis_list[i],
                                       self.image_pol,
                                       npixel=self.npixel,
                                       cellsize=0.0005)
            for i in range(nfreqwin)
        ]
        self.model_imagelist = arlexecute.compute(self.model_imagelist,
                                                  sync=True)
        self.model_imagelist = arlexecute.scatter(self.model_imagelist)
    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_list_arlexecute_workflow(
            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_list_arlexecute_workflow(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
        ]
コード例 #8
0
    def actualSetUp(self,
                    add_errors=False,
                    freqwin=3,
                    block=False,
                    dospectral=True,
                    dopol=False,
                    zerow=False,
                    makegcfcf=False):

        self.npixel = 256
        self.low = create_named_configuration('LOWBD2', rmax=750.0)
        self.freqwin = freqwin
        self.vis_list = list()
        self.ntimes = 5
        self.cellsize = 0.0005
        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.frequency = numpy.array([1.0e8])
            self.channelwidth = numpy.array([4e7])

        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,
                                             cellsize=self.cellsize,
                                             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, :],
                single=True) for freqwin, _ in enumerate(self.frequency)
        ]

        self.components_list = arlexecute.compute(self.components_list,
                                                  sync=True)

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

        self.model_list = arlexecute.compute(self.model_list, sync=True)

        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.

        centre = self.freqwin // 2
        self.model = self.model_list[centre]

        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.components = self.components_list[centre]

        if makegcfcf:
            self.gcfcf = [
                create_awterm_convolutionfunction(self.model,
                                                  nw=61,
                                                  wstep=16.0,
                                                  oversampling=4,
                                                  support=60,
                                                  use_aaf=True)
            ]
            self.gcfcf_clipped = [
                (self.gcfcf[0][0],
                 apply_bounding_box_convolutionfunction(self.gcfcf[0][1],
                                                        fractional_level=1e-3))
            ]

            self.gcfcf_joint = [
                create_awterm_convolutionfunction(self.model,
                                                  nw=11,
                                                  wstep=16.0,
                                                  oversampling=4,
                                                  support=60,
                                                  use_aaf=True)
            ]

        else:
            self.gcfcf = None
            self.gcfcf_clipped = None
            self.gcfcf_joint = None