lime_tbx.common.datatypes module
This module contains different dataclasses and classes used for the exchange of data between modules of the package lime-tbx.
- It exports the following classes:
MoonData - Moon data used in the calculations of the Moon’s irradiance.
SRFChannel - Spectral responses and metadata for a SRF Channel
SpectralResponseFunction - The spectral response function, a set of channels with their data.
SRF_fwhm - Dataclass containing the spectral response function, a set of channels with their data.
Point - Superclass for all point classes.
SurfacePoint - Point on Earth’s surface
CustomPoint - Point with custom Moon data.
SatellitePoint - Point of a Satellite in a concrete datetime
OrbitFile - Satellite orbit file.
Satellite - ESA Satellite
SatellitePosition - A satellite’s position
LunarObservation - GLOD lunar observation
PolarisationCoefficients - Coefficients used in the DoLP algorithm.
- ReflectanceCoefficients - Dataclass containing the cimel coefficients that will be used in the
reflectance simulation algorithm.
LimeCoefficients - Dataclass containing a PolarisationCoefficients and a ReflectanceCoefficients.
SpectralData - Data for a spectrum of wavelengths, with an associated uncertainty each.
ComparisonData - Dataclass containing the data outputed from a comparison.
KernelsPath - Dataclass containing the needed information in order to find all SPICE kernels.
EocfiPath - Dataclass containing the needed information in order to find all satellite data for EOCFI.
SelenographicDataWrite - Extra data that allowes to define CustomPoints in the GLOD data file.
- LunarObservationWrite - Dataclass containing the needed information to create a Lunar observation
in a LGLOD file.
- LGLODData - Dataclass with the data of a LGLOD simulation file. LGLOD is the GLOD-based format
used by the toolbox.
- LGLODComparisonData - Dataclass with the data of a LGLOD comparison file. LGLOD is the
GLOD-based format used by the toolbox.
LimeException - Exception that is raised by the toolbox that is intended to be shown to the user.
InterpolationSettings - Representation of the YAML file that contains the interpolation settings data.
- It exports the following Enums:
SpectralValidity - Enum that represents if a channel is inside LIME’s spectral range.
- class lime_tbx.common.datatypes.AOLPCoefficients(wavelengths: List[float], aolp_coeff: List[List[float]], unc_coeff: List[List[float]], err_corr_data: List[List[float]])[source]
Bases:
object
- class lime_tbx.common.datatypes.ComparisonData(observed_signal: SpectralData, simulated_signal: SpectralData, diffs_signal: SpectralData, mean_relative_difference: float, mean_absolute_relative_difference: float, standard_deviation_mrd: float, number_samples: int, dts: List[datetime], points: List[SurfacePoint] | List[CustomPoint], ampa_valid_range: List[bool], perc_diffs: SpectralData, mean_perc_difference: float, mdas: List[MoonData])[source]
Bases:
object
Dataclass containing the data outputed from a comparison.
The SpectralDatas “wlens” attribute is not a list of float, instead a list of datetimes, corresponding to the measurements datetimes.
The comparison data corresponds to the compared data for multiple datetimes for a single channel.
- observed_signal
Real data obtained from the GLOD files.
- Type:
- simulated_signal
Simulated data obtained from the model for the same conditions.
- Type:
- diffs_signal
Relative differences between the simulated and real data. 100*(experimental - simulated) / simulated.
- Type:
- mean_relative_difference
The mean of the relative differences (diffs_signals mean).
- Type:
float
- mean_absolute_relative_difference
The mean of the absolutes of the relative differences (abs(diffs_signals) mean).
- Type:
float
- standard_deviation_mrd
Standard deviation of relative differences.
- Type:
float
- number_samples
Number of compared instances presnet in the object
- Type:
int
- dts
Datetimes of the different samples. They are also used as the “wlens” attribute for the SpectraDatas.
- Type:
list of datetime
- points
Point for every datetime.
- Type:
list of SurfacePoint
- ampa_valid_range
Flag that indicates if the moon phase angle is in the valid LIME range.
- Type:
list of bool
- perc_diffs
Percentage differences between the simulated and real data.
- Type:
- mean_perc_difference
The mean of the percentage differences (perc_diffs mean).
- Type:
float
- ampa_valid_range: List[bool]
- diffs_signal: SpectralData
- dts: List[datetime]
- get_diffs_and_label(chosen_diffs: CompFields) Tuple[SpectralData, str] | Tuple[None, None] [source]
- mean_absolute_relative_difference: float
- mean_perc_difference: float
- mean_relative_difference: float
- number_samples: int
- observed_signal: SpectralData
- perc_diffs: SpectralData
- points: List[SurfacePoint] | List[CustomPoint]
- simulated_signal: SpectralData
- standard_deviation_mrd: float
- class lime_tbx.common.datatypes.CustomPoint(distance_sun_moon: float, distance_observer_moon: float, selen_obs_lat: float, selen_obs_lon: float, selen_sun_lon: float, abs_moon_phase_angle: float, moon_phase_angle: float)[source]
Bases:
Point
Dataclass representing a point with custom Moon data.
The needed parameters for the calculation from a custom point.
- distance_sun_moon
Distance between the Sun and the Moon (in astronomical units)
- Type:
float
- distance_observer_moon
Distance between the Observer and the Moon (in kilometers)
- Type:
float
- selen_obs_lat
Selenographic latitude of the observer (in degrees)
- Type:
float
- selen_obs_lon
Selenographic longitude of the observer (in degrees)
- Type:
float
- selen_sun_lon
Selenographic longitude of the Sun (in radians)
- Type:
float
- abs_moon_phase_angle
Absolute Moon phase angle (in degrees)
- Type:
float
- moon_phase_angle
Moon phase angle (in degrees)
- Type:
float
- abs_moon_phase_angle: float
- distance_observer_moon: float
- distance_sun_moon: float
- moon_phase_angle: float
- selen_obs_lat: float
- selen_obs_lon: float
- selen_sun_lon: float
- class lime_tbx.common.datatypes.EocfiPath(main_eocfi_path: str, custom_eocfi_path: str)[source]
Bases:
object
Dataclass containing the needed information in order to find all EOCFI data in the system.
- main_eocfi_path
Path where the main TBX satellite data is located (can be read-only).
- Type:
str
- custom_eocfi_path
Path where the custom TBX satellite data is located (can be read-only).
- Type:
str
- custom_eocfi_path: str
- main_eocfi_path: str
- class lime_tbx.common.datatypes.InterpolationSettings(interpolation_spectrum: str, interpolation_spectrum_polarisation: str, interpolation_spectrum_aolp: str, interpolation_SRF: str, show_cimel_points: bool, show_interp_spectrum: bool, skip_uncertainties: bool, use_wehrli: bool)[source]
Bases:
object
Representation of the YAML file that contains the interpolation settings data.
- interpolation_spectrum
Name (and id) of the spectrum used for interpolation.
- Type:
str
- interpolation_spectrum_polarisation
Name (and id) of the spectrum used for interpolation for polarisation.
- Type:
str
- interpolation_spectrum_aolp
Name (and id) of the spectrum used for interpolation for angle of polarisation.
- Type:
str
- interpolation_SRF
Name (and id) of the spectrum used for SRF interpolation.
- Type:
str
- show_interp_spectrum
Flag that indicates if the interpolation spectrum used is going to be shown in graphs.
- Type:
bool
- skip_uncertainties
Flag that indicates if the uncertainties calculation should be skipped.
- Type:
bool
- use_wehrli
Boolean indicating if the Wehrli spectrum will be used for calculating ESI or not.
- Type:
bool
- interpolation_SRF: str
- interpolation_spectrum: str
- interpolation_spectrum_aolp: str
- interpolation_spectrum_polarisation: str
- show_cimel_points: bool
- show_interp_spectrum: bool
- skip_uncertainties: bool
- use_wehrli: bool
- class lime_tbx.common.datatypes.KernelsPath(main_kernels_path: str, custom_kernel_path: str)[source]
Bases:
object
Dataclass containing the needed information in order to find all SPICE kernels.
- main_kernels_path
Path where the main SPICE kernels are located (can be read-only).
- Type:
str
- custom_kernel_path
Path where the custom SPICE kernel will be stored (must be writeable).
- Type:
str
- custom_kernel_path: str
- main_kernels_path: str
- class lime_tbx.common.datatypes.LGLODComparisonData(comparisons: List[ComparisonData], ch_names: List[str], sat_name: str, spectrum_name: str, skipped_uncs: bool, version: str)[source]
Bases:
object
Dataclass with the data of a LGLOD comparison file. LGLOD is the GLOD-based format used by the toolbox.
- comparisons
List of the comparison values.
- Type:
list of ComparisonData
- ch_names
List with the names of the channels.
- Type:
list of str
- sat_name
Name of the satellite used for comparison.
- Type:
str
- spectrum_name
Name of the spectrum used for interpolation.
- Type:
str
- skipped_uncs
Flag that indicates if the uncertainties calculation was skipped or not.
- Type:
bool
- ch_names: List[str]
- comparisons: List[ComparisonData]
- sat_name: str
- skipped_uncs: bool
- spectrum_name: str
- version: str
- class lime_tbx.common.datatypes.LGLODData(observations: List[LunarObservationWrite], signals: SpectralData, not_default_srf: bool, elis_cimel: List[SpectralData], elrefs_cimel: List[SpectralData], polars_cimel: List[SpectralData], aolp_cimel: List[SpectralData], spectrum_name: str, skipped_uncs: bool, version: str, dolp_spectrum_name: str, aolp_spectrum_name: str)[source]
Bases:
object
Dataclass with the data of a LGLOD simulation file. LGLOD is the GLOD-based format used by the toolbox.
- observations
Spectral irradiance, reflectance and polarisation for all the datetimes.
- Type:
list of LunarObservationWrite
- signals
SRF-Integrated irradiance data.
- Type:
- not_default_srf
Flag that indicates if the spectral response function used is the default one or not (a custom user-selected one).
- Type:
bool
- elis_cimel
Irradiance for the cimel.
- Type:
list of SpectralData
- elrefs_cimel
Reflectance for the cimel.
- Type:
list of SpectralData
- polars_cimel
Polarisation for the cimel.
- Type:
list of SpectralData
- aolp_cimel
AoLP for the cimel.
- Type:
list of SpectralData
- spectrum_name
Name of the spectrum used for interpolation.
- Type:
str
- skipped_uncs
Flag that indicates if the uncertainties calculation was skipped or not.
- Type:
bool
- dolp_spectrum_name
Name of the spectrum used for degree of linear polarisation interpolation.
- Type:
str
- aolp_spectrum_name
Name of the spectrum used for angle of linear polarisation interpolation.
- Type:
str
- aolp_cimel: List[SpectralData]
- aolp_spectrum_name: str
- dolp_spectrum_name: str
- elis_cimel: List[SpectralData]
- elrefs_cimel: List[SpectralData]
- not_default_srf: bool
- observations: List[LunarObservationWrite]
- polars_cimel: List[SpectralData]
- signals: SpectralData
- skipped_uncs: bool
- spectrum_name: str
- version: str
- class lime_tbx.common.datatypes.LimeCoefficients(reflectance: ReflectanceCoefficients, polarisation: PolarisationCoefficients, aolp: AOLPCoefficients, version: str)[source]
Bases:
object
Coefficients used in the LIME algorithms.
- reflectance
Reflectance coefficients for the LIME model.
- Type:
- polarisation
Polarisation coefficients for the DoLP/LIME model.
- Type:
PolatizationCoefficients
- version
Name of the version that will be shown to the user.
- Type:
str
- aolp: AOLPCoefficients
- polarisation: PolarisationCoefficients
- reflectance: ReflectanceCoefficients
- version: str
- exception lime_tbx.common.datatypes.LimeException(*args: object)[source]
Bases:
Exception
Exception that is raised by the toolbox that is intended to be shown to the user.
- class lime_tbx.common.datatypes.LunarObservation(ch_names: List[str], sat_pos_ref: str, ch_irrs: Dict[str, float], dt: datetime, sat_pos: SatellitePosition | None, data_source: str, md: MoonData | None)[source]
Bases:
object
Dataclass containing the information for one GLOD-like lunar observation instant.
- ch_names
Names of the channels present
- Type:
list of str
- sat_pos_ref
Name of the reference system, usually J2000 (Earth), or MOON_ME (Moon). For EOCFI it’s ITRF93.
- Type:
str
- ch_irrs
Irradiances relative to each channel. The key is the channel name, and the irradiance is given in Wm⁻²nm⁻¹.
- Type:
dict of str and float
- dt
Datetime of the observation.
- Type:
datetime
- sat_pos
Satellite position at that moment.
- Type:
- data_source
Data source of the lunar observation.
- Type:
str
- ch_irrs: Dict[str, float]
- ch_names: List[str]
- check_valid_srf(srf: SpectralResponseFunction) bool [source]
- data_source: str
- dt: datetime
- sat_pos: SatellitePosition | None
- sat_pos_ref: str
- class lime_tbx.common.datatypes.LunarObservationWrite(ch_names: List[str], sat_pos_ref: str, dt: datetime, sat_pos: SatellitePosition, irrs: SpectralData, refls: SpectralData, polars: SpectralData, aolp: SpectralData, sat_name: str, selenographic_data: SelenographicDataWrite, data_source: str)[source]
Bases:
object
Dataclass containing the needed information to create a Lunar observation in a LGLOD file.
- ch_names
Names of the channels present
- Type:
list of str
- sat_pos_ref
Name of the reference system, usually J2000 (Earth), or MOON_ME (Moon). For EOCFI it’s ITRF93.
- Type:
str
- dt
Datetime of the observation.
- Type:
datetime
- sat_pos
Satellite position at that moment.
- Type:
- irrs
Irradiance data
- Type:
- refls
Reflectance data
- Type:
- polars
Polarisation data
- Type:
- aolp
AoLP data
- Type:
- sat_name
Name of the satellite. If None or empty, then it’s a SurfacePoint
- Type:
str | None
- selenographic_data
If a CustomPoint, data that allowes to define the point. If None then it’s not selenographic (not a CustomPoint).
- Type:
SelenographicDataWrite | None
- data_source
Data source of the lunar observation.
- Type:
str
- aolp: SpectralData
- ch_names: List[str]
- check_valid_srf(srf: SpectralResponseFunction) bool [source]
- data_source: str
- dt: datetime
- irrs: SpectralData
- polars: SpectralData
- refls: SpectralData
- sat_name: str
- sat_pos: SatellitePosition
- sat_pos_ref: str
- selenographic_data: SelenographicDataWrite
- class lime_tbx.common.datatypes.MoonData(distance_sun_moon: float, distance_observer_moon: float, long_sun_radians: float, lat_obs: float, long_obs: float, absolute_mpa_degrees: float, mpa_degrees: float, geom_factor: float | None = None)[source]
Bases:
object
Moon data needed to calculate Moon’s irradiance, probably obtained from NASA’s SPICE Toolbox
- distance_sun_moon
Distance between the Sun and the Moon (in astronomical units)
- Type:
float
- distance_observer_moon
Distance between the Observer and the Moon (in kilometers)
- Type:
float
- selen_sun_lon_rad
Selenographic longitude of the Sun (in radians)
- Type:
float
- selen_obs_lat
Selenographic latitude of the observer (in degrees)
- Type:
float
- selen_obs_lon
Selenographic longitude of the observer (in degrees)
- Type:
float
- abs_moon_phase_angle
Absolute Moon phase angle (in degrees)
- Type:
float
- mpa_degrees
Moon phase angle (in degrees)
- Type:
float
- geom_factor
Geometric factor by which the TBX calculated irradiance will be divided. Used in comparisons when the normalization parameters (distances) are not available with precision.
- Type:
float
- class lime_tbx.common.datatypes.OrbitFile(name: str, dt0: datetime, dtf: datetime)[source]
Bases:
object
Dataclass that represents a Satellite orbit file.
- name
Name of the orbit file in the file system.
- Type:
str
- dt0
First datetime for which the orbit file works.
- Type:
datetime
- dtf
Last datetime for which the orbit file works
- Type:
datetime
- dt0: datetime
- dtf: datetime
- name: str
- class lime_tbx.common.datatypes.Point[source]
Bases:
ABC
Abstract class representing a point which can be used to generate a MoonData
- class lime_tbx.common.datatypes.PolarisationCoefficients(wavelengths: List[float], pos_coeffs: List[List[float]], pos_unc: List[List[float]], p_pos_err_corr_data: List[List[float]], neg_coeffs: List[List[float]], neg_unc: List[List[float]], p_neg_err_corr_data: List[List[float]])[source]
Bases:
object
Coefficients used in the DoLP algorithm.
If created with numpy arrays, it will return those numpy arrays.
- get_coefficients_negative(wavelength_nm: float) List[float] [source]
Gets all negative phase angle coefficients for a concrete wavelength
- Parameters:
wavelength_nm (float) – Wavelength in nanometers from which one wants to obtain the coefficients.
- Returns:
A list containing the ‘a’ coefficients for the wavelength
- Return type:
list of float
- get_coefficients_positive(wavelength_nm: float) List[float] [source]
Gets all positive phase angle coefficients for a concrete wavelength
- Parameters:
wavelength_nm (float) – Wavelength in nanometers from which one wants to obtain the coefficients.
- Returns:
A list containing the ‘a’ coefficients for the wavelength
- Return type:
list of float
- class lime_tbx.common.datatypes.ReflectanceCoefficients(_ds: Dataset)[source]
Bases:
object
Set of coefficients from the same version. Used in order to calculate the reflectance from mainly CIMEL data.
- _ds
Original source dataset
- Type:
xarray.DataSet
- wlens
Wavelengths present in this coefficient version. Each one of them
- Type:
np.ndarray
- coeffs
Reflectance Coefficients, with an attribute for every coefficient group, a matrix each.
- Type:
_WlenReflCoeffs
- unc_coeffs
Reflectance Coefficients uncertainties, with an attribute for every coefficient group, a matrix each.
- Type:
_WlenReflCoeffs
- coeffs
- err_corr_coeff
- unc_coeffs
- wlens: ndarray
- class lime_tbx.common.datatypes.SRFChannel(center: float, id: str, spectral_response: Dict[float, float], min_wlen: float = 350, max_wlen: float = 2500)[source]
Bases:
object
Dataclass containing the spectral responses and metadata for a SRF Channel
- center: float
Center wavelength
- id: str
Identifier of the channel
- spectral_responsedict of float, float
Set of pairs wavelength, percentage. 100% = 1.0.
- spectral_validity: SpectralValidity
Information about if the channel is inside LIME’s spectral calculation range or not.
- center: float
- id: str
- spectral_response: Dict[float, float]
- valid_spectre: SpectralValidity
- class lime_tbx.common.datatypes.SRF_fwhm(name: str, wav_centre: ndarray, fwhm: ndarray, shape: str)[source]
Bases:
object
Dataclass containing the spectral response function, a set of channels with their data.
- name
Name of the SRF, the identifier.
- Type:
str
- channels
List of the SRF channels.
- Type:
list of SRFChannel
- fwhm: ndarray
- name: str
- shape: str
- wav_centre: ndarray
- class lime_tbx.common.datatypes.Satellite(name: str, id: int, orbit_files: List[OrbitFile], norad_sat_number: int | None, intdes: str | None, time_file: str | None)[source]
Bases:
object
Dataclass that represents an ESA Satellite.
- name
Satellite name
- Type:
str
- id
Satellite id
- Type:
int
- norad_sat_number
Number of the satellite in the NORAD Catalog number (Celestrak) Only present if the satellite has TLE files.
- Type:
int | None
- intdes
International Designator of the object. Only present if the satellite has TLE files.
- Type:
str | None
- time_file
File used for time initialization. Only present if the satellite has TLE files.
- Type:
str | None
- get_best_orbit_file(dt: datetime) OrbitFile [source]
Obtain the best orbit file for the given datetime.
- Parameters:
dt (datetime) – Datetime that is queried.
- Returns:
orbit_file – Selected orbit file for the fiven datetime.
- Return type:
- get_datetime_range() Tuple[datetime, datetime] [source]
Calculate all the datetime range between its orbit files.
- Returns:
dt0 (datetime) – First datetime for which the Satellite can be simulated.
dtf (datetime) – Last datetime for which the Satellite can be simulated.
- id: int
- intdes: str | None
- name: str
- norad_sat_number: int | None
- time_file: str | None
- class lime_tbx.common.datatypes.SatellitePoint(name: str, dt: datetime | List[datetime])[source]
Bases:
Point
Dataclass representing a Satellite in a concrete datetime
- name
Name of the satellite
- Type:
str
- dt
Datetime/s that will be computed
- Type:
datetime | list of datetime
- dt: datetime | List[datetime]
- name: str
- class lime_tbx.common.datatypes.SatellitePosition(x: float, y: float, z: float)[source]
Bases:
object
Dataclass containing the information of the position of a SatellitePoint, for a specific reference system, usually J2000 (Earth), or MOON_ME (Moon). For EOCFI it’s ITRF93.
- x
The x coordinate
- Type:
float
- y
The y coordinate
- Type:
float
- z
The z coordinate
- Type:
float
- x: float
- y: float
- z: float
- class lime_tbx.common.datatypes.SelenographicDataWrite(distance_sun_moon: float, selen_sun_lon_rad: float, mpa_degrees: float, selen_obs_lat_deg: float, selen_obs_lon_deg: float, distance_obs_moon_km: float)[source]
Bases:
object
Extra data that allowes to define CustomPoints in the GLOD data file.
- distance_sun_moon
Distance between the Sun and the Moon (in astronomical units)
- Type:
float
- selen_sun_lon_rad
Selenographic longitude of the Sun (in radians)
- Type:
float
- mpa_degrees
Moon phase angle (in degrees)
- Type:
float
- selen_obs_lat_deg
Selenographic latitude of the observer (in degrees)
- Type:
float
- selen_obs_lon_deg
Selenographic longitude of the observer (in degrees)
- Type:
float
- distance_obs_moon_km
Distance between the observer and the Moon (in kilometers)
- Type:
float
- distance_obs_moon_km: float
- distance_sun_moon: float
- mpa_degrees: float
- selen_obs_lat_deg: float
- selen_obs_lon_deg: float
- selen_sun_lon_rad: float
- class lime_tbx.common.datatypes.SpectralData(wlens: ndarray, data: ndarray, uncertainties: ndarray, ds: Dataset)[source]
Bases:
object
Data for a spectrum of wavelengths, with an associated uncertainty each.
- wlens
Spectrum of wavelengths.
- Type:
np.ndarray
- data
Data associated to the wavelengths (irradiance, reflectance, etc).
- Type:
np.ndarray
- uncertainties
Uncertainties associated to the data.
- Type:
np.ndarray
- err_corr
Error correlation matrix, if included.
- Type:
None | np.ndarray
- static make_irradiance_ds(wavs: ndarray, irr: ndarray, unc: ndarray | None = None, corr: ndarray | None = None) Dataset [source]
- static make_polarisation_ds(wavs: ndarray, polarisation: ndarray, unc: ndarray | None = None, corr: ndarray | None = None) Dataset [source]
- class lime_tbx.common.datatypes.SpectralResponseFunction(name: str, channels: List[SRFChannel])[source]
Bases:
object
Dataclass containing the spectral response function, a set of channels with their data.
- name
Name of the SRF, the identifier.
- Type:
str
- channels
List of the SRF channels.
- Type:
list of SRFChannel
- channels: List[SRFChannel]
- get_channel_from_name(name: str) SRFChannel [source]
- name: str
- class lime_tbx.common.datatypes.SpectralValidity(value)[source]
Bases:
Enum
Enum that represents if a channel is inside LIME’s spectral range. VALID: Fully in the range. PARTLY_OUT: Some wavelengths out of range. OUT: All wavelengths out of range.
- OUT = 2
- PARTLY_OUT = 1
- VALID = 0
- class lime_tbx.common.datatypes.SurfacePoint(latitude: float, longitude: float, altitude: float, dt: datetime | List[datetime])[source]
Bases:
Point
Dataclass representing a point on Earth’s surface.
The needed parameters for the calculation from a surface point.
- latitude
Geographic latitude in decimal degrees.
- Type:
float
- longitude
Geographic longitude in decimal degrees.
- Type:
float
- altitude
Altitude over the sea level in meters.
- Type:
float
- dt
Time or time series at which the lunar data will be calculated.
- Type:
datetime | list of datetime
- altitude: float
- dt: datetime | List[datetime]
- latitude: float
- longitude: float