processing_components/simulation/ionospheric_screen.py
def grid_gaintable_to_screen(vis, gaintables, screen, height=3e5, gaintable_slices=None, scale=1.0, **kwargs):
    """ Grid a gaintable to a screen image
    
    The phases are just average per grid cell, no phase unwrapping is performed.

    :param vis:
    :param gaintables: input gaintables
    :param screen:
    :param height: Height (in m) of screen above telescope e.g. 3e5
    :param scale: Multiply the screen by this factor
    :return: gridded screen image, weights image
    """
    assert isinstance(vis, BlockVisibility)
    
    station_locations = vis.configuration.xyz
    
    nant = station_locations.shape[0]
    t2r = numpy.pi / 43200.0
    
    newscreen = create_empty_image_like(screen)
    weights = create_empty_image_like(screen)
    nchan, ntimes, ny, nx = screen.shape

    # The time in the Visibility is hour angle in seconds!
    number_no_weight = 0
    for gaintable in gaintables:
        for iha, rows in enumerate(gaintable_timeslice_iter(gaintable, gaintable_slices=gaintable_slices)):
            gt = create_gaintable_from_rows(gaintable, rows)
            ha = numpy.average(gt.time)

            pp = find_pierce_points(station_locations,
                                    (gt.phasecentre.ra.rad + t2r * ha) * u.rad,
                                    gt.phasecentre.dec,
                                    height=height,
                                    phasecentre=vis.phasecentre)
            scr = numpy.angle(gt.gain[0, :, 0, 0, 0])
            wt = gt.weight[0, :, 0, 0, 0]
            for ant in range(nant):
                pp0 = pp[ant][0:2]
                for freq in vis.frequency:
                    phase2tec = - freq / 8.44797245e9
                    worldloc = [pp0[0], pp0[1], ha, freq]
                    pixloc = newscreen.wcs.wcs_world2pix([worldloc], 0)[0].astype('int')
                    assert pixloc[0] >= 0
                    assert pixloc[0] < nx
                    assert pixloc[1] >= 0
                    assert pixloc[1] < ny
                    pixloc[3] = 0
                    newscreen.data[pixloc[3], pixloc[2], pixloc[1], pixloc[0]] += wt[ant] * phase2tec * scr[ant]
                    weights.data[pixloc[3], pixloc[2], pixloc[1], pixloc[0]] += wt[ant]
                    if wt[ant] == 0.0:
                        number_no_weight += 1
    if number_no_weight > 0:
        log.warning("grid_gaintable_to_screen: %d pierce points are have no weight" % (number_no_weight))

    newscreen.data[weights.data > 0.0] = newscreen.data[weights.data > 0.0] / weights.data[weights.data > 0.0]

    return newscreen, weights
 Grid a gaintable to a screen image
    
    The phases are just average per grid cell, no phase unwrapping is performed.

    :param vis:
    :param gaintables: input gaintables
    :param screen:
    :param height: Height (in m) of screen above telescope e.g. 3e5
    :param scale: Multiply the screen by this factor
    :return: gridded screen image, weights image
    
