Skip to content
Snippets Groups Projects
Commit 607b7084 authored by Hannes Feldt's avatar Hannes Feldt
Browse files

simplify statistics files

parent b01100b0
No related branches found
No related tags found
1 merge request!93L2SS-1582: Fix handling of closing streams on HDF5 files
Pipeline #83990 failed
...@@ -8,170 +8,13 @@ ...@@ -8,170 +8,13 @@
Models the structure of an HDF statistics file. Models the structure of an HDF statistics file.
""" """
import inspect import inspect
from typing import Dict, List from typing import Dict
from numpy import ndarray from numpy import ndarray
from lofar_station_client.file_access import attribute from lofar_station_client.file_access import attribute
class StatisticsData(ndarray):
"""
Representation of a periodic data matrix written to the HDF statistics file.
"""
version_id: int = attribute()
""" Version of the packet format. """
timestamp: str = attribute()
""" timestamp of the data """
station_info_raw: int = attribute(name="station_info__raw", optional=True)
""" Bit field with station information, encoding several other properties. """
station_info_station_id: int = attribute()
""" Station identifier """
station_info_antenna_field_index: int = attribute()
""" Antenna field number """
source_info_t_adc: int = attribute()
"""" Sampling clock. 0 = 160 MHz, 1 = 200 MHz. """
source_info_subband_calibrated_flag: bool = attribute()
""" subband_calibrated_flag 1 = subband data had subband calibration values applied,
0 = not.
"""
source_info_payload_error: bool = attribute()
""" 0 = data is ok, 1 = data is corrupted (a fault was encountered). """
source_info_nyquist_zone_index: int = attribute()
""" nyquist zone of filter
- 0 = 0 -- 1/2 * t_adc Hz (low band),
- 1 = 1/2 * t_adc -- t_adc Hz (high band),
- 2 = t_adc -- 3/2 * t_adc Hz (high band).
"""
source_info_gn_index: int = attribute()
""" Global index of FPGA that emitted this packet. """
source_info_fsub_type: int = attribute()
""" Sampling method. 0 = critically sampled, 1 = oversampled. """
source_info_beam_repositioning_flag: bool = attribute()
source_info_antenna_band_index: int = attribute()
""" Antenna type. 0 = low band, 1 = high band. """
source_info_raw: int = attribute(name="source_info__raw", optional=True)
""" Bit field with input information, encoding several other properties. """
observation_id: int = attribute()
""" Observation identifier """
nof_statistics_per_packet: int = attribute()
""" Number of statistic data points in the payload. """
nof_signal_inputs: int = attribute()
""" Number of inputs that contributed to data in this packet. """
nof_bytes_per_statistic: int = attribute()
""" Word size of each statistic """
marker: str = attribute()
""" The type of statistic:
- 'S' = SST
- 'B' = BST
- 'X' = XST
- 'b' = beamlet
"""
integration_interval: float = attribute()
""" Integration interval, in seconds. """
integration_interval_raw: int = attribute()
""" Integration interval, in block periods. """
data_id_raw: int = attribute(name="data_id__raw", optional=True)
""" Bit field with payload information, encoding several other properties. """
block_serial_number: int = attribute()
""" Timestamp of the data, in block periods since 1970. """
block_period_raw: int = attribute()
""" Block period, in nanoseconds. """
block_period: float = attribute()
""" Block period, in seconds. """
data_id_signal_input_index: int = attribute()
"""
SST input (antenna polarisation) index for which this packet contains statistics
"""
data_id_subband_index: int = attribute(optional=True)
"""
XST subband number for which this packet contains statistics.
"""
data_id_first_baseline: int = attribute(optional=True)
"""
XST first antenna pair for which this packet contains statistics.
"""
data_id_beamlet_index: int = attribute(optional=True)
"""
BST the number of the beamlet for which this packet holds statistics.
"""
nof_valid_payloads: ndarray = attribute()
""" Number of packets received so far that we could parse correctly and do not have
a payload error. One value per FPGA. """
nof_payload_errors: ndarray = attribute()
""" Number of packets that reported a payload error. One value per FPGA. """
gn_indices: ndarray = attribute()
""" Global node index (gn) as reported by each FPGA, for each element in the payload
counters. """
tile_beam_pointing_direction: List[str] = attribute(optional=True)
""" Direction of the tile beam """
tile_beam_tracking_enabled: List[bool] = attribute(optional=True)
""" Whether the tile beam is tracking """
digital_beam_pointing_direction: List[str] = attribute(optional=True)
""" Direction of the digital beam """
digital_beam_tracking_enabled: List[bool] = attribute(optional=True)
""" Whether the digital beam is tracking """
hbat_pwr_on: ndarray = attribute(optional=True)
""" Elements per hba tile """
rcu_attenuator_db: List[float] = attribute(name="rcu_attenuator_dB", optional=True)
""" Amount of dB with which each antenna signal must be adjusted to line up. """
rcu_dth_on: List[bool] = attribute(optional=True)
rcu_dth_freq: List[float] = attribute(optional=True)
clock: int = attribute(optional=True)
""" clock in hz """
frequency_band: ndarray = attribute(optional=True)
""" filter selection """
sdp_subband_frequency_range: ndarray = attribute(optional=True)
""" subband frequencies of subbands 0 and 511, as assumed by SDP """
subbands: List[int] = attribute(optional=True)
""" Subband number for each beamlet """
class StatisticsFileHeader: class StatisticsFileHeader:
""" """
Pythonic representation of the HDF statistics file header written by the statistics Pythonic representation of the HDF statistics file header written by the statistics
...@@ -228,7 +71,7 @@ class StatisticsFileHeader: ...@@ -228,7 +71,7 @@ class StatisticsFileHeader:
return True return True
class StatisticsDataFile(Dict[str, StatisticsData], StatisticsFileHeader): class StatisticsDataFile(Dict[str, ndarray], StatisticsFileHeader):
""" """
Pythonic representation of the HDF statistics file written by the statistics Pythonic representation of the HDF statistics file written by the statistics
writer. writer.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment