Example #1
0
    def ft_ift_sm(ov, sm, g):
        assert isinstance(ov, Visibility) or isinstance(ov,
                                                        BlockVisibility), ov
        assert isinstance(sm, SkyModel), sm
        if g is not None:
            assert len(g) == 2, g
            assert isinstance(g[0], Image), g[0]
            assert isinstance(g[1], ConvolutionFunction), g[1]

        v = copy_visibility(ov)

        v.data['vis'][...] = 0.0 + 0.0j

        if len(sm.components) > 0:

            if isinstance(sm.mask, Image):
                comps = copy_skycomponent(sm.components)
                comps = apply_beam_to_skycomponent(comps, sm.mask)
                v = predict_skycomponent_visibility(v, comps)
            else:
                v = predict_skycomponent_visibility(v, sm.components)

        if isinstance(sm.image, Image):
            if numpy.max(numpy.abs(sm.image.data)) > 0.0:
                if isinstance(sm.mask, Image):
                    model = copy_image(sm.image)
                    model.data *= sm.mask.data
                else:
                    model = sm.image
                v = predict_list_serial_workflow([v], [model],
                                                 context=context,
                                                 vis_slices=vis_slices,
                                                 facets=facets,
                                                 gcfcf=[g],
                                                 **kwargs)[0]

        assert isinstance(sm.image, Image), sm.image

        result = invert_list_serial_workflow([v], [sm.image],
                                             context=context,
                                             vis_slices=vis_slices,
                                             facets=facets,
                                             gcfcf=[g],
                                             **kwargs)[0]
        if isinstance(sm.mask, Image):
            result[0].data *= sm.mask.data
        return result
Example #2
0
    def ft_cal_sm(obv, sm):
        assert isinstance(obv, BlockVisibility), obv
        bv = copy_visibility(obv)

        bv.data['vis'][...] = 0.0 + 0.0j

        assert len(sm.components) > 0

        if isinstance(sm.mask, Image):
            comps = copy_skycomponent(sm.components)
            comps = apply_beam_to_skycomponent(comps, sm.mask)
            bv = predict_skycomponent_visibility(bv, comps)
        else:
            bv = predict_skycomponent_visibility(bv, sm.components)

        if docal and isinstance(sm.gaintable, GainTable):
            bv = apply_gaintable(bv, sm.gaintable, inverse=True)

        return bv
Example #3
0
    def test_apply_primary_beam_imageplane(self):
        self.createVis()
        telescope = 'MID'
        lflux = numpy.array([[100.0, 1.0, -10.0, +60.0]])
        cflux = numpy.array([[100.0, 60.0, -10.0, +1.0]])
        apply_pb = True
        for flux, vpol in ((lflux, PolarisationFrame("linear")),
                           (cflux, PolarisationFrame("circular"))):
            # print("Testing {0}".format(vpol.type))
            # print("Original flux = {}".format(flux))
            bvis = create_blockvisibility(
                self.config,
                self.times,
                self.frequency,
                channel_bandwidth=self.channel_bandwidth,
                phasecentre=self.phasecentre,
                weight=1.0,
                polarisation_frame=vpol,
                zerow=True)

            component_centre = SkyCoord(ra=+15.5 * u.deg,
                                        dec=-35.0 * u.deg,
                                        frame='icrs',
                                        equinox='J2000')
            component = create_skycomponent(
                direction=component_centre,
                flux=flux,
                frequency=self.frequency,
                polarisation_frame=PolarisationFrame("stokesIQUV"))
            model = create_image_from_visibility(
                bvis,
                cellsize=self.cellsize,
                npixel=self.npixel,
                override_cellsize=False,
                polarisation_frame=PolarisationFrame("stokesIQUV"))
            pb = create_pb(model, telescope=telescope, use_local=False)
            if apply_pb:
                pbcomp = apply_beam_to_skycomponent(component, pb)
                # print("After application of primary beam {}".format(str(pbcomp.flux)))
            else:
                pbcomp = copy_skycomponent(component)
            bvis = dft_skycomponent_visibility(bvis, pbcomp)
            iquv_image = idft_visibility_skycomponent(bvis, component)[0]
Example #4
0
    def ft_cal_sm(ov, sm, g):
        assert isinstance(ov, Visibility), ov
        assert isinstance(sm, SkyModel), sm
        if g is not None:
            assert len(g) == 2, g
            assert isinstance(g[0], Image), g[0]
            assert isinstance(g[1], ConvolutionFunction), g[1]

        v = copy_visibility(ov)

        v.data['vis'][...] = 0.0 + 0.0j

        if len(sm.components) > 0:

            if isinstance(sm.mask, Image):
                comps = copy_skycomponent(sm.components)
                comps = apply_beam_to_skycomponent(comps, sm.mask)
                v = predict_skycomponent_visibility(v, comps)
            else:
                v = predict_skycomponent_visibility(v, sm.components)

        if isinstance(sm.image, Image):
            if numpy.max(numpy.abs(sm.image.data)) > 0.0:
                if isinstance(sm.mask, Image):
                    model = copy_image(sm.image)
                    model.data *= sm.mask.data
                else:
                    model = sm.image
                v = predict_list_serial_workflow([v], [model],
                                                 context=context,
                                                 vis_slices=vis_slices,
                                                 facets=facets,
                                                 gcfcf=[g],
                                                 **kwargs)[0]

        if docal and isinstance(sm.gaintable, GainTable):
            bv = convert_visibility_to_blockvisibility(v)
            bv = apply_gaintable(bv, sm.gaintable, inverse=True)
            v = convert_blockvisibility_to_visibility(bv)

        return v