lime_tbx.presentation.cli.cli module

Command Line Interface (CLI) module for the LIME Toolbox.

This module handles the interpretation of command-line options and executes the appropriate actions, including simulations, comparisons, and data exports.

It supports: - Simulations of lunar irradiance, reflectance, and polarization. - Comparisons with observational data. - Output in various formats (CSV, Graph, NetCDF). - Updating coefficient datasets. - Managing interpolation and spectral response function settings.

This module serves as the entry point for the command-line execution of LIME TBX.

class lime_tbx.presentation.cli.cli.CLI(kernels_path: KernelsPath, eocfi_path: EocfiPath, selected_version: str | None = None)[source]

Bases: object

Command Line Interface handler for LIME TBX.

This class processes command-line arguments, performs simulations, and manages comparisons. It serves as the main interface for users executing the toolbox from the command line.

It contains a LimeSimulation instance that handles and stores the asked calculations that then will be retrieved for export.

Responsibilities: - Simulations of lunar irradiance, reflectance, and polarization. - Comparisons with observational data. - Output in various formats (CSV, Graph, NetCDF). - Updating coefficient datasets. - Managing interpolation and spectral response function settings.

calculate_comparisons(input_files: List[str], ed: ExportComparison)[source]

Performs comparisons between simulation results and observational data.

Parameters:
  • input_files (List[str]) – List of file paths containing observational data.

  • ed (export.ExportComparison) – The comparison export configuration.

Raises:

LimeException – If the observation data is not valid.

calculate_geographic(lat: float, lon: float, height: float, dt: datetime | List[datetime], export_data: ExportData)[source]

Runs a simulation from a geographic location, ahnd export the results as specified.

Parameters:
  • lat (float) – Latitude in degrees.

  • lon (float) – Longitude in degrees.

  • height (float) – Height above sea level in meters.

  • dt (datetime or List[datetime]) – The timestamp(s) for the simulation.

  • export_data (export.ExportData) – The export configuration.

Raises:

ExportError – If something wrong happens during export.

calculate_satellital(sat_name: str, dt: datetime | List[datetime], export_data: ExportData)[source]

Runs a simulation from a satellite’s perspective.

Parameters:
  • sat_name (str) – Name of the satellite.

  • dt (datetime or List[datetime]) – The timestamp(s) for the simulation.

  • export_data (export.ExportData) – The export configuration.

Raises:

ExportError – If something wrong happens during export.

calculate_selenographic(distance_sun_moon: float, distance_observer_moon: float, selen_obs_lat: float, selen_obs_lon: float, selen_sun_lon: float, moon_phase_angle: float, export_data: ExportData)[source]

Runs a simulation from a selenographic (Moon-based) perspective.

Parameters:
  • distance_sun_moon (float) – Distance between the Sun and the Moon (meters).

  • distance_observer_moon (float) – Distance between the observer and the Moon (meters).

  • selen_obs_lat (float) – Observer’s latitude on the Moon (degrees).

  • selen_obs_lon (float) – Observer’s longitude on the Moon (degrees).

  • selen_sun_lon (float) – Sub-solar longitude on the Moon (degrees).

  • moon_phase_angle (float) – Moon phase angle (degrees).

  • export_data (export.ExportData) – The export configuration.

Raises:

ExportError – If something wrong happens during export.

check_sys_args(sysargs: List[str]) int[source]

Validates system arguments to prevent syntax errors.

Ensures flags are correctly formatted and separated.

Parameters:

sysargs (List[str]) – The raw command-line arguments.

Returns:

  • 0 if validation passes.

  • 1 if errors are found.

Return type:

int

handle_input(opts: List[Tuple[str, str]], args: List[str]) int[source]

Processes command-line options and executes the corresponding actions.

This function parses command-line arguments, validates inputs, and dispatches execution to the appropriate simulation, comparison, or configuration functions.

It supports: - Simulations of lunar irradiance, reflectance, and polarization from different perspectives (Earth, Lunar, Satellite). - Comparisons with observational data in GLOD format. - Output in multiple formats (CSV, Graph, NetCDF). - Updating coefficient datasets. - Managing interpolation and spectral response function settings.

Parameters:
  • opts (List[Tuple[str, str]]) – A list of command-line options and their corresponding arguments. Example: [('-e', '10.5,20.3,100,2023-02-18T12:00:00')]

  • args (List[str]) – Additional arguments passed after the options, primarily used for input file paths in comparisons.

Returns:

Exit status code: - 0 for success. - 1 for errors (invalid input, missing parameters, execution failures).

Return type:

int

load_srf(srf_file: str)[source]

Loads the Spectral Response Function (SRF) from a specified file.

If no file is provided, it loads the default SRF.

Parameters:

srf_file (str) – Path to the SRF file. If an empty string is given, it loads the default SRF.

update_coefficients() int[source]

Checks for and downloads coefficient dataset updates.

Returns:

  • 0 if the update is successful or no updates are available.

  • 1 if an error occurs during the update process.

Return type:

int

exception lime_tbx.presentation.cli.cli.CLIError[source]

Bases: Exception

Exception raised for all errors encountered during command-line argument processing.

exception lime_tbx.presentation.cli.cli.ParsingError[source]

Bases: CLIError

Exception raised for errors encountered during command-line argument parsing.

This exception is used to indicate issues such as: - Invalid or unrecognized argument values. - Missing required parameters. - Incorrect formatting of input arguments.

lime_tbx.presentation.cli.cli.eprint(*args, **kwargs)[source]

Prints messages to the standard error (stderr).

This function behaves like the built-in print, but directs output to sys.stderr instead of sys.stdout. It supports the same arguments as print.

Parameters:
  • *args (Any) – Positional arguments passed to print, representing the values to be printed.

  • **kwargs (Any) – Keyword arguments passed to print (e.g., sep, end, flush).

lime_tbx.presentation.cli.cli.print_help()[source]

Displays the command-line help message.

This function prints usage instructions and a description of available options for the LIME Toolbox CLI. It explains how to run simulations, comparisons, and specify output formats.

The available options include: - -h, --help: Show this help message. - -v, --version: Display the version number. - -u, --update: Update the coefficients. - -e, --earth: Perform simulations from a geographic point. - -l, --lunar: Perform simulations from a selenographic point. - -s, --satellite: Perform simulations from a satellite. - -c, --comparison: Perform comparisons using GLOD observation files. - -o, --output: Define output format and file paths. - -f, --srf: Select a Spectral Response Function (SRF) file. - -t, --timeseries: Use a CSV file with multiple datetimes. - -C, --coefficients: Change the coefficients version used by the toolbox. - -i, --interpolation-settings: Modify interpolation settings via JSON input.

The function also provides examples of valid input formats and highlights any constraints or dependencies for specific options.

lime_tbx.presentation.cli.cli.print_version()[source]

Prints the package version name to the standard output.