lime_tbx.business.spice_adapter.spice_adapter module
This module acts as an interface/adapter with NASA’s SPICE software.
- It exports the following classes:
ISPICEAdapter - Interface that contains the methods of this module.
SPICEAdapter - Class that implements the methods exported by this module.
- class lime_tbx.business.spice_adapter.spice_adapter.ISPICEAdapter[source]
Bases:
ABC
Interface that contains the methods of this module.
- It exports the following functions:
- get_moon_data_from_earth() - Calculate lunar data for a position on earth
surface at a concrete datetime.
- get_moon_datas_from_rectangular_multiple() - Calculate lunar data for some
rectangular coordinates from Earth or Moon.
to_rectangular_multiple() - Transforms planetographic coordinates to rectangular coordinates.
- to_planetographic_multiple() - Transforms multiple rectangular coordinates
to planetographic coordinates.
- abstract static get_moon_data_from_earth(latitude: float, longitude: float, altitude: float, dt: datetime | List[datetime], kernels_path: KernelsPath, source_frame: str = 'J2000') MoonData | List[MoonData] [source]
Calculate lunar data for a position on earth surface at a concrete datetime.
- Parameters:
latitude (float) – Geographic latitude in decimal degrees.
longitude (float) – Geographic longitude in decimal degrees.
altitude (float) – Altitude over the sea level in meters.
dt (datetime | list of datetimes) – Time or time series at which the lunar data will be calculated.
kernels_path (str) – Path where the needed SPICE kernels are located. The user must have write access to that directory.
source_frame (str) – Source frame from which to transform the xyz coordinates. By default J2000, but it can be others like MOON_ME or ITRF93.
- Returns:
md – Lunar data for the given parameters. If the parameter dt was a list, this will be a list. Otherwise not.
- Return type:
- static get_moon_datas_from_rectangular_multiple(xyzs: List[Tuple[float, float, float]], dts: List[datetime], kernels_path: KernelsPath, source_frame: str = 'J2000') List[MoonData] [source]
Calculate lunar data for the given rectangular coordinates. Faster execution for some cases
- Parameters:
xyzs (list of tuple of three floats) – Rectangular coordinates in meters
dts (List of datetime) – Datetimes of each position of those xyzs
kernels_path (KernelsPath) – Information about the SPICE kernels location
source_frame (str) – Source frame from which to transform the xyz coordinates. By default J2000, but it can be something like ‘MOON_ME’ if the coordinates are lunar.
Returns
--------
MoonData (list of) – Lunar data for the given parameters.
- abstract static get_solar_moon_datas(dts: List[datetime], kernels_path: str)[source]
Obtain solar selenographic coordinates of at multiple times.
- timeslist of str | list of datetime
Times at which the lunar data will be calculated. If they are str, they must be in a valid UTC format allowed by SPICE, such as %Y-%m-%d %H:%M:%S. If they are datetimes they must be timezone aware, or they will be understood as computer local time.
- kernels_pathstr
Path where the SPICE kernels are stored
- abstract static to_planetographic_multiple(xyz_list: List[Tuple[float]], body: str, kernels_path: str, datetimes: List[datetime], source_frame: str = 'J2000', target_frame: str = 'IAU_EARTH') List[Tuple[float, float, float]] [source]
Transforms multiple rectangular coordinates to planetographic coordinates.
- Parameters:
xyz_list (list of tuples of 3 floats) – List of xyz coordinates in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
datetimes (list of datetime) – Datetimes of the positions
source_frame (str) – Reference frame of the rectangular coordinates
target_frame (str) – Reference frame of the planetographic coordinates
- Returns:
llhs – List of planetographic coordinates, in lat (deg), lon (deg), alt (meters) form.
- Return type:
list of tuples of 3 floats
- abstract static to_planetographic_same_frame(xyz_list: List[Tuple[float]], body: str, kernels_path: str) List[Tuple[float, float, float]] [source]
Transforms multiple rectangular coordinates to planetographic coordinates in the same ref frame.
- Parameters:
xyz_list (list of tuples of 3 floats) – List of xyz coordinates in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
- Returns:
llhs – List of planetographic coordinates, in lat (deg), lon (deg), alt (meters) form.
- Return type:
list of tuples of 3 floats
- static to_rectangular_multiple(latlonheights: List[Tuple[float, float, float]], body: str, kernels_path: str, datetimes: List[datetime], source_frame: str = 'IAU_EARTH', target_frame: str = 'J2000') List[Tuple[float, float, float]] [source]
Transforms planetographic coordinates to rectangular coordinates.
- Parameters:
latlonheights (list of tuple of floats) – Latitude and longitude in degrees, height in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
datetimes (list of datetime) – Datetimes of the positions
source_frame (str) – Reference frame of the planetographic coordinates
target_frame (str) – Reference frame of the rectangular coordinates
- Returns:
xyzs – Rectangular coordinates in meters
- Return type:
list of tuples of 3 floats
- abstract static to_rectangular_same_frame(latlonheights: List[Tuple[float, float, float]], body: str, kernels_path: str) List[Tuple[float, float, float]] [source]
Transforms planetographic coordinates to rectangular coordinates in the same frame.
- Parameters:
latlonheights (list of tuple of floats) – Latitude and longitude in degrees, height in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
- Returns:
xyzs – Rectangular coordinates in meters
- Return type:
list of tuples of 3 floats
- class lime_tbx.business.spice_adapter.spice_adapter.SPICEAdapter[source]
Bases:
ISPICEAdapter
Class that implements the methods of this module.
- It exports the following functions:
- get_moon_data_from_earth() - Calculate lunar data for a position on earth
surface at a concrete datetime.
- get_moon_data_from_moon() - Calculate lunar data for a position on moon’s
surface at a concrete datetime.
to_rectangular_multiple() - Transforms planetographic coordinates to rectangular coordinates.
- to_planetographic_multiple() - Transforms multiple rectangular coordinates
to planetographic coordinates.
- static get_moon_data_from_earth(latitude: float, longitude: float, altitude: float, dt: datetime | List[datetime], kernels_path: KernelsPath, source_frame: str = 'J2000') MoonData | List[MoonData] [source]
Calculate lunar data for a position on earth surface at a concrete datetime.
- Parameters:
latitude (float) – Geographic latitude in decimal degrees.
longitude (float) – Geographic longitude in decimal degrees.
altitude (float) – Altitude over the sea level in meters.
dt (datetime | list of datetimes) – Time or time series at which the lunar data will be calculated.
kernels_path (str) – Path where the needed SPICE kernels are located. The user must have write access to that directory.
source_frame (str) – Source frame from which to transform the xyz coordinates. By default J2000, but it can be others like MOON_ME or ITRF93.
- Returns:
md – Lunar data for the given parameters. If the parameter dt was a list, this will be a list. Otherwise not.
- Return type:
- static get_moon_datas_from_rectangular_multiple(xyzs: List[Tuple[float, float, float]], dts: List[datetime], kernels_path: KernelsPath, source_frame: str = 'J2000') List[MoonData] [source]
Calculate lunar data for the given rectangular coordinates. Faster execution for some cases
- Parameters:
xyzs (list of tuple of three floats) – Rectangular coordinates in meters
dts (List of datetime) – Datetimes of each position of those xyzs
kernels_path (KernelsPath) – Information about the SPICE kernels location
source_frame (str) – Source frame from which to transform the xyz coordinates. By default J2000, but it can be something like ‘MOON_ME’ if the coordinates are lunar.
Returns
--------
MoonData (list of) – Lunar data for the given parameters.
- static get_solar_moon_datas(dts: List[datetime], kernels_path: str)[source]
Obtain solar selenographic coordinates of at multiple times.
- timeslist of str | list of datetime
Times at which the lunar data will be calculated. If they are str, they must be in a valid UTC format allowed by SPICE, such as %Y-%m-%d %H:%M:%S. If they are datetimes they must be timezone aware, or they will be understood as computer local time.
- kernels_pathstr
Path where the SPICE kernels are stored
- static to_planetographic_multiple(xyz_list: List[Tuple[float]], body: str, kernels_path: str, datetimes: List[datetime], source_frame: str = 'J2000', target_frame: str = 'IAU_EARTH')[source]
Transforms multiple rectangular coordinates to planetographic coordinates.
- Parameters:
xyz_list (list of tuples of 3 floats) – List of xyz coordinates in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
datetimes (list of datetime) – Datetimes of the positions
source_frame (str) – Reference frame of the rectangular coordinates
target_frame (str) – Reference frame of the planetographic coordinates
- Returns:
llhs – List of planetographic coordinates, in lat (deg), lon (deg), alt (meters) form.
- Return type:
list of tuples of 3 floats
- static to_planetographic_same_frame(xyz_list: List[Tuple[float]], body: str, kernels_path: str)[source]
Transforms multiple rectangular coordinates to planetographic coordinates in the same ref frame.
- Parameters:
xyz_list (list of tuples of 3 floats) – List of xyz coordinates in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
- Returns:
llhs – List of planetographic coordinates, in lat (deg), lon (deg), alt (meters) form.
- Return type:
list of tuples of 3 floats
- static to_rectangular_multiple(latlonheights: List[Tuple[float, float, float]], body: str, kernels_path: str, datetimes: List[datetime], source_frame: str = 'IAU_EARTH', target_frame: str = 'J2000')[source]
Transforms planetographic coordinates to rectangular coordinates.
- Parameters:
latlonheights (list of tuple of floats) – Latitude and longitude in degrees, height in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
datetimes (list of datetime) – Datetimes of the positions
source_frame (str) – Reference frame of the planetographic coordinates
target_frame (str) – Reference frame of the rectangular coordinates
- Returns:
xyzs – Rectangular coordinates in meters
- Return type:
list of tuples of 3 floats
- static to_rectangular_same_frame(latlonheights: List[Tuple[float, float, float]], body: str, kernels_path: str)[source]
Transforms planetographic coordinates to rectangular coordinates in the same frame.
- Parameters:
latlonheights (list of tuple of floats) – Latitude and longitude in degrees, height in meters.
body (str) – Name of the body. For example ‘MOON’ or ‘EARTH’.
kernels_path (str) – Path to the directory of the main kernels.
- Returns:
xyzs – Rectangular coordinates in meters
- Return type:
list of tuples of 3 floats