Pattern I/O Module
The pattern_io module provides utilities for reading and writing antenna radiation pattern data in various formats.
- spacelink.core.pattern_io.load_radiation_pattern_npz(source)[source]
Load a radiation pattern from a NumPy NPZ file or file-like object.
- Parameters:
source (pathlib.Path or file-like object) – Path to the NPZ file containing the radiation pattern data, or a file-like object (such as BytesIO) containing NPZ data. This allows loading from files, databases, or in-memory buffers.
- Returns:
A new RadiationPattern object reconstructed from the saved data.
- Return type:
RadiationPattern
- Raises:
FileNotFoundError – If the specified file does not exist (when
sourceis a path).KeyError – If required keys are missing from the NPZ file.
ValueError – If the file’s
format_nameorformat_versionare unsupported.
- spacelink.core.pattern_io.save_radiation_pattern_npz(pattern, destination)[source]
Save the radiation pattern data to a NumPy NPZ file or file-like object.
- Parameters:
pattern (RadiationPattern) – The radiation pattern to save.
destination (pathlib.Path or file-like object) – Path to the output NPZ file, or a file-like object (such as BytesIO) to write NPZ data to. This allows saving to files, databases, or in-memory buffers.
- Return type:
None
- spacelink.core.pattern_io.import_hfss_csv(hfss_csv_path, *, rad_efficiency)[source]
Create a radiation pattern from an HFSS exported CSV file.
This expects the CSV file to contain the following columns in any order: - Freq [GHz] - Theta [deg] - Phi [deg] - dB(RealizedGainLHCP) [] - dB(RealizedGainRHCP) [] - ang_deg(rELHCP) [deg] - ang_deg(rERHCP) [deg]
Any other columns will be ignored. There must be exactly one header row with the column names.
The Theta and Phi values must form a regular grid.
- Parameters:
hfss_csv_path (pathlib.Path) – Path to the HFSS CSV file.
rad_efficiency (Dimensionless) – Radiation efficiency \(\eta\) in (0, 1].
- Returns:
Radiation pattern constructed from the CSV. If the CSV contains only a single frequency the pattern will be created without a frequency axis (it will be frequency-invariant).
- Return type:
RadiationPattern
- Raises:
FileNotFoundError – If the CSV file does not exist.
KeyError – If required columns are missing from the CSV.
ValueError – If duplicate (Freq, Theta, Phi) grid rows are present or if the CSV does not form a complete regular grid (NaNs detected after pivoting and reindexing).