ska_pst.testutils.file_generator
Submodule providing file generators.
- class ska_pst.testutils.file_generator.DadaFileGenerator(logger: Optional[Logger] = None)[source]
A class used to help generate test DADA files.
- actual_file_length_secs(nbit: int, nchan: int, npol: int, ndim: int, tsamp: float, resolution: int, file_length_sec: float, udp_nsamp: int = 1, **kwargs: Any) float[source]
Calculate the actual file length that would be generated from parameters, in seconds.
This method is used to help in test assertions to calculate the length of the sub-integration in seconds.
- Parameters
nbit (int) – the number of bits per sample
nchan (int) – the number of channels in the output of the file
npol (int) – the number of the polarisations in the output file
ndim (int) – the number of dimensions of used to represent sample values. For voltage recorder and flow through this should be 2 as both output complex valued data.
tsamp (float) – the time per sample, in microseconds.
resolution (int) – the resolution data in the output data.
file_length_sec (float) – the requested file length of a sub-integration, in seconds.
udp_nsamp (int, optional) – the number of samples per packet, defaults to 1. This is used in the RESOLUTION value and to be used to determine the total number of samples in a file and to then calculate the expected length of the file.
- Returns
the actual file length that would be generated from parameters, in seconds.
- Return type
float
- generate_file(*, config: dict, directory: Path, scan_id: int, pst_scan_config: dict, **kwargs: Any) Path[source]
Generate a file.
- Parameters
config (dict) – the configuration to use generate the metadata
directory (pathlib.Path) – the directory of where to write the file to.
scan_id (int) – the scan ID the file is for
pst_scan_config (dict) – the scan configuration that should be used to back the generation of the file.
- Returns
the path to the generated file.
- Return type
pathlib.Path
- class ska_pst.testutils.file_generator.FileGenerator(*args, **kwargs)[source]
A protocol to generate output files on the fly.
Implementations of this generator should clean up files when no longer used.
- generate_file(*, config: dict, directory: Path, scan_id: int, pst_scan_config: dict, **kwargs: Any) Path[source]
Generate a file.
- Parameters
config (dict) – the configuration to use generate the metadata
directory (pathlib.Path) – the directory of where to write the file to.
scan_id (int) – the scan ID the file is for
pst_scan_config (dict) – the scan configuration that should be used to back the generation of the file.
- Returns
the path to the generated file.
- Return type
pathlib.Path
- class ska_pst.testutils.file_generator.PsrFitsFileGenerator[source]
A PSRFITS file generator that can be used in unit testing.
The current implementation generates a search mode file (for PST that is the detected filterbank mode).
- generate_file(*, config: dict, directory: Path, scan_id: int, pst_scan_config: dict, **kwargs: Any) Path[source]
Generate a file.
- Parameters
config (dict) – the configuration to use generate the metadata
directory (pathlib.Path) – the directory of where to write the file to.
scan_id (int) – the scan ID the file is for
pst_scan_config (dict) – the scan configuration that should be used to back the generation of the file.
- Returns
the path to the generated file.
- Return type
pathlib.Path
- class ska_pst.testutils.file_generator.StatsFileGenerator(logger: Optional[Logger] = None)[source]
A class used to help generate test STAT HDF5 files.
This is a wrapper around the
ska_pst.stat.utility.Hdf5FileGeneratorclass to use theFileGeneratorprotocol.- generate_file(*, config: dict, directory: Path, scan_id: int, pst_scan_config: dict, **kwargs: Any) Path[source]
Generate a file.
- Parameters
config (dict) – the configuration to use generate the metadata
directory (pathlib.Path) – the directory of where to write the file to.
scan_id (int) – the scan ID the file is for
pst_scan_config (dict) – the scan configuration that should be used to back the generation of the file.
- Returns
the path to the generated file.
- Return type
pathlib.Path