processing_components/visibility/base.py
def create_visibility(config: Configuration, times: numpy.array, frequency: numpy.array,
                      channel_bandwidth, phasecentre: SkyCoord,
                      weight: float, polarisation_frame=PolarisationFrame('stokesI'),
                      integration_time=1.0,
                      zerow=False, elevation_limit=15.0 * numpy.pi / 180.0, source='unknown', meta=None) -> Visibility:
    """ Create a Visibility from Configuration, hour angles, and direction of source

    Note that we keep track of the integration time for BDA purposes

    :param config: Configuration of antennas
    :param times: hour angles in radians
    :param frequency: frequencies (Hz] [nchan]
    :param weight: weight of a single sample
    :param phasecentre: phasecentre of observation
    :param channel_bandwidth: channel bandwidths: (Hz] [nchan]
    :param integration_time: Integration time ('auto' or value in s)
    :param polarisation_frame: PolarisationFrame('stokesI')
    :return: Visibility
    """
    assert phasecentre is not None, "Must specify phase centre"
    
    if polarisation_frame is None:
        polarisation_frame = correlate_polarisation(config.receptor_frame)
    
    latitude = config.location.geodetic[1].to('rad').value

    nch = len(frequency)
    ants_xyz = config.data['xyz']
    nants = len(config.data['names'])
    nbaselines = int(nants * (nants - 1) / 2)
    ntimes = 0
    for iha, ha in enumerate(times):
    
        # Calculate the positions of the antennas as seen for this hour angle
        # and declination
        _, elevation = hadec_to_azel(ha, phasecentre.dec.rad, latitude)
        if elevation_limit is None or (elevation > elevation_limit):
            ntimes +=1

    npol = polarisation_frame.npol
    nrows = nbaselines * ntimes * nch
    nrowsperintegration = nbaselines * nch
    rvis = numpy.zeros([nrows, npol], dtype='complex')
    rweight = weight * numpy.ones([nrows, npol])
    rtimes = numpy.zeros([nrows])
    rfrequency = numpy.zeros([nrows])
    rchannel_bandwidth = numpy.zeros([nrows])
    rantenna1 = numpy.zeros([nrows], dtype='int')
    rantenna2 = numpy.zeros([nrows], dtype='int')
    ruvw = numpy.zeros([nrows, 3])
    
    n_flagged = 0

    # Do each hour angle in turn
    row = 0
    for iha, ha in enumerate(times):
        
        # Calculate the positions of the antennas as seen for this hour angle
        # and declination
        _, elevation = hadec_to_azel(ha, phasecentre.dec.rad, latitude)
        if elevation_limit is None or (elevation > elevation_limit):
            rtimes[row:row + nrowsperintegration] = ha * 43200.0 / numpy.pi

            # TODO: optimise loop
            # Loop over all pairs of antennas. Note that a2>a1
            ant_pos = xyz_to_uvw(ants_xyz, ha, phasecentre.dec.rad)
            for a1 in range(nants):
                for a2 in range(a1 + 1, nants):
                    rantenna1[row:row + nch] = a1
                    rantenna2[row:row + nch] = a2
                    rweight[row:row+nch,...] = 1.0
                
                    # Loop over all frequencies and polarisations
                    for ch in range(nch):
                        # noinspection PyUnresolvedReferences
                        k = frequency[ch] / constants.c.value
                        ruvw[row, :] = (ant_pos[a2, :] - ant_pos[a1, :]) * k
                        rfrequency[row] = frequency[ch]
                        rchannel_bandwidth[row] = channel_bandwidth[ch]
                        row += 1
    
    if zerow:
        ruvw[..., 2] = 0.0
    assert row == nrows
    rintegration_time = numpy.full_like(rtimes, integration_time)
    vis = Visibility(uvw=ruvw, time=rtimes, antenna1=rantenna1, antenna2=rantenna2,
                     frequency=rfrequency, vis=rvis,
                     weight=rweight, imaging_weight=rweight,
                     integration_time=rintegration_time, channel_bandwidth=rchannel_bandwidth,
                     polarisation_frame=polarisation_frame, source=source, meta=meta)
    vis.phasecentre = phasecentre
    vis.configuration = config
    log.info("create_visibility: %s" % (vis_summary(vis)))
    assert isinstance(vis, Visibility), "vis is not a Visibility: %r" % vis
    if elevation_limit is not None:
        log.info('create_visibility: flagged %d/%d visibilities below elevation limit %f (rad)' %
                (n_flagged, vis.nvis, elevation_limit))
    else:
        log.info('create_visibility: created %d visibilities' % (vis.nvis))

    return vis
 Create a Visibility from Configuration, hour angles, and direction of source

    Note that we keep track of the integration time for BDA purposes

    :param config: Configuration of antennas
    :param times: hour angles in radians
    :param frequency: frequencies (Hz] [nchan]
    :param weight: weight of a single sample
    :param phasecentre: phasecentre of observation
    :param channel_bandwidth: channel bandwidths: (Hz] [nchan]
    :param integration_time: Integration time ('auto' or value in s)
    :param polarisation_frame: PolarisationFrame('stokesI')
    :return: Visibility
    
