DelFileGenerator#
- class pride.io.DelFileGenerator(del_file: str | pathlib.Path)#
Generate a DEL file with estimated delays
The SFXC correlator reads estimated delays from binary files with .del extension. This class provides an interface to create such files with the outputs of a delay estimation.
- Parameters:
file – Path to the DEL file to be created
max_size_id – Maximum allowed size of an ID (scan, source…)
station_id_size – Size of the station ID in bytes
header_size – Size of the header in bytes
- add_header(station_id: str, trailing_padding: int = 1) None#
Add header to DEL file
The header is a set of 4 + header_size bytes. The first 4 bytes are an integer with the size of the remaining part of the header (header_size). The remaining bytes are occupied by a two-character station ID, and padding.
After checking that the file is empty, the function initializes it by adding the header.
- Parameters:
station_id – Station ID
trailing_padding – Size of the padding after the station ID
- validate_scan_contents(scan_id: str, source: str, mjd_ref: int, data: numpy.ndarray) None#
Validate scan contents before writing to the DEL file
Performs the following checks: - scan_id and source are strings with a maximum of 80 characters - mjd_ref is an integer - data is a 2D numpy array with shape (N, 7)
The function terminates with an error if any of the checks fail.
- Parameters:
scan_id – Scan ID
source – Source name
mjd_ref – Modified Julian Date reference
data – Data array with shape (N, 7)
- pack_id(id: str) bytes#
Generate bytes object for ID
Generates a bytes object for an ID with a maximum size of 80 characters by filling the unused space with padding bytes. A padding byte is always added after the ID.
- Parameters:
id – ID to be packed
- Returns:
Packed bytes object
- pack_scan_contents(scan_id: str, source_name: str, mjd_reference: int, scan_data: numpy.ndarray) bytes#
Pack scan contents into an array of bytes
The function turns the scan contents into an array of bytes with the correct format and padding. An internal state flag is used to ensure that the scan data has been validated before calling this function.
- Parameters:
scan_id – Scan ID
source – Source name
mjd_ref – Modified Julian Date reference
data – Data array with shape (N, 7)
- Returns:
Packed bytes object
- add_scan(scan_id: str, source_name: str, mjd_reference: int, scan_data: numpy.ndarray) None#
Add scan data to pre-initialized DEL file
After checking that the file has a header, and that the scan data has the correct format, the function packs the information into byte objects and appends it to the DEL file. An internal state flag is used to ensure that the scan data is validated before packing.
- Parameters:
scan_id – Scan ID [Maximum size: 80 characters]
source_name – Source name [Maximum size: 80 characters]
mjd_reference – MJD reference
scan_data – Data to be added to the DEL file