gelsa.gelsa#
Classes
|
Main class for handling Gelsa simulation setup and frame loading. |
- class gelsa.gelsa.Gelsa(config_file=None, config={}, **kwargs)[source]#
Bases:
objectMain class for handling Gelsa simulation setup and frame loading.
This class manages configuration settings, loads calibration models (detector, optical, dispersion, sensitivity, relative flux, PSF), and provides methods to create or load spectral (SpecFrame) and photometric (PhotFrame) frames based on the loaded configuration and calibration data.
- update_config(config)[source]#
Update the current configuration with new settings.
Only keys already present in the default configuration are updated. A warning is printed for unknown keys.
- Parameters:
config (dict) – Dictionary containing configuration settings to update.
- load_config(config_path=None, config=None, **kwargs)[source]#
Load configuration settings from multiple sources.
Configuration is loaded in the following order, with later sources overwriting earlier ones: 1. Default configuration (_default_config). 2. Configuration from a JSON file (config_path). 3. Configuration from a dictionary (config). 4. Configuration from keyword arguments (**kwargs).
- write_config(path)[source]#
Write the current configuration to a JSON file.
- Parameters:
path (str) – The path to the output JSON file.
- property detector_model#
Load and return the DetectorModel instance.
Loads the detector model based on the ‘detector_slots_path’ specified in the configuration. The model is cached after the first load.
- Returns:
The loaded detector model instance.
- Return type:
detector_model.DetectorModel
- property optical_model#
Load and return the OpticalModel instance.
Loads the optical model based on the ‘opt_file’ specified in the configuration. The model is cached after the first load.
- Returns:
The loaded optical model instance.
- Return type:
optical_model.OpticalModel
- property dispersion_model#
Load and return the dispersion models (IDS and CRV).
Loads the Inverse Dispersion Solution (IDS) and Curvature (CRV) models based on the ‘ids_file’ and ‘crv_file’ specified in the configuration. The models are cached after the first load.
- Returns:
- A dictionary containing the loaded ‘ids’ and ‘crv’
DisplacementModel instances.
- Return type:
- property sensitivity_model#
Load and return the SensitivityModel instance.
Loads the sensitivity (absolute calibration) model based on the ‘abs_file’ specified in the configuration. The model is cached after the first load.
- Returns:
The loaded sensitivity model instance.
- Return type:
sensitivity_model.SensitivityModel
- property relative_flux_model#
Load and return the RelativeFluxCalibration instance, if enabled.
Loads the relative flux loss model based on the ‘rel_flux_file’ specified in the configuration, only if ‘use_relative_flux_loss’ is True. Otherwise, returns None. The model is cached after the first load.
- Returns:
The loaded relative flux model instance or None if disabled.
- Return type:
relative_flux.RelativeFluxCalibration or None
- property psf_model#
Load and return the appropriate PSF model instance.
Loads either the default PSF model, the chromatic PSF model, or None, based on the ‘use_psf’ and ‘use_chromatic_psf’ settings in the configuration. The model is cached after the first load.
- Returns:
The loaded PSF model instance.
- Return type:
psf_model.PSFModel, psf_model.DefaultPSFModel, or None
- property zero_order_mask#
Load and return the ZeroOrderMask instance, if enabled.
Loads the zero-order mask based on the ‘zero_order_catalog’ specified in the configuration. If ‘zero_order_catalog’ is not set, returns None. The mask object is cached after the first load.
- Returns:
The loaded zero-order mask instance or None if disabled.
- Return type:
zero_order_mask.ZeroOrderMask or None
- load_spec_frame(frame_path, loctable_path=None, persistence_path=None, **frame_args)[source]#
Load an existing spectral frame (SpecFrame) from a file.
Initializes a SpecFrame, loads data from the specified frame path (adjusting for workdir), optionally loads a location table, and sets up all relevant calibration models (optical, detector, dispersion, etc.).
- Parameters:
- Returns:
The loaded and configured spectral frame instance.
- Return type:
- new_spec_frame(ra, dec, pa, **params)[source]#
Create a new, empty spectral frame (SpecFrame) at a given pointing.
Initializes a SpecFrame with the specified pointing (RA, Dec, PA) and any additional parameters. Sets up all relevant calibration models (optical, detector, dispersion, etc.). This frame does not contain pixel data initially.
- Parameters:
- Returns:
The newly created and configured spectral frame instance.
- Return type:
- load_frame(frame_path, loctable_path=None, persistence_path=None, **frame_args)#
Load an existing spectral frame (SpecFrame) from a file.
Initializes a SpecFrame, loads data from the specified frame path (adjusting for workdir), optionally loads a location table, and sets up all relevant calibration models (optical, detector, dispersion, etc.).
- Parameters:
- Returns:
The loaded and configured spectral frame instance.
- Return type:
- new_frame(ra, dec, pa, **params)#
Create a new, empty spectral frame (SpecFrame) at a given pointing.
Initializes a SpecFrame with the specified pointing (RA, Dec, PA) and any additional parameters. Sets up all relevant calibration models (optical, detector, dispersion, etc.). This frame does not contain pixel data initially.
- Parameters:
- Returns:
The newly created and configured spectral frame instance.
- Return type:
- load_phot_frame(frame_path, **params)[source]#
Load an existing photometric frame (PhotFrame) from a file.
Initializes a PhotFrame, loads data from the specified frame path (adjusting for workdir), and sets up the WCS.
- Parameters:
frame_path (str) – Path to the photometric frame file (relative to workdir).
**params – Additional parameters to pass to the PhotFrame constructor.
- Returns:
The loaded photometric frame instance.
- Return type:
- new_phot_frame(ra=None, dec=None, pa=None, **params)[source]#
Create a new photometric frame (PhotFrame) definition.
Initializes a PhotFrame with the specified pointing (RA, Dec, PA) and any additional parameters. Loads the WCS information from the JSON file specified in the configuration (‘nir_wcs’).
- Parameters:
ra (float, optional) – Right Ascension of the frame center (degrees). Defaults to None.
dec (float, optional) – Declination of the frame center (degrees). Defaults to None.
pa (float, optional) – Position Angle of the frame (degrees). Defaults to None.
**params – Additional parameters to pass to the PhotFrame constructor.
- Returns:
The newly created photometric frame instance.
- Return type: