FastUVH5Meta
- class pyuvdata.uvdata.FastUVH5Meta(path: str | Path | File | Group, *, blt_order: tuple[str] | Literal['determine'] | None = None, blts_are_rectangular: bool | None = None, time_axis_faster_than_bls: bool | None = None, recompute_nbls: bool | None = None, astrometry_library: str | None = None)[source]
A fast read-only interface to UVH5 file metadata that makes some assumptions.
This class is just a really thin wrapper over a UVH5 file that makes it easier to read in parts of the metadata at a time. This makes it much faster to perform small tasks where simple metadata is required, rather than reading in the whole header.
All metadata is available as attributes, through
__getattr__
magic. Thus, accessing eg.obj.freq_array
will go and get the frequencies directly from the file, and store them in memory. However, some attributes are made faster than the default, by assumptions on the data shape – in particular, times and baselines.Anything that is read in is stored in memory so the second access is much faster. However, the memory can be released simply by deleting the attribute (it can be accessed again, and the data will be re-read).
- Parameters:
filename (str or Path) – The filename to read from.
blt_order (tuple of str or “determine”, optional) – The order of the baseline-time axis. This can be determined, or read directly from file, however since it has been optional in the past, many existing files do not contain it in the metadata. Some reading operations are significantly faster if this is known, so providing it here can provide a speedup. Default is to try and read it from file, and if not there, just leave it as None. Set to “determine” to auto-detect the blt_order from the metadata (takes extra time to do so).
blts_are_rectangular (bool, optional) – Whether the baseline-time axis is rectangular. This can be read from metadata in new files, but many old files do not contain it. If not provided, the rectangularity will be determined from the data. This is a non-negligible operation, so if you know it, it can be provided here to speed up reading.
time_axis_faster_than_bls (bool, optional) – If blts are rectangular, this variable specifies whether the time axis is the fastest-moving virtual axis. Various reading functions benefit from knowing this, so if it is known, it can be provided here to speed up reading. It will be determined from the data if not provided.
recompute_nbls (bool, optional) – Whether to recompute the number of unique baselines from the data. Before v1.2 of the UVH5 spec, it was possible to have an incorrect number of baselines in the header without error, so this provides an opportunity to rectify it. Old HERA files (< March 2023) may have this issue, but in this case the correct number of baselines can be computed more quickly than by fully re=computing, and so we do this.
astrometry_library (str) – Library used for calculating the LSTs. Allowed options are ‘erfa’ (which uses the pyERFA), ‘novas’ (which uses the python-novas library), and ‘astropy’ (which uses the astropy utilities). Default is erfa unless the telescope location frame is MCMF (on the moon), in which case the default is astropy.
Notes
To check if a particular attribute is available, use
hasattr(obj, attr)
. Many attributes will not show up dynamically in an interpreter, because they are gotten dynamically from the file.- property Nbls: int
The number of unique baselines.
- property blt_order: tuple[str]
Tuple defining order of blts axis.
- property blts_are_rectangular: bool
Whether blts axis is rectangular.
That is, this is true if the blts can be reshaped to
(Ntimes, Nbls)
OR(Nbls, Ntimes)
. This requires each baseline to have the same number of times associated, AND the blt ordering to either be (time, baseline) or (baseline,time).
- property time_axis_faster_than_bls: bool
Whether times move first in the blt axis.
- property times: ndarray
The unique times in the file.
- property lsts: ndarray
The unique LSTs in the file.
- property lst_array: ndarray
The LSTs corresponding to each baseline-time.
- property channel_width: float
The width of each frequency channel in Hz.
- property unique_antpair_1_array: ndarray
The unique antenna 1 indices in the file.
- property unique_antpair_2_array: ndarray
The unique antenna 2 indices in the file.
- property unique_ants: set
The unique antennas in the file.
- property baseline_array: ndarray
The baselines in the file, as unique integers.
- property unique_baseline_array: ndarray
The unique baselines in the file, as unique integers.
- property antpairs: list[tuple[int, int]]
Get the unique antenna pairs in the file.
- has_key(key: tuple[int, int] | tuple[int, int, str]) bool [source]
Check if the file has a given antpair or antpair-pol key.
- property pols: list[str]
The polarizations in the file, as standardized strings, eg. ‘xx’ or ‘ee’.
- property vis_units: str
The visibility units in the file, as a string.
- to_uvdata(*, check_lsts: bool = False, astrometry_library: str | None = None) UVData [source]
Convert the file to a UVData object.
The object will be metadata-only.
- Parameters:
check_lsts (bool) – Option to check that the LSTs match the expected values for the telescope location and times.
astrometry_library (str) – Library used for calculating the LSTs. Allowed options are ‘erfa’ (which uses the pyERFA), ‘novas’ (which uses the python-novas library), and ‘astropy’ (which uses the astropy utilities). Default is erfa unless the telescope location frame is MCMF (on the moon), in which case the default is astropy.