def predict_skymodel_list_serial_workflow(vis_list, skymodel_list, context, vis_slices=1, facets=1, gcfcf=None, **kwargs): """Predict from a skymodel, iterating over both the vis_list and skymodel The visibility and image are scattered, the visibility is predicted on each part, and then the parts are assembled. :param vis_list: :param skymodel_list: skymodel list :param vis_slices: Number of vis slices (w stack or timeslice) :param facets: Number of facets (per axis) :param context: Type of processing e.g. 2d, wstack, timeslice or facets :param gcfcg: tuple containing grid correction and convolution function :param kwargs: Parameters for functions in components :return: List of vis_lists """ def extract_comps(sm): return sm.components def extract_image(sm): return sm.images[0] comp = [extract_comps(sm) for sm in skymodel_list] images = [extract_image(sm) for sm in skymodel_list] dft_vis_list = zero_list_serial_workflow(vis_list) dft_vis_list = [ predict_skycomponent_visibility(dft_vis_list[i], comp[i]) for i, _ in enumerate(dft_vis_list) ] fft_vis_list = zero_list_serial_workflow(vis_list) fft_vis_list = predict_list_serial_workflow(fft_vis_list, images, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) def vis_add(v1, v2): vout = copy_visibility(v1) vout.data['vis'] += v2.data['vis'] return vout return [ vis_add(dft_vis_list[i], fft_vis_list[i]) for i, _ in enumerate(dft_vis_list) ]
def _predict_base(self, context='2d', extra='', fluxthreshold=1.0, facets=1, vis_slices=1, gcfcf=None, **kwargs): centre = self.freqwin // 2 vis_list = zero_list_serial_workflow(self.vis_list) vis_list = predict_list_serial_workflow(vis_list, self.model_list, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) vis_list = subtract_list_serial_workflow(self.vis_list, vis_list) dirty = invert_list_serial_workflow(vis_list, self.model_list, context='2d', dopsf=False, gcfcf=gcfcf, normalize=True)[centre] assert numpy.max(numpy.abs(dirty[0].data)), "Residual image is empty" export_image_to_fits( dirty[0], '%s/test_imaging_predict_%s%s_serial_dirty.fits' % (self.dir, context, extra)) maxabs = numpy.max(numpy.abs(dirty[0].data)) assert maxabs < fluxthreshold, "Error %.3f greater than fluxthreshold %.3f " % ( maxabs, fluxthreshold)
def test_zero_list(self): self.actualSetUp() centre = self.freqwin // 2 vis_list = zero_list_serial_workflow(self.vis_list) assert numpy.max(numpy.abs(vis_list[centre].vis)) < 1e-15, numpy.max( numpy.abs(vis_list[centre].vis)) predicted_vis_list = [ predict_skycomponent_visibility(vis_list[freqwin], self.components_list[freqwin]) for freqwin, _ in enumerate(self.frequency) ] assert numpy.max(numpy.abs(predicted_vis_list[centre].vis)) > 0.0, \ numpy.max(numpy.abs(predicted_vis_list[centre].vis)) diff_vis_list = subtract_list_serial_workflow(self.vis_list, predicted_vis_list) assert numpy.max(numpy.abs( diff_vis_list[centre].vis)) < 1e-15, numpy.max( numpy.abs(diff_vis_list[centre].vis))