Create a Visibility from Configuration, hour angles, and direction of source
Note that we keep track of the integration time for BDA purposes
Create a Visibility from Configuration hour angles and direction of source Note that we keep track of the integration time for BDA purposes
def create_visibility(config: Configuration, times: numpy.array, frequency: numpy.array,
                      channel_bandwidth, phasecentre: SkyCoord,
                      weight: float, polarisation_frame=PolarisationFrame('stokesI'),
                      integration_time=1.0,
                      zerow=False, elevation_limit=15.0 * numpy.pi / 180.0, source='unknown', meta=None) -> Visibility:
    assert phasecentre is not None, "Must specify phase centre"
    if polarisation_frame is None:
        polarisation_frame = correlate_polarisation(config.receptor_frame)
    latitude = config.location.geodetic[1].to('rad').value
    nch = len(frequency)
    ants_xyz = config.data['xyz']
    nants = len(config.data['names'])
    nbaselines = int(nants * (nants - 1) / 2)
    ntimes = 0
    for iha, ha in enumerate(times):
        _, elevation = hadec_to_azel(ha, phasecentre.dec.rad, latitude)
        if elevation_limit is None or (elevation > elevation_limit):
            ntimes +=1
    npol = polarisation_frame.npol
    nrows = nbaselines * ntimes * nch
    nrowsperintegration = nbaselines * nch
    rvis = numpy.zeros([nrows, npol], dtype='complex')
    rweight = weight * numpy.ones([nrows, npol])
    rtimes = numpy.zeros([nrows])
    rfrequency = numpy.zeros([nrows])
    rchannel_bandwidth = numpy.zeros([nrows])
    rantenna1 = numpy.zeros([nrows], dtype='int')
    rantenna2 = numpy.zeros([nrows], dtype='int')
    ruvw = numpy.zeros([nrows, 3])
    n_flagged = 0
    row = 0
    for iha, ha in enumerate(times):
        _, elevation = hadec_to_azel(ha, phasecentre.dec.rad, latitude)
        if elevation_limit is None or (elevation > elevation_limit):
            rtimes[row:row + nrowsperintegration] = ha * 43200.0 / numpy.pi
            ant_pos = xyz_to_uvw(ants_xyz, ha, phasecentre.dec.rad)
            for a1 in range(nants):
                for a2 in range(a1 + 1, nants):
                    rantenna1[row:row + nch] = a1
                    rantenna2[row:row + nch] = a2
                    rweight[row:row+nch,...] = 1.0
                    for ch in range(nch):
                        k = frequency[ch] / constants.c.value
                        ruvw[row, :] = (ant_pos[a2, :] - ant_pos[a1, :]) * k
                        rfrequency[row] = frequency[ch]
                        rchannel_bandwidth[row] = channel_bandwidth[ch]
                        row += 1
    if zerow:
        ruvw[..., 2] = 0.0
    assert row == nrows
    rintegration_time = numpy.full_like(rtimes, integration_time)
    vis = Visibility(uvw=ruvw, time=rtimes, antenna1=rantenna1, antenna2=rantenna2,
                     frequency=rfrequency, vis=rvis,
                     weight=rweight, imaging_weight=rweight,
                     integration_time=rintegration_time, channel_bandwidth=rchannel_bandwidth,
                     polarisation_frame=polarisation_frame, source=source, meta=meta)
    vis.phasecentre = phasecentre
    vis.configuration = config
    log.info("create_visibility: %s" % (vis_summary(vis)))
    assert isinstance(vis, Visibility), "vis is not a Visibility: %r" % vis
    if elevation_limit is not None:
        log.info('create_visibility: flagged %d/%d visibilities below elevation limit %f (rad)' %
                (n_flagged, vis.nvis, elevation_limit))
    else:
        log.info('create_visibility: created %d visibilities' % (vis.nvis))
    return vis
