Previous topic

pycrtools.lora

Next topic

pycrtools.ppf

This Page

pycrtools.metadata

antennaset2rcumode(antennaset, filter)
convertITRFToLocal(itrfpos[, phase_center, ...])
get(keyword, antennaIDs, antennaset[, ...]) Return metadata values, given the antennaIDs and the antennaset.
getCableAttenuation(station, antennaset[, ...])
getCableDelays(station, antennaset[, ...]) Get cable delays in seconds.
getCableLength(station, antennaset[, ...])
getClockCorrection(station[, antennaset, time]) Get clock correction for superterp stations in seconds.
getClockCorrectionParset(parsetfilename, station)
getItrfAntennaPosition(station, antennaset) Returns the antenna positions of all the antennas in the station in ITRF coordinates for the specified antennaset.
getLofarCenterRelativeAntennaPosition(...[, ...]) Returns antenna positions relative to the LOFAR center (e.g.
getRelativeAntennaPosition(station, antennaset) Returns the antenna positions of all the antennas in the station relative to the center of the station for the specified antennaset.
getRotationMatrix(station, antennaset) Returns the rotation matrix of a given station.
getStationCenterRelativeAntennaPosition(...) Returns antenna positions relative to the station center for selected antennas, or all antennas if no selection was applied.
getStationGainCalibration(station, antennaset) Read phase calibration data for a station.
getStationPhaseCalibration(station, antennaset) Read phase calibration data for a station.
getStationPositions(station, antennaset[, ...]) Returns the antenna positions of all the antennas in the station relative to the station center for the specified antennaset.
idToStationName(station_id) Returns the station name from a station_id
mapAntennasetKeyword(antennaset) Ugly fix to map correct antenna names in input to wrong antenna names for metadata module.
stationNameToID(station_name) Returns the station id from a station name
stationNameToNR(station_name) Returns the station id from a station name

This module reads in calibration metadata from file in the early fases of LOFAR. In the future this should be replaced by reading the metadata from the files.

Module author: Sander ter Veen <s.terveen@astro.ru.nl>

pycrtools.metadata.convertITRFToLocal(itrfpos, phase_center=hArray(float, [3, ]fill=[3.82658e+06, 461023, 5.06489e+06]) # len=3 slice=[0:3]), reflonlat=hArray(float, [2, ]fill=[0.119901, 0.923543]) # len=2 slice=[0:2]))
pycrtools.metadata.get(keyword, antennaIDs, antennaset, return_as_hArray=False)

Return metadata values, given the antennaIDs and the antennaset.

Required arguments:

Parameter Description
keyword Any of StationPhaseCalibration, CableDelays, RelativeAntennaPosition, ClockCorrection, StationPositions
antennaIDs AntennaIDs as given by crfile[“antennaIDs”]
antennaset

Antennaset used for this station. Options:

  • LBA_INNER
  • LBA_OUTER
  • LBA_X
  • LBA_Y
  • LBA_SPARSE0
  • LBA_SPARSE1
  • HBA_0
  • HBA_1
  • HBA

Optional arguments:

Parameter Description
return_as_hArray Default False
pycrtools.metadata.getCableDelays(station, antennaset, return_as_hArray=False)

Get cable delays in seconds.

Required arguments:

Parameter Description
station Station name or ID e.g. “CS302”, 142
antennaset

Antennaset used for this station. Options:

  • LBA_INNER
  • LBA_OUTER
  • LBA_X
  • LBA_Y
  • LBA_SPARSE0
  • LBA_SPARSE1
  • HBA_0
  • HBA_1
  • HBA

Optional arguments:

Parameter Description
return_as_hArray Returns numpy array if False (default)

returns “array of (rcus * cable delays ) for all dipoles in a station”

pycrtools.metadata.getClockCorrection(station, antennaset='LBA', time=1278480000)

Get clock correction for superterp stations in seconds. Currently static values.

station Station name or number for which to get the correction. time Optional. Linux time of observation. As clocks drift the value from the correct time should be given. Not yet implemented.

pycrtools.metadata.getItrfAntennaPosition(station, antennaset, return_as_hArray=False)

Returns the antenna positions of all the antennas in the station in ITRF coordinates for the specified antennaset. station can be the name or id of the station. Default returns as numpy array, option to return as hArray.

Required arguments:

Parameter Description
station Name or id of the station. e.g. “CS302” or 142
antennaset

Antennaset used for this station. Options:

  • LBA_INNER
  • LBA_OUTER
  • LBA_X
  • LBA_Y
  • LBA_SPARSE0
  • LBA_SPARSE1
  • HBA_0
  • HBA_1
  • HBA

Optional arguments:

Parameter Description
return_as_hArray Return as hArray.
pycrtools.metadata.getLofarCenterRelativeAntennaPosition(station, antennaset, return_as_hArray=False)

Returns antenna positions relative to the LOFAR center (e.g. antenna 0 of station CS002) for selected antennas, or all antennas if no selection was applied.

Output: a two dimensional array containing the Cartesian position of each antenna in meters in local coordinates from the station center center. So that if a is the returned array a[i] is an array of length 3 with positions (x,y,z) of antenna i.

pycrtools.metadata.getRelativeAntennaPosition(station, antennaset, return_as_hArray=False, LOFAR_centered=True, phase_center=None)

Returns the antenna positions of all the antennas in the station relative to the center of the station for the specified antennaset. station can be the name or id of the station. It is returned as hArray by default, option to return as numpy array.

Required arguments:

Parameter Description
station Name or id of the station. e.g. “CS302” or 142
antennaset Antennaset used for this station.

Optional arguments:

Parameter Default Description
LOFAR_centered True Get the relative positions to the center of LOFAR, or to the station if False.
return_as_hArray False Return as hArray.
phase_center None Reference position in ITRF.
pycrtools.metadata.getRotationMatrix(station, antennaset)

Returns the rotation matrix of a given station.

NOTE: We may not need to implement this, since the rotation matrix is the same for all dutch stations. Altough it will be useful for the use of international stations.

pycrtools.metadata.getStationCenterRelativeAntennaPosition(station, antennaset, return_as_hArray=False)

Returns antenna positions relative to the station center for selected antennas, or all antennas if no selection was applied.

Output: a two dimensional array containing the Cartesian position of each antenna in meters in local coordinates from the station center center. So that if a is the returned array a[i] is an array of length 3 with positions (x,y,z) of antenna i.

pycrtools.metadata.getStationGainCalibration(station, antennaset, return_as_hArray=False, caltable_location=None)

Read phase calibration data for a station.

Required arguments:

Parameter Description
station station name or ID.
mode observation mode.

Optional arguments:

Parameter Description
return_as_hArray Default False

returns one gain per RCU. This gain is calculated using the absolute value from the CalTables assuming these are not frequency dependent. This seems to be true in current (2013-08) tables.

pycrtools.metadata.getStationPhaseCalibration(station, antennaset, return_as_hArray=False, caltable_location=None)

Read phase calibration data for a station.

Required arguments:

Parameter Description
station station name or ID.
mode observation mode.

Optional arguments:

Parameter Description
return_as_hArray Default False

returns weights for 512 subbands.

Examples:

>>> metadata.getStationPhaseCalibration("CS002","LBA_OUTER")
array([[ 1.14260161 -6.07397622e-18j,  1.14260161 -6.05283530e-18j,
     1.14260161 -6.03169438e-18j, ...,  1.14260161 +4.68675289e-18j,
     1.14260161 +4.70789381e-18j,  1.14260161 +4.72903474e-18j],
   [ 0.95669876 +2.41800591e-18j,  0.95669876 +2.41278190e-18j,
     0.95669876 +2.40755789e-18j, ...,  0.95669876 -2.41017232e-19j,
     0.95669876 -2.46241246e-19j,  0.95669876 -2.51465260e-19j],
   [ 0.98463207 +6.80081617e-03j,  0.98463138 +6.89975906e-03j,
     0.98463069 +6.99870187e-03j, ...,  0.98299670 +5.71319125e-02j,
     0.98299096 +5.72306908e-02j,  0.98298520 +5.73294686e-02j],
   ...,
   [ 1.03201290 +7.39535744e-02j,  1.03144532 +8.14880844e-02j,
     1.03082273 +8.90182487e-02j, ..., -0.82551740 -6.23731331e-01j,
    -0.82094046 -6.29743206e-01j, -0.81631975 -6.35721497e-01j],
   [ 1.12370332 -1.15296909e-01j,  1.12428451 -1.09484545e-01j,
     1.12483564 -1.03669252e-01j, ..., -0.92476286 +6.48703460e-01j,
    -0.92810503 +6.43912711e-01j, -0.93142239 +6.39104744e-01j],
   [ 1.10043006 -6.18995646e-02j,  1.10075250 -5.58731668e-02j,
     1.10104193 -4.98450938e-02j, ..., -1.01051042 +4.40052904e-01j,
    -1.01290481 +4.34513198e-01j, -1.01526883 +4.28960464e-01j]])

>>> metadata.getStationPhaseCalibration(122,"LBA_OUTER")
Calibration data not yet available. Returning 1
array([[ 1.+0.j,  1.+0.j,  1.+0.j, ...,  1.+0.j,  1.+0.j,  1.+0.j],
   [ 1.+0.j,  1.+0.j,  1.+0.j, ...,  1.+0.j,  1.+0.j,  1.+0.j],
   [ 1.+0.j,  1.+0.j,  1.+0.j, ...,  1.+0.j,  1.+0.j,  1.+0.j],
   ...,
   [ 1.+0.j,  1.+0.j,  1.+0.j, ...,  1.+0.j,  1.+0.j,  1.+0.j],
   [ 1.+0.j,  1.+0.j,  1.+0.j, ...,  1.+0.j,  1.+0.j,  1.+0.j],
   [ 1.+0.j,  1.+0.j,  1.+0.j, ...,  1.+0.j,  1.+0.j,  1.+0.j]])
pycrtools.metadata.getStationPositions(station, antennaset, return_as_hArray=False, coordinatesystem='WGS84')

Returns the antenna positions of all the antennas in the station relative to the station center for the specified antennaset. station can be the name or id of the station. Default returns as numpy array, option to return as hArray.

Required arguments:

Argument Description
station Name or id of the station. e.g. “CS302” or 142
antennaset

Antennaset used for this station. Options:

  • LBA_INNER
  • LBA_OUTER
  • LBA_X
  • LBA_Y
  • LBA_SPARSE0
  • LBA_SPARSE1
  • HBA_0
  • HBA_1
  • HBA
coordinatesystem Currently WGS84 and ITRF.

Optional arguments

Argument Description
return_as_hArray Return as hArray.

Examples:

>>> import pycr_metadata as md
>>>
>>> ant_pos=get_antenna_positions(142,"LBA_INNER",True)
>>> ant_pos
hArray(float,[96, 3]) # len=288, slice=[0:288], vec -> [-0.0,0.0,-0.0,-0.0,0.0,-0.0,-0.0004,2.55,...]

>>> ant_pos=get_antenna_positions("CS005","HBA",False)
>>> ant_pos
array([[  1.07150000e+01,   7.58900000e+00,   1.00000000e-03],
       [  1.07150000e+01,   7.58900000e+00,   1.00000000e-03],
        [  1.28090000e+01,   2.88400000e+00,   1.00000000e-03],....

>>> antenna_ids=file["antennaIDs"]
[1420000005,142000008,142000080]
>>> station_id=antenna_ids[0]/1000000
142
>>> rcu_ids=np.mod(antenna_ids,1000)
array([5, 8, 80])
>>> all_antenna_pos=get_antenna_positions(station_id,"LBA_INNER",False)
>>> used_antenna_pos=all_antenna_pos[rcu_ids]
array([[  2.25000000e+00,   1.35000000e+00,  -1.00000000e-03],
       [  4.00000000e-04,  -2.55000000e+00,   1.00000000e-03],
       [  8.53000000e-01,   1.37240000e+01,  -3.00000000e-03]])
pycrtools.metadata.idToStationName(station_id)

Returns the station name from a station_id The station_id is crfile[“antennaIDs”]/1000000 The station name is more commonly used to identify the station for example for the files with metadata

pycrtools.metadata.mapAntennasetKeyword(antennaset)

Ugly fix to map correct antenna names in input to wrong antenna names for metadata module.

pycrtools.metadata.stationNameToID(station_name)

Returns the station id from a station name

pycrtools.metadata.stationNameToNR(station_name)

Returns the station id from a station name