lime_tbx.presentation.cli.export module

Data exporting module for LIME TBX’s CLI

After parsing the command and calculating its result, this module is in charge of exporting the results to the selected kind of output.

class lime_tbx.presentation.cli.export.CLIExporter(kernels_path: KernelsPath, eocfi_path: EocfiPath, settings_manager: SettingsManager, lime_simulation: ILimeSimulation)[source]

Bases: object

Handles exporting simulation and comparison results from the CLI.

This class provides methods for saving data in multiple formats, including CSV, Graphs, and NetCDF.

export(point: Point, ed: ExportData, srf: SpectralResponseFunction)[source]

Exports simulation or comparison results based on the selected export format.

This method determines the appropriate export format (CSV, Graph, NetCDF) and calls the corresponding function.

Parameters:
  • point (Point) – The observation point (Earth, Lunar, or Satellite) for the simulation.

  • ed (ExportData) – The export configuration object, determining the file format and parameters.

  • srf (SpectralResponseFunction) – The spectral response function used in the simulation.

Raises:

ExportError – If an error occurs while exporting the data.

export_comparison_bywlen_graph(data: List[ComparisonData], wlcs: List[float], xlabel: str, ylabel: str, output_file: str, version: str, chosen_diffs: CompFields)[source]

Exports comparison results by wavelength as a boxplot graph.

This method visualizes the comparison of observed and simulated data across different wavelengths. It includes a statistical representation of differences.

Parameters:
  • data (List[ComparisonData]) – List of comparison data for each spectral channel.

  • wlcs (List[float]) – List of wavelength centers for each channel.

  • xlabel (str) – Label for the x-axis (e.g., “Wavelength (nm)”).

  • ylabel (str) – Label for the y-axis (e.g., “Irradiance (Wm⁻²nm⁻¹)”).

  • output_file (str) – Path to save the exported graph file.

  • version (str) – Version of the LIME coefficients used in the simulation.

  • chosen_diffs (CompFields) – Specifies whether to show relative differences, percentage differences, or none.

Raises:

ExportError – If an error occurs while generating or saving the graph.

export_comparison_graph(comparison: ComparisonData, xlabel: str, ylabel: str, output_file: str, version: str, title: str, chosen_diffs: CompFields, date_range: Tuple[datetime, datetime] | None = None)[source]

Exports comparison results as a graph.

This method generates a graph comparing observed and simulated irradiance values. It includes relative or percentage differences based on the chosen difference metric.

Parameters:
  • comparison (ComparisonData) – The comparison data containing observed and simulated signals.

  • xlabel (str) – Label for the x-axis (e.g., “Wavelength (nm)”, “UTC Date”).

  • ylabel (str) – Label for the y-axis (e.g., “Irradiance (Wm⁻²nm⁻¹)”).

  • output_file (str) – Path to save the exported graph file.

  • version (str) – Version of the LIME coefficients used in the simulation.

  • title (str) – Title of the graph.

  • chosen_diffs (CompFields) – Specifies whether to show relative differences, percentage differences, or none.

  • date_range (Optional, Tuple[datetime, datetime]) – Initial and final datetimes, in case the comparison is not an standard comparison, and its dts attribute is None.

Raises:

ExportError – If an error occurs while generating or saving the graph.

class lime_tbx.presentation.cli.export.ComparisonKey(value)[source]

Bases: Enum

Enumeration for comparison output modes.

DT

Compare based on UTC datetime.

Type:

int

MPA

Compare based on Moon Phase Angle.

Type:

int

BOTH

Compare using both datetime and Moon Phase Angle.

Type:

int

CHANNEL

Compare by spectral channel.

Type:

int

CHANNEL_MEAN

Compare using averaged spectral channels.

Type:

int

BOTH = 2
CHANNEL = 3
CHANNEL_MEAN = 4
DT = 0
MPA = 1
class lime_tbx.presentation.cli.export.ExportCSV(o_file_refl: str, o_file_irr: str, o_file_polar: str, o_file_integrated_irr: str)[source]

Bases: ExportData

Represents CSV file export settings for simulation results.

o_file_refl

Path to the output CSV file for reflectance.

Type:

str

o_file_irr

Path to the output CSV file for irradiance.

Type:

str

o_file_polar

Path to the output CSV file for polarization.

Type:

str

