ska_sdp_instrumental_calibration.data_managers.sky_model.sky_model_reader module
- class ska_sdp_instrumental_calibration.data_managers.sky_model.sky_model_reader.ComponentConverters[source]
Bases:
object- static create_lsm_df(local_sky_model)[source]
Create a pandas DataFrame from a LocalSkyModel instance.
- Parameters:
local_sky_model (LocalSkyModel) -- The local sky model object containing astronomical component data.
- Returns:
A DataFrame where columns correspond to the sky model's defined fields and rows represent individual components.
- Return type:
pandas.DataFrame
- classmethod df_to_components(df)[source]
Convert a pandas DataFrame into a list of Component objects.
- static sky_components_to_components(sky_components)[source]
Convert SkyComponent instances to external Component instances.
- Parameters:
sky_components (Iterable[SkyComponent]) -- An iterable of internal sky component dataclass instances.
- Returns:
An iterable of component objects compatible with the external local sky model library.
- Return type:
Iterable[Component]
- static components_to_sky_components(components)[source]
Convert external Component instances to SkyComponent instances.
- Parameters:
components (Iterable[Component]) -- An iterable of component objects from the external local sky model library.
- Returns:
An iterable of internal sky component dataclass instances with explicit unit-suffixed fields.
- Return type:
Iterable[SkyComponent]
- ska_sdp_instrumental_calibration.data_managers.sky_model.sky_model_reader.export_lsm_to_csv(components, csv_path)[source]
Export a list of Component instances to a CSV file.
- ska_sdp_instrumental_calibration.data_managers.sky_model.sky_model_reader.generate_lsm_from_csv(csvfile, phasecentre, fov=5.0, flux_limit=0.0)[source]
Generate a local sky model using a CSV file.
This function reads a CSV file and converts it into a list of
Componentobjects. If the CSV file cannot be found, the function raises a ValueError.The CSV file is expected to have a commented line header and the following 10 columns in order: component_id, ra, dec, i_pol, major_ax, minor_ax, pos_ang, ref_freq, spec_idx, log_spec_idx.
The spec_idx column should contain a JSON array of spectral indices (e.g., "[-0.7,0.01,0.123]"). The log_spec_idx column is a boolean indicating whether the spectral index was calculated using a logarithmic (true) or linear (false) model.
All components are treated as Gaussians, though many may default to point sources.
- Parameters:
csvfile (str) -- The path to the CSV file. Must follow the format described above.
phasecentre (SkyCoord) -- The phase centre of the observation, serving as the reference point for the sky model.
fov (float, optional) -- The field of view diameter in degrees. Components outside this radius (centered on phasecentre) are excluded. Default is 5.0.
flux_limit (float, optional) -- The minimum flux density in Jy. Components below this limit are excluded. Default is 0.0.
- Returns:
A list of component objects extracted from the CSV file.
- Return type:
- Raises:
ValueError -- If the csvfile does not exist or cannot be opened.
- ska_sdp_instrumental_calibration.data_managers.sky_model.sky_model_reader.generate_lsm_from_gleamegc(gleamfile, phasecentre, fov=5.0, flux_limit=0.0, alpha0=-0.78)[source]
Generate a local sky model using the GLEAM-EGC catalogue.
This function parses a GLEAM-EGC formatted file and converts it into a list of
Componentobjects. If the file cannot be found, a warning is logged and a single point source at the phase centre is returned.All components are treated as Gaussians. The function attempts to use 'Fintfit200' and 'alpha' columns for flux and spectral index. If these are unavailable (marked as '---'), it falls back to 'Fintwide' and
alpha0.- Parameters:
gleamfile (str) -- The path to the catalogue file. Must follow the GLEAM-EGC data format.
phasecentre (SkyCoord) -- The phase centre of the observation, serving as the reference point for the sky model.
fov (float, optional) -- The field of view diameter in degrees. Components outside this radius (centered on
phasecentre) are excluded. Default is 5.0.flux_limit (float, optional) -- The minimum flux density in Jy. Components below this limit are excluded. Default is 0.0.
alpha0 (float, optional) -- The nominal spectral index to use when fitted data are unspecified in the catalogue. Default is -0.78.
- Returns:
A list of component objects extracted from the catalogue.
- Return type: