f2m.pangu_interface package¶
Submodules¶
f2m.pangu_interface.generate_frames module¶
- f2m.pangu_interface.generate_frames.generate_frames(flight_file: Path, output_folder: Path, pangu_model: str = 'models/malapert/spole_flat.pan', width: int = 1024, height: int = 1024, sun: list[float] = [149600000000.0, 300, 4], reflectance: str = 'hapke', shadows: Literal['static', 'dynamic', 'none'] = 'static', sun_samples: int = 20, shadowmap: str | None = None, use_virtual_display: bool = True, spice_flags: tuple = None, move_model: tuple[list[int], list[int]] | None = None, verbose: bool = False, **pangu_kwargs: str) None¶
Generate frames using PANGU
- Parameters:
flight_file (Path) – The flight file to use
output_folder (Path) – The output folder to save the frames
pangu_model (str) – The PANGU model to use. Defaults to “models/malapert/spole_flat.pan”.
width (int) – The width of the frames. Defaults to 1024.
height (int) – The height of the frames. Defaults to 1024.
sun (list[float]) – The sun position parameters. Defaults to [1.496e11, 300, 4].
reflectance (str) – The reflectance model to use. Defaults to “hapke”.
shadows (Literal["static, dynamic", "none"]) – The type of shadows to use. Defaults to “static”.
sun_samples (int) – The number of samples to use for the shadowmap. Ignored if shadows is not “static”. Defaults to 20.
shadowmap (Optional[str]) – The shadowmap to use, ignored if shadows is not “static”. If None, the name of the shadowmap is inferred from the model name and sun position. Defaults to None.
use_virtual_display (bool) – Whether to use a virtual display to run PANGU. Defaults to True.
spice_flags (tuple) – Consists of (spice_frame, spice_epoch, spice_search). Give None to disable spice entirely. If specific indices are None, a default is assigned.
move_model (Optional[tuple]) – [0] being an ArrayLike object of position (3x1) and [1] being an ArrayLike (4x1) quaternion (in wxyz) for the rotation
verbose (bool) – Whether to print the shell command that is run. Defaults to False.
Note
Make sure you have the spice kernels installed in the right place:
- For spice_flags:
spice_frame : J2000|MOON_ME|IAU_MARS|ITOKAWA_FIXED| spice_epoch : 2000/01/01 00:00:00.0 (“yyyy/mm/dd hh:mm:ss.frac”) spice_search : pangu_path
For debugging: set -sky to ‘red’ instead of ‘black’
f2m.pangu_interface.rangefinder module¶
- f2m.pangu_interface.rangefinder.close_server_mode() Popen¶
Closes the PANGU server mode
- f2m.pangu_interface.rangefinder.rangefinder(fli_file: Path, output_path: Path, pangu_model: str = 'models/malapert/spole_flat.pan', h: int = 1024, w: int = 1024, use_virtual_display: bool = True, indices: list[int] | None = None, move_model: tuple[list[int], list[int]] | None = None) list[float]¶
Generate depth maps for the flight trajectory from .fli files
- Parameters:
fli_file (Path) – The flight file to use
output_path (Path) – The output folder to save the frames
pangu_model (str) – The PANGU model to use. Defaults to “models/malapert/spole_flat.pan”.
h (int) – The height of the frames. Defaults to 1024.
w (int) – The width of the frames. Defaults to 1024.
use_virtual_display (bool) – Whether to use a virtual display to run PANGU. Defaults to True.
indices (Optional[list[int]]) – indices in the flight file to take the snapshot of. If None, the whole flight file will be used. Defaults to None.
move_model (Optional[tuple]) – [0] being an ArrayLike object of position (3x1) and [1] being an ArrayLike (4x1) quaternion (in wxyz) for the rotation.
- Returns:
The rangefinder values
- Return type:
list[float]
- f2m.pangu_interface.rangefinder.snapshot_lidar_call(output_path: Path, x: float, y: float, z: float, q1: float, q2: float, q3: float, q4: float) None¶
- f2m.pangu_interface.rangefinder.start_server_mode(pangu_model: str = 'models/malapert/spole_flat.pan', width: int = 1024, height: int = 1024, fov: int = 60, move_model: tuple[list[int], list[int]] | None = None) Popen¶
Starts PANGU model in server mode
- Parameters:
pangu_model (str) – The PANGU model to use. Defaults to “models/malapert/spole_flat.pan”.
width (int) – The width of the frames. Defaults to 1024.
height (int) – The height of the frames. Defaults to 1024.
fov (int) – The field of view. Defaults to 60.
- Returns:
The PANGU process
- Return type:
subprocess.Popen
f2m.pangu_interface.utils module¶
- f2m.pangu_interface.utils.generate_shadowmap(pangu_model: str, sun: list[float], samples: int = 20, threads: int | None = None) None¶
Generates the PANGU shadowmap
- Parameters:
pangu_model (str) – The PANGU model to use.
sun (list[float]) – The sun parameters.
samples (int) – The number of samples to use for the shadowmap. Defaults to 20.
threads (Optional[int]) – The number of threads to use. If None, it will use 125% of the available CPU cores. Defaults to None.
- f2m.pangu_interface.utils.get_landing_site_dir(pangu_model: str) str¶
Returns the PANGU model directory
- Parameters:
pangu_model (str) – The PANGU model to use.
- Returns:
The PANGU model directory
- Return type:
str
- f2m.pangu_interface.utils.get_shadowmap(pangu_model: str, sun: list[float], samples: int = 20) str¶
Returns the name of the PANGU shadowmap
- Parameters:
pangu_model (str) – The PANGU model to use.
sun (list[float]) – The sun parameters.
samples (int) – The number of samples to use for the shadowmap. Defaults to 20.
- Returns:
The PANGU shadowmap name
- Return type:
str
- f2m.pangu_interface.utils.handle_pangu_error(e: CalledProcessError, use_virtual_display: bool) None¶
Handles PANGU errors
- Parameters:
e (subprocess.CalledProcessError) – The error
use_virtual_display (bool) – Whether a virtual display is used