Grid a gaintable to a screen image
The phases are just average per grid cell, no phase unwrapping is performed.
Grid a gaintable to a screen image The phases are just average per grid cell no phase unwrapping is performed .
def grid_gaintable_to_screen(vis, gaintables, screen, height=3e5, gaintable_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
    newscreen = create_empty_image_like(screen)
    weights = create_empty_image_like(screen)
    nchan, ntimes, ny, nx = screen.shape
    number_no_weight = 0
    for gaintable in gaintables:
        for iha, rows in enumerate(gaintable_timeslice_iter(gaintable, gaintable_slices=gaintable_slices)):
            gt = create_gaintable_from_rows(gaintable, rows)
            ha = numpy.average(gt.time)
            pp = find_pierce_points(station_locations,
                                    (gt.phasecentre.ra.rad + t2r * ha) * u.rad,
                                    gt.phasecentre.dec,
                                    height=height,
                                    phasecentre=vis.phasecentre)
            scr = numpy.angle(gt.gain[0, :, 0, 0, 0])
            wt = gt.weight[0, :, 0, 0, 0]
            for ant in range(nant):
                pp0 = pp[ant][0:2]
                for freq in vis.frequency:
                    phase2tec = - freq / 8.44797245e9
                    worldloc = [pp0[0], pp0[1], ha, freq]
                    pixloc = newscreen.wcs.wcs_world2pix([worldloc], 0)[0].astype('int')
                    assert pixloc[0] >= 0
                    assert pixloc[0] < nx
                    assert pixloc[1] >= 0
                    assert pixloc[1] < ny
                    pixloc[3] = 0
                    newscreen.data[pixloc[3], pixloc[2], pixloc[1], pixloc[0]] += wt[ant] * phase2tec * scr[ant]
                    weights.data[pixloc[3], pixloc[2], pixloc[1], pixloc[0]] += wt[ant]
                    if wt[ant] == 0.0:
                        number_no_weight += 1
    if number_no_weight > 0:
        log.warning("grid_gaintable_to_screen: %d pierce points are have no weight" % (number_no_weight))
    newscreen.data[weights.data > 0.0] = newscreen.data[weights.data > 0.0] / weights.data[weights.data > 0.0]
    return newscreen, weights
def grid_gaintable_to_screen ( vis , gaintables , screen , height = 3e5 , gaintable_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 newscreen = create_empty_image_like ( screen ) weights = create_empty_image_like ( screen ) nchan , ntimes , ny , nx = screen . shape number_no_weight = 0 for gaintable in gaintables : for iha , rows in enumerate ( gaintable_timeslice_iter ( gaintable , gaintable_slices = gaintable_slices ) ) : gt = create_gaintable_from_rows ( gaintable , rows ) ha = numpy . average ( gt . time ) pp = find_pierce_points ( station_locations , ( gt . phasecentre . ra . rad + t2r * ha ) * u . rad , gt . phasecentre . dec , height = height , phasecentre = vis . phasecentre ) scr = numpy . angle ( gt . gain [ 0 , : , 0 , 0 , 0 ] ) wt = gt . weight [ 0 , : , 0 , 0 , 0 ] for ant in range ( nant ) : pp0 = pp [ ant ] [ 0 : 2 ] for freq in vis . frequency : phase2tec = - freq / 8.44797245e9 worldloc = [ pp0 [ 0 ] , pp0 [ 1 ] , ha , freq ] pixloc = newscreen . wcs . wcs_world2pix ( [ worldloc ] , 0 ) [ 0 ] . astype ( 'int' ) assert pixloc [ 0 ] >= 0 assert pixloc [ 0 ] < nx assert pixloc [ 1 ] >= 0 assert pixloc [ 1 ] < ny pixloc [ 3 ] = 0 newscreen . data [ pixloc [ 3 ] , pixloc [ 2 ] , pixloc [ 1 ] , pixloc [ 0 ] ] += wt [ ant ] * phase2tec * scr [ ant ] weights . data [ pixloc [ 3 ] , pixloc [ 2 ] , pixloc [ 1 ] , pixloc [ 0 ] ] += wt [ ant ] if wt [ ant ] == 0.0 : number_no_weight += 1 if number_no_weight > 0 : log . warning ( "grid_gaintable_to_screen: %d pierce points are have no weight" % ( number_no_weight ) ) newscreen . data [ weights . data > 0.0 ] = newscreen . data [ weights . data > 0.0 ] / weights . data [ weights . data > 0.0 ] return newscreen , weights
Grid a gaintable to a screen image
The phases are just average per grid cell, no phase unwrapping is performed.
Grid a gaintable to a screen image The phases are just average per grid cell no phase unwrapping is performed .
""" Grid a gaintable to a screen image
    
    The phases are just average per grid cell, no phase unwrapping is performed.

    :param vis:
    :param gaintables: input gaintables
    :param screen:
    :param height: Height (in m) of screen above telescope e.g. 3e5
    :param scale: Multiply the screen by this factor
    :return: gridded screen image, weights image
    """ # The time in the Visibility is hour angle in seconds!
gridded screen image, weights image
gridded screen image weights image
vis
None
gaintables
None
screen
None
height
Height (in m) of screen above telescope e.g. 3e5
Height ( in m ) of screen above telescope e . g . 3e5
gaintable_slices
scale
Multiply the screen by this factor
Multiply the screen by this factor