o_file_integrated_irr

Path to the output CSV file for integrated irradiance.

Type:

str

o_file_integrated_irr: str
o_file_irr: str
o_file_polar: str
o_file_refl: str
class lime_tbx.presentation.cli.export.ExportComparison[source]

Bases: ABC

Abstract base class for exporting comparison results.

This class serves as a parent for different export formats, including CSV and graphical representations of comparison data.

class lime_tbx.presentation.cli.export.ExportComparisonCSV(comparison_key: ComparisonKey, output_files: List[str], chosen_diff: CompFields)[source]

Bases: ExportComparison

Represents CSV file export settings for comparison results.

comparison_key

The comparison method (e.g., DT, MPA, BOTH, CHANNEL).

Type:

ComparisonKey

output_files

List of file paths for saving the comparison data. Each comparison type has a different amount of files.

Type:

List[str]

chosen_diff

The difference metric (relative, percentage, or none).

Type:

CompFields

chosen_diff: CompFields
comparison_key: ComparisonKey
output_files: List[str]
class lime_tbx.presentation.cli.export.ExportComparisonCSVDir(comparison_key: ComparisonKey, output_dir: str, chosen_diff: CompFields)[source]

Bases: ExportComparison

Represents CSV directory export settings for comparison results.

Instead of exporting individual CSV files, this class allows exporting all comparison data to a specified directory, and automatically generating the file names.

comparison_key

The comparison method (e.g., DT, MPA, BOTH, CHANNEL).

Type:

ComparisonKey

output_dir

The directory where CSV files will be saved.

Type:

str

chosen_diff

The difference metric (relative, percentage, or none).

Type:

CompFields

chosen_diff: CompFields
comparison_key: ComparisonKey
output_dir: str
class lime_tbx.presentation.cli.export.ExportComparisonGraph(comparison_key: ComparisonKey, output_files: List[str], chosen_diff: CompFields)[source]

Bases: ExportComparison

Represents graphical export settings for comparison results.

comparison_key

The comparison method (e.g., DT, MPA, BOTH, CHANNEL).

Type:

ComparisonKey

output_files

List of file paths for saving the comparison graphs. Each comparison type has a different amount of files.

Type:

List[str]

chosen_diff

The difference metric (relative, percentage, or none).

Type:

CompFields

chosen_diff: CompFields
comparison_key: ComparisonKey
output_files: List[str]
class lime_tbx.presentation.cli.export.ExportComparisonGraphDir(extension: str, comparison_key: ComparisonKey, output_dir: str, chosen_diff: CompFields)[source]

Bases: ExportComparison

Represents graphical export settings for comparison results in a directory.

This allows exporting comparison graphs to a specified directory with a chosen file extension, and automatically generating the file names.

extension

File extension for the exported graphs (e.g., “png”, “jpg”).

Type:

str

comparison_key

The comparison method (e.g., DT, MPA, BOTH, CHANNEL).

Type:

ComparisonKey

output_dir

The directory where graphs will be saved.

Type:

str

chosen_diff

The difference metric (relative, percentage, or none).

Type:

CompFields

chosen_diff: CompFields
comparison_key: ComparisonKey
extension: str
output_dir: str
class lime_tbx.presentation.cli.export.ExportData[source]

Bases: ABC

Abstract base class for export data formats.

Subclasses define specific export types such as CSV, Graphs, and NetCDF.

exception lime_tbx.presentation.cli.export.ExportError[source]

Bases: Exception

Exception that encapsules anything that might go wrong during CLI file export.

class lime_tbx.presentation.cli.export.ExportGraph(o_file_refl: str, o_file_irr: str, o_file_polar: str)[source]

Bases: ExportData

Represents graphical export settings for simulation results.

o_file_refl

Path to the output graph file for reflectance.

Type:

str

o_file_irr

Path to the output graph file for irradiance.

Type:

str

o_file_polar

Path to the output graph file for polarization.

Type:

str

o_file_irr: str
o_file_polar: str
o_file_refl: str
class lime_tbx.presentation.cli.export.ExportNetCDF(output_file: str)[source]

Bases: ExportData, ExportComparison

Represents NetCDF file export settings for simulations and comparisons.

This format allows storing structured, multi-dimensional scientific data.

output_file

The path to the NetCDF output file.

Type:

str

output_file: str