processing_components/simulation/ionospheric_screen.py
def create_gaintable_from_screen(vis, sc, screen, height=3e5, vis_slices=None, scale=1.0, **kwargs):
    """ Create gaintables from a screen calculated using ARatmospy

    :param vis:
    :param sc: Sky components for which pierce points are needed
    :param screen:
    :param height: Height (in m) of screen above telescope e.g. 3e5
    :param scale: Multiply the screen by this factor
    :return:
    """
    assert isinstance(vis, BlockVisibility)
    
    station_locations = vis.configuration.xyz
    
    # Convert to TEC
    # phase = image[pixel] * -8.44797245e9 / frequency
    nant = station_locations.shape[0]
    t2r = numpy.pi / 43200.0
    gaintables = [create_gaintable_from_blockvisibility(vis, **kwargs) for i in sc]
    
    # The time in the Visibility is hour angle in seconds!
    for iha, rows in enumerate(vis_timeslice_iter(vis, vis_slices=vis_slices)):
        v = create_visibility_from_rows(vis, rows)
        ha = numpy.average(v.time)
        tec2phase = - 8.44797245e9 / numpy.array(vis.frequency)

        number_bad = 0
        number_good = 0

        for icomp, comp in enumerate(sc):
            pp = find_pierce_points(station_locations, (comp.direction.ra.rad + t2r * ha) * u.rad, comp.direction.dec,
                                    height=height, phasecentre=vis.phasecentre)
            scr = numpy.zeros([nant])
            for ant in range(nant):
                pp0 = pp[ant][0:2]
                worldloc = [pp0[0], pp0[1], ha, 1e8]
                try:
                    pixloc = screen.wcs.wcs_world2pix([worldloc], 0)[0].astype('int')
                    scr[ant] = scale * screen.data[pixloc[3], pixloc[2], pixloc[1], pixloc[0]]
                    number_good += 1
                except:
                    number_bad += 1
                    scr[ant] = 0.0
            
            scr = scr[:, numpy.newaxis] * tec2phase[numpy.newaxis, :]
            # axes of gaintable.gain are time, ant, nchan, nrec
            gaintables[icomp].gain[iha, :, :, :] = numpy.exp(1j * scr[..., numpy.newaxis, numpy.newaxis])
            gaintables[icomp].phasecentre = comp.direction
        
        if number_bad > 0:
            log.warning("create_gaintable_from_screen: %d pierce points are inside the screen image" % (number_good))
            log.warning("create_gaintable_from_screen: %d pierce points are outside the screen image" % (number_bad))

    return gaintables
 Create gaintables from a screen calculated using ARatmospy

    :param vis:
    :param sc: Sky components for which pierce points are needed
    :param screen:
    :param height: Height (in m) of screen above telescope e.g. 3e5
    :param scale: Multiply the screen by this factor
    :return:
    
Create gaintables from a screen calculated using ARatmospy
Create gaintables from a screen calculated using ARatmospy
def create_gaintable_from_screen(vis, sc, screen, height=3e5, vis_slices=None, scale=1.0, **kwargs):
    assert isinstance(vis, BlockVisibility)
    station_locations = vis.configuration.xyz
    nant = station_locations.shape[0]
    t2r = numpy.pi / 43200.0
    gaintables = [create_gaintable_from_blockvisibility(vis, **kwargs) for i in sc]
    for iha, rows in enumerate(vis_timeslice_iter(vis, vis_slices=vis_slices)):
        v = create_visibility_from_rows(vis, rows)
        ha = numpy.average(v.time)
        tec2phase = - 8.44797245e9 / numpy.array(vis.frequency)
        number_bad = 0
        number_good = 0
        for icomp, comp in enumerate(sc):
            pp = find_pierce_points(station_locations, (comp.direction.ra.rad + t2r * ha) * u.rad, comp.direction.dec,
                                    height=height, phasecentre=vis.phasecentre)
            scr = numpy.zeros([nant])
            for ant in range(nant):
                pp0 = pp[ant][0:2]
                worldloc = [pp0[0], pp0[1], ha, 1e8]
                try:
                    pixloc = screen.wcs.wcs_world2pix([worldloc], 0)[0].astype('int')
                    scr[ant] = scale * screen.data[pixloc[3], pixloc[2], pixloc[1], pixloc[0]]
                    number_good += 1
                except:
                    number_bad += 1
                    scr[ant] = 0.0
            scr = scr[:, numpy.newaxis] * tec2phase[numpy.newaxis, :]
            gaintables[icomp].gain[iha, :, :, :] = numpy.exp(1j * scr[..., numpy.newaxis, numpy.newaxis])
            gaintables[icomp].phasecentre = comp.direction
        if number_bad > 0:
            log.warning("create_gaintable_from_screen: %d pierce points are inside the screen image" % (number_good))
            log.warning("create_gaintable_from_screen: %d pierce points are outside the screen image" % (number_bad))
    return gaintables
