Skip to main content

Lunar DEM generation, Kaguya scene analysis, metadata prediction, and rover-aware landing utilities.

Project description

lunadem

lunadem is a lunar terrain analysis library for DEM reconstruction, Kaguya scene metadata understanding, offline metadata prediction, rover-aware landing analysis, and dual-backend visualization.

PyPI: https://pypi.org/project/lunadem/

Install

pip install lunadem

Optional extras:

pip install "lunadem[ml]"
pip install "lunadem[viz]"
pip install "lunadem[pds]"
pip install "lunadem[dev]"

Canonical import and CLI name is lunadem.

Compatibility note:

  • import lunardem still works as a deprecated compatibility shim.
  • lunardem still exists as a compatibility CLI alias.

Main Capabilities

  • DEM generation from images with sfs, multiscale_sfs, ml, and hybrid methods.
  • Memory-safe SFS and hybrid reconstruction for large Kaguya scenes through bounded working resolution.
  • Kaguya scene loading from STAC item.json plus camera.json.
  • Dozens of deterministic metadata helpers for centroid, bbox, footprint, coverage, transforms, angles, camera path, and sun geometry.
  • Packaged shape-from-shading theory helpers through CLI and Python.
  • Packaged offline ONNX metadata models for illumination, view geometry, and scene context prediction.
  • Rover presets for sojourner, spirit, opportunity, curiosity, perseverance, pragyan, and soraq.
  • Rover-aware landing-site search using slope, roughness, hazard, clearance, and optional sun geometry.
  • Matplotlib plotting for visible local rendering and Plotly for hoverable 3D output and HTML export.
  • Moon-globe, terrain-surface, landing-site, and scene-geometry visualization.
  • download --test support for the official reference scene.

Bundled Resources

  • Kaguya dataset access helpers in lunadem.datasets.
  • SFS theory files in lunadem/assets/docs/.
  • Real packaged ONNX model weights in lunadem/assets/models/.
  • Packaged metrics file describing the current model suite.
  • Rover preset catalog in lunadem.landing.rovers.
  • Optional C++ acceleration hook under lunadem._native when built with native support.
  • Detailed generated references in run.md, lunar_data.md, sfs.md, documentation.txt, and update.md.

Quick Start

from lunadem import (
    ReconstructionConfig,
    build_scene_summary,
    find_safe_landing_site,
    generate_dem,
    get_rover_spec,
    load_kaguya_scene,
    plot_landing_site_2d,
    plot_moon_surface_3d,
    plot_scene_geometry_3d,
    predict_scene_metadata,
)

scene = load_kaguya_scene("TC1S2B0_01_07496N087E3020")
summary = build_scene_summary(scene)

config = ReconstructionConfig(
    output={"output_dir": "output", "base_name": "moon_demo"},
)

dem_result = generate_dem(scene.image_path, method="hybrid", config=config)
prediction = predict_scene_metadata(scene.image_path, max_patches=8)
landing = find_safe_landing_site(scene.image_path, rover=get_rover_spec("pragyan"), scene=scene)

plot_scene_geometry_3d(
    scene,
    backend="both",
    show=False,
    save_path="output/scene_geometry.png",
    html_path="output/scene_geometry.html",
)
plot_moon_surface_3d(
    scene,
    backend="both",
    show=False,
    save_path="output/moon_surface.png",
    html_path="output/moon_surface.html",
)
plot_landing_site_2d(
    scene.image_path,
    landing,
    backend="both",
    show=False,
    save_path="output/landing_2d.png",
    html_path="output/landing_2d.html",
)

print(summary["centroid"])
print(prediction.targets)
print(landing.summary)

CLI Overview

