def test_ical_pipeline_global(self):
        self.actualSetUp(add_errors=True)
        controls = create_calibration_controls()
        controls['T']['first_selfcal'] = 1
        controls['T']['timeslice'] = 'auto'
        
        clean, residual, restored, gt_list = \
            ical_list_serial_workflow(self.vis_list,
                                      model_imagelist=self.model_imagelist,
                                      context='2d',
                                      algorithm='mmclean', facets=1,
                                      scales=[0, 3, 10],
                                      niter=1000, fractional_threshold=0.1, threshold=0.1,
                                      nmoment=3,
                                      nmajor=5, gain=0.1,
                                      deconvolve_facets=4, deconvolve_overlap=32,
                                      deconvolve_taper='tukey', psf_support=64,
                                      restore_facets=4, psfwidth=1.0,
                                      calibration_context='T', controls=controls, do_selfcal=True,
                                      global_solution=True)
        
        centre = len(clean) // 2
        if self.persist:
            export_image_to_fits(clean[centre], '%s/test_pipelines_ical_global_pipeline_serial_clean.fits' % self.dir)
            export_image_to_fits(residual[centre][0], '%s/test_pipelines_ical_global_pipeline_serial_residual.fits' % self.dir)
            export_image_to_fits(restored[centre], '%s/test_pipelines_ical_global_pipeline_serial_restored.fits' % self.dir)
            export_gaintable_to_hdf5(gt_list[0]['T'],
                                     '%s/test_pipelines_ical_global_pipeline_serial_gaintable.hdf5' %
                                     self.dir)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 99.88268162471103) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] + 0.4016554844145119) < 1.0e-7, str(qa)
예제 #2
0
 def test_readwritegaintable(self):
     self.vis = create_blockvisibility(self.mid, self.times, self.frequency,
                                       channel_bandwidth=self.channel_bandwidth,
                                       phasecentre=self.phasecentre,
                                       polarisation_frame=PolarisationFrame("linear"),
                                       weight=1.0)
     gt = create_gaintable_from_blockvisibility(self.vis, timeslice='auto')
     gt = simulate_gaintable(gt, phase_error=1.0, amplitude_error=0.1)
     export_gaintable_to_hdf5(gt, '%s/test_data_model_helpers_gaintable.hdf' % self.dir)
     newgt = import_gaintable_from_hdf5('%s/test_data_model_helpers_gaintable.hdf' % self.dir)
 
     for key in gt.data.dtype.fields:
         assert numpy.max(numpy.abs(newgt.data[key] - gt.data[key])) < 1e-15
 
     assert gt.data.shape == newgt.data.shape
     assert numpy.max(numpy.abs(gt.gain - newgt.gain)) < 1e-15
    def test_ical_pipeline_pol(self):
        self.actualSetUp(add_errors=True, dopol=True)
        controls = create_calibration_controls()
        controls['T']['first_selfcal'] = 1
        controls['T']['timeslice'] = 'auto'

        ical_list = \
            ical_list_rsexecute_workflow(self.vis_list,
                                         model_imagelist=self.model_imagelist,
                                         context='2d',
                                         algorithm='mmclean', facets=1,
                                         scales=[0, 3, 10],
                                         niter=1000, fractional_threshold=0.1, threshold=0.1,
                                         nmoment=3,
                                         nmajor=5, gain=0.1,
                                         deconvolve_facets=4, deconvolve_overlap=32,
                                         deconvolve_taper='tukey', psf_support=64,
                                         restore_facets=4, psfwidth=1.0,
                                         calibration_context='T', controls=controls, do_selfcal=True,
                                         global_solution=False)
        clean, residual, restored, gt_list = rsexecute.compute(ical_list,
                                                               sync=True)
        centre = len(clean) // 2
        if self.persist:
            export_image_to_fits(
                clean[centre],
                '%s/test_pipelines_ical_pipeline_pol_rsexecute_clean.fits' %
                self.dir)
            export_image_to_fits(
                residual[centre][0],
                '%s/test_pipelines_ical_pipeline__polrsexecute_residual.fits' %
                self.dir)
            export_image_to_fits(
                restored[centre],
                '%s/test_pipelines_ical_pipeline_pol_rsexecute_restored.fits' %
                self.dir)
            export_gaintable_to_hdf5(
                gt_list[centre]['T'],
                '%s/test_pipelines_ical_pipeline_pol_rsexecute_gaintable.hdf5'
                % self.dir)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 88.18493789481009) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] + 2.0896642789962585) < 1.0e-7, str(qa)