def create_gaintable_from_screen ( vis , sc , screen , height = 3e5 , vis_slices = None , scale = 1.0 , ** kwargs ) : assert isinstance ( vis , BlockVisibility ) station_locations = vis . configuration . xyz nant = station_locations . shape [ 0 ] t2r = numpy . pi / 43200.0 gaintables = [ create_gaintable_from_blockvisibility ( vis , ** kwargs ) for i in sc ] for iha , rows in enumerate ( vis_timeslice_iter ( vis , vis_slices = vis_slices ) ) : v = create_visibility_from_rows ( vis , rows ) ha = numpy . average ( v . time ) tec2phase = - 8.44797245e9 / numpy . array ( vis . frequency ) number_bad = 0 number_good = 0 for icomp , comp in enumerate ( sc ) : pp = find_pierce_points ( station_locations , ( comp . direction . ra . rad + t2r * ha ) * u . rad , comp . direction . dec , height = height , phasecentre = vis . phasecentre ) scr = numpy . zeros ( [ nant ] ) for ant in range ( nant ) : pp0 = pp [ ant ] [ 0 : 2 ] worldloc = [ pp0 [ 0 ] , pp0 [ 1 ] , ha , 1e8 ] try : pixloc = screen . wcs . wcs_world2pix ( [ worldloc ] , 0 ) [ 0 ] . astype ( 'int' ) scr [ ant ] = scale * screen . data [ pixloc [ 3 ] , pixloc [ 2 ] , pixloc [ 1 ] , pixloc [ 0 ] ] number_good += 1 except : number_bad += 1 scr [ ant ] = 0.0 scr = scr [ : , numpy . newaxis ] * tec2phase [ numpy . newaxis , : ] gaintables [ icomp ] . gain [ iha , : , : , : ] = numpy . exp ( 1j * scr [ ... , numpy . newaxis , numpy . newaxis ] ) gaintables [ icomp ] . phasecentre = comp . direction if number_bad > 0 : log . warning ( "create_gaintable_from_screen: %d pierce points are inside the screen image" % ( number_good ) ) log . warning ( "create_gaintable_from_screen: %d pierce points are outside the screen image" % ( number_bad ) ) return gaintables
Create gaintables from a screen calculated using ARatmospy
Create gaintables from a screen calculated using ARatmospy
""" Create gaintables from a screen calculated using ARatmospy

    :param vis:
    :param sc: Sky components for which pierce points are needed
    :param screen:
    :param height: Height (in m) of screen above telescope e.g. 3e5
    :param scale: Multiply the screen by this factor
    :return:
    """ # Convert to TEC # phase = image[pixel] * -8.44797245e9 / frequency # The time in the Visibility is hour angle in seconds! # axes of gaintable.gain are time, ant, nchan, nrec
None
vis
None
sc
Sky components for which pierce points are needed
Sky components for which pierce points are needed
screen
None
height
Height (in m) of screen above telescope e.g. 3e5
Height ( in m ) of screen above telescope e . g . 3e5
vis_slices
scale
Multiply the screen by this factor
Multiply the screen by this factor