processing_components/imaging/base.py
def predict_skycomponent_visibility(vis: Union[Visibility, BlockVisibility],
                                    sc: Union[Skycomponent, List[Skycomponent]]) -> Union[Visibility, BlockVisibility]:
    """Predict the visibility from a Skycomponent, add to existing visibility, for Visibility or BlockVisibility

    :param vis: Visibility or BlockVisibility
    :param sc: Skycomponent or list of SkyComponents
    :return: Visibility or BlockVisibility
    """
    if sc is None:
        return vis
    
    if not isinstance(sc, collections.Iterable):
        sc = [sc]

    
    if isinstance(vis, Visibility):
        
        _, im_nchan = list(get_frequency_map(vis, None))
        
        for comp in sc:
            assert isinstance(comp, Skycomponent), comp
            
            assert_same_chan_pol(vis, comp)
            
            l, m, n = skycoord_to_lmn(comp.direction, vis.phasecentre)
            phasor = simulate_point(vis.uvw, l, m)
            
            comp_flux = comp.flux[im_nchan, :]
            vis.data['vis'][...] += comp_flux[:,:] * phasor[:, numpy.newaxis]

    elif isinstance(vis, BlockVisibility):
        
        ntimes, nant, _, nchan, npol = vis.vis.shape
        
        k = numpy.array(vis.frequency) / constants.c.to('m s^-1').value
        
        for comp in sc:
            #            assert isinstance(comp, Skycomponent), comp
            assert_same_chan_pol(vis, comp)
            
            flux = comp.flux
            if comp.polarisation_frame != vis.polarisation_frame:
                flux = convert_pol_frame(flux, comp.polarisation_frame, vis.polarisation_frame)
            
            l, m, n = skycoord_to_lmn(comp.direction, vis.phasecentre)
            uvw = vis.uvw[..., numpy.newaxis] * k
            phasor = numpy.ones([ntimes, nant, nant, nchan, npol], dtype='complex')
            for chan in range(nchan):
                phasor[:, :, :, chan, :] = simulate_point(uvw[..., chan], l, m)[..., numpy.newaxis]
            
            vis.data['vis'][..., :, :] += flux[:, :] * phasor[..., :]
    
    return vis
Predict the visibility from a Skycomponent, add to existing visibility, for Visibility or BlockVisibility

    :param vis: Visibility or BlockVisibility
    :param sc: Skycomponent or list of SkyComponents
    :return: Visibility or BlockVisibility
    
Predict the visibility from a Skycomponent, add to existing visibility, for Visibility or BlockVisibility
Predict the visibility from a Skycomponent add to existing visibility for Visibility or BlockVisibility
def predict_skycomponent_visibility(vis: Union[Visibility, BlockVisibility],
                                    sc: Union[Skycomponent, List[Skycomponent]]) -> Union[Visibility, BlockVisibility]:
    if sc is None:
        return vis
    if not isinstance(sc, collections.Iterable):
        sc = [sc]
    if isinstance(vis, Visibility):
        _, im_nchan = list(get_frequency_map(vis, None))
        for comp in sc:
            assert isinstance(comp, Skycomponent), comp
            assert_same_chan_pol(vis, comp)
            l, m, n = skycoord_to_lmn(comp.direction, vis.phasecentre)
            phasor = simulate_point(vis.uvw, l, m)
            comp_flux = comp.flux[im_nchan, :]
            vis.data['vis'][...] += comp_flux[:,:] * phasor[:, numpy.newaxis]
    elif isinstance(vis, BlockVisibility):
        ntimes, nant, _, nchan, npol = vis.vis.shape
        k = numpy.array(vis.frequency) / constants.c.to('m s^-1').value
        for comp in sc:
            assert_same_chan_pol(vis, comp)
            flux = comp.flux
            if comp.polarisation_frame != vis.polarisation_frame:
                flux = convert_pol_frame(flux, comp.polarisation_frame, vis.polarisation_frame)
            l, m, n = skycoord_to_lmn(comp.direction, vis.phasecentre)
            uvw = vis.uvw[..., numpy.newaxis] * k
            phasor = numpy.ones([ntimes, nant, nant, nchan, npol], dtype='complex')
            for chan in range(nchan):
                phasor[:, :, :, chan, :] = simulate_point(uvw[..., chan], l, m)[..., numpy.newaxis]
            vis.data['vis'][..., :, :] += flux[:, :] * phasor[..., :]
    return vis
def predict_skycomponent_visibility ( vis : Union [ Visibility , BlockVisibility ] , sc : Union [ Skycomponent , List [ Skycomponent ] ] ) -> Union [ Visibility , BlockVisibility ] : if sc is None : return vis if not isinstance ( sc , collections . Iterable ) : sc = [ sc ] if isinstance ( vis , Visibility ) : _ , im_nchan = list ( get_frequency_map ( vis , None ) ) for comp in sc : assert isinstance ( comp , Skycomponent ) , comp assert_same_chan_pol ( vis , comp ) l , m , n = skycoord_to_lmn ( comp . direction , vis . phasecentre ) phasor = simulate_point ( vis . uvw , l , m ) comp_flux = comp . flux [ im_nchan , : ] vis . data [ 'vis' ] [ ... ] += comp_flux [ : , : ] * phasor [ : , numpy . newaxis ] elif isinstance ( vis , BlockVisibility ) : ntimes , nant , _ , nchan , npol = vis . vis . shape k = numpy . array ( vis . frequency ) / constants . c . to ( 'm s^-1' ) . value for comp in sc : assert_same_chan_pol ( vis , comp ) flux = comp . flux if comp . polarisation_frame != vis . polarisation_frame : flux = convert_pol_frame ( flux , comp . polarisation_frame , vis . polarisation_frame ) l , m , n = skycoord_to_lmn ( comp . direction , vis . phasecentre ) uvw = vis . uvw [ ... , numpy . newaxis ] * k phasor = numpy . ones ( [ ntimes , nant , nant , nchan , npol ] , dtype = 'complex' ) for chan in range ( nchan ) : phasor [ : , : , : , chan , : ] = simulate_point ( uvw [ ... , chan ] , l , m ) [ ... , numpy . newaxis ] vis . data [ 'vis' ] [ ... , : , : ] += flux [ : , : ] * phasor [ ... , : ] return vis
Predict the visibility from a Skycomponent, add to existing visibility, for Visibility or BlockVisibility
Predict the visibility from a Skycomponent add to existing visibility for Visibility or BlockVisibility
"""Predict the visibility from a Skycomponent, add to existing visibility, for Visibility or BlockVisibility

    :param vis: Visibility or BlockVisibility
    :param sc: Skycomponent or list of SkyComponents
    :return: Visibility or BlockVisibility
    """ #            assert isinstance(comp, Skycomponent), comp
Visibility or BlockVisibility
Visibility or BlockVisibility
vis
Union[Visibility, BlockVisibility]
Visibility or BlockVisibility
Visibility or BlockVisibility
sc
Union[Skycomponent, List[Skycomponent]]
Skycomponent or list of SkyComponents
Skycomponent or list of SkyComponents