lunadem download --test --output downloads
lunadem scene-summary TC1S2B0_01_07496N087E3020
lunadem sfs --maths
lunadem predict dataset/TC1S2B0_01_07496N087E3020/image/image.tif --kind all
lunadem generate dataset/TC1S2B0_01_07496N087E3020/image/image.tif --method hybrid --output output
lunadem plot-surface dataset/TC1S2B0_01_07496N087E3020/image/image.tif --backend both --show --reconstruct
lunadem plot-scene TC1S2B0_01_07496N087E3020 --backend both --show --output output/scene_geometry.png --output-html output/scene_geometry.html
lunadem landing-site dataset/TC1S2B0_01_07496N087E3020/image/image.tif --scene TC1S2B0_01_07496N087E3020 --rover pragyan --backend both --show --output-2d output/landing_2d.png --output-3d output/landing_3d.png --output-2d-html output/landing_2d.html --output-3d-html output/landing_3d.html

Plotting Backends

  • Use Matplotlib when you want visible local plots or static PNG output.
  • Use Plotly when you want hoverable 3D interaction or HTML export.
  • Use backend="both" for the scene, Moon, and landing plot helpers when you want both at once.
  • Python plotting APIs default to show=False so scripts stay safe.
  • CLI plot commands default to --show, which makes desktop visualization available immediately.

Public API Scope

The current public package surface exposes more than 40 callable functions and helper APIs across:

  • DEM generation and terrain analysis.
  • Scene loading and metadata derivation.
  • Coordinate and unit conversion.
  • Metadata model inspection and prediction.
  • Rover preset lookup and landing-site selection.
  • Matplotlib and Plotly visualization helpers.
  • File export helpers for GeoTIFF, OBJ, PLY, and manifest generation.

Full callable catalog and examples are in run.md.

The long-form generated manual with parameter breakdowns and code templates is in documentation.txt.

Packaged Model Metrics

The current wheel bundles real ONNX artifacts for the metadata suite. The metrics below come from grouped scene-level evaluation on the local 18-scene Kaguya dataset.

Model Target MAE
illumination_cnn sun_azimuth_deg 1.608062
illumination_cnn sun_elevation_deg 0.002216
view_geometry_cnn off_nadir_deg 0.105210
view_geometry_cnn view_azimuth_deg 0.051268
scene_context_cnn gsd_m 0.082854
scene_context_cnn centroid_lat_deg 3.149079
scene_context_cnn centroid_lon_deg 0.509205

Important note:

  • These models estimate scene metadata from imagery.
  • They are not trained as ground-truth DEM regressors.
  • They are not trained as supervised landing-safety classifiers.
  • The local dataset is still small, so accuracy should be treated as a practical estimate rather than a broad benchmark.

Reference Files

  • run.md: generated command and Python function catalog with examples.
  • documentation.txt: long-form generated manual exceeding 2000 lines.
  • lunar_data.md: explanation of the Kaguya STAC and camera metadata concepts used by the library.
  • sfs.md: shape-from-shading concepts, mathematics, terms, and assumptions.
  • update.md: GitHub and PyPI release workflow.

Development Notes

  • The package version is sourced from lunadem/__init__.py.
  • Native acceleration is optional and every accelerated path has a Python fallback.
  • The ONNX model artifacts are bundled inside the package, so end users do not need to download weights separately.
  • The official reference scene remains TC1S2B0_01_07496N087E3020.

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lunadem-0.4.5.tar.gz (8.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lunadem-0.4.5-py3-none-any.whl (8.0 MB view details)

Uploaded Python 3

File details

Details for the file lunadem-0.4.5.tar.gz.

File metadata

  • Download URL: lunadem-0.4.5.tar.gz
  • Upload date:
  • Size: 8.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for lunadem-0.4.5.tar.gz
Algorithm Hash digest
SHA256 2db233cb3c7aeb0c7a574af25befebd3080d485884d7ed97681d9f8ef4e950dd
MD5 e710d7e533b16469e7ce72edf7f924d4
BLAKE2b-256 9f6c4abab7464d76f15dfcc21ebc7ce5519d8ac15743e814b77f64bc9e74a562

See more details on using hashes here.

File details

Details for the file lunadem-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: lunadem-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for lunadem-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c9be348cf9265690359270693f2065d27de952ea7bedd1f12c6b16138c6907e0
MD5 3f47437ea788baf926ab57d10d495af7
BLAKE2b-256 799012620502b96a1e382cfea48adc6a1e7f3098da85833f8073f9b1fca09660

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page