def create_visibility ( config : Configuration , times : numpy . array , frequency : numpy . array , channel_bandwidth , phasecentre : SkyCoord , weight : float , polarisation_frame = PolarisationFrame ( 'stokesI' ) , integration_time = 1.0 , zerow = False , elevation_limit = 15.0 * numpy . pi / 180.0 , source = 'unknown' , meta = None ) -> Visibility : assert phasecentre is not None , "Must specify phase centre" if polarisation_frame is None : polarisation_frame = correlate_polarisation ( config . receptor_frame ) latitude = config . location . geodetic [ 1 ] . to ( 'rad' ) . value nch = len ( frequency ) ants_xyz = config . data [ 'xyz' ] nants = len ( config . data [ 'names' ] ) nbaselines = int ( nants * ( nants - 1 ) / 2 ) ntimes = 0 for iha , ha in enumerate ( times ) : _ , elevation = hadec_to_azel ( ha , phasecentre . dec . rad , latitude ) if elevation_limit is None or ( elevation > elevation_limit ) : ntimes += 1 npol = polarisation_frame . npol nrows = nbaselines * ntimes * nch nrowsperintegration = nbaselines * nch rvis = numpy . zeros ( [ nrows , npol ] , dtype = 'complex' ) rweight = weight * numpy . ones ( [ nrows , npol ] ) rtimes = numpy . zeros ( [ nrows ] ) rfrequency = numpy . zeros ( [ nrows ] ) rchannel_bandwidth = numpy . zeros ( [ nrows ] ) rantenna1 = numpy . zeros ( [ nrows ] , dtype = 'int' ) rantenna2 = numpy . zeros ( [ nrows ] , dtype = 'int' ) ruvw = numpy . zeros ( [ nrows , 3 ] ) n_flagged = 0 row = 0 for iha , ha in enumerate ( times ) : _ , elevation = hadec_to_azel ( ha , phasecentre . dec . rad , latitude ) if elevation_limit is None or ( elevation > elevation_limit ) : rtimes [ row : row + nrowsperintegration ] = ha * 43200.0 / numpy . pi ant_pos = xyz_to_uvw ( ants_xyz , ha , phasecentre . dec . rad ) for a1 in range ( nants ) : for a2 in range ( a1 + 1 , nants ) : rantenna1 [ row : row + nch ] = a1 rantenna2 [ row : row + nch ] = a2 rweight [ row : row + nch , ... ] = 1.0 for ch in range ( nch ) : k = frequency [ ch ] / constants . c . value ruvw [ row , : ] = ( ant_pos [ a2 , : ] - ant_pos [ a1 , : ] ) * k rfrequency [ row ] = frequency [ ch ] rchannel_bandwidth [ row ] = channel_bandwidth [ ch ] row += 1 if zerow : ruvw [ ... , 2 ] = 0.0 assert row == nrows rintegration_time = numpy . full_like ( rtimes , integration_time ) vis = Visibility ( uvw = ruvw , time = rtimes , antenna1 = rantenna1 , antenna2 = rantenna2 , frequency = rfrequency , vis = rvis , weight = rweight , imaging_weight = rweight , integration_time = rintegration_time , channel_bandwidth = rchannel_bandwidth , polarisation_frame = polarisation_frame , source = source , meta = meta ) vis . phasecentre = phasecentre vis . configuration = config log . info ( "create_visibility: %s" % ( vis_summary ( vis ) ) ) assert isinstance ( vis , Visibility ) , "vis is not a Visibility: %r" % vis if elevation_limit is not None : log . info ( 'create_visibility: flagged %d/%d visibilities below elevation limit %f (rad)' % ( n_flagged , vis . nvis , elevation_limit ) ) else : log . info ( 'create_visibility: created %d visibilities' % ( vis . nvis ) ) return vis
Create a Visibility from Configuration, hour angles, and direction of source
Note that we keep track of the integration time for BDA purposes
Create a Visibility from Configuration hour angles and direction of source Note that we keep track of the integration time for BDA purposes
""" Create a Visibility from Configuration, hour angles, and direction of source

    Note that we keep track of the integration time for BDA purposes

    :param config: Configuration of antennas
    :param times: hour angles in radians
    :param frequency: frequencies (Hz] [nchan]
    :param weight: weight of a single sample
    :param phasecentre: phasecentre of observation
    :param channel_bandwidth: channel bandwidths: (Hz] [nchan]
    :param integration_time: Integration time ('auto' or value in s)
    :param polarisation_frame: PolarisationFrame('stokesI')
    :return: Visibility
    """ # Calculate the positions of the antennas as seen for this hour angle # and declination # Do each hour angle in turn # Calculate the positions of the antennas as seen for this hour angle # and declination # TODO: optimise loop # Loop over all pairs of antennas. Note that a2>a1 # Loop over all frequencies and polarisations # noinspection PyUnresolvedReferences
None
config
Configuration
Configuration of antennas
Configuration of antennas
times
numpy.array
hour angles in radians
hour angles in radians
frequency
numpy.array
frequencies (Hz] [nchan]
frequencies ( Hz ] [ nchan ]
channel_bandwidth
channel bandwidths: (Hz] [nchan]
channel bandwidths : ( Hz ] [ nchan ]
phasecentre
SkyCoord
phasecentre of observation
phasecentre of observation
weight
float
weight of a single sample
weight of a single sample
polarisation_frame
None
integration_time
Integration time ('auto' or value in s)
Integration time ( ' auto ' or value in s )
zerow
elevation_limit
source
meta