lunar_toolkit.shadowcam.sc

KPLO ShadowCam: ODE file selection, download, SPICE and CSM cameras for ASP.

ScProduct(product_id, cube_url, label_url=None, cube_kbytes=None) dataclass

Cube and PDS4 label URLs of one ShadowCam product.

observation_id property

M013178466S for M013178466SE / M013178466SC.

ScOutputs(product_id, cube, camera=None, cam_test=None, geotiff=None) dataclass

Files written for one product (None for skipped steps).

ScProcessor(output_dir=Path('shadowcam'), *, product='raw', web=False, csm=True, validate=False, mapproject=False, dem=None, resolution=None, t_srs=None, projection=DEFAULT_PROJECTION, keep=False, force=False, spiceinit_params=None)

Download ShadowCam cubes and prepare them for ASP (SPICE + CSM camera).

Follows the ASP 3.7 ShadowCam example: spiceinit on the delivered cube (in place), isd_generate -k <cube> <cube> for the CSM camera and, optionally, cam_test and mapproject. Needs ASP 3.7's custom ISIS / ALE build and the KPLO kernels under $ISISDATA/kplo/kernels (rsync from rsync.im-ldi.com::kplo) plus $ISISDATA/base/kernels.

Per product output_dir gets <id>.cub, <id>.json (when csm), <id>.cam_test.txt (when validate) and <id>.tif (when mapproject). Steps whose output exists (for spiceinit: a cube whose History records it, see has_spice) are skipped unless force.

Parameters:
  • output_dir (Path, default: Path('shadowcam') ) –

    Where cubes, labels and cameras are written.

  • product (str, default: 'raw' ) –

    "raw" (…SE, the cube in ASP's example) or "cal" (…SC, radiometrically calibrated, bias columns removed) for observation IDs.

  • web (bool, default: False ) –

    Use the USGS SPICE web service (it serves the KPLO kernels) in spiceinit. ALE's ShadowCam driver only reads NAIF kernel files, so isd_generate needs the local kernels either way.

  • csm (bool, default: True ) –

    Write a CSM camera with isd_generate.

  • validate (bool, default: False ) –

    Run cam_test (ISIS vs CSM camera) and save its report.

  • mapproject (bool, default: False ) –

    Write a GeoTIFF: ASP mapproject onto dem when given, else ISIS cam2map onto the spiceinit shape.

  • dem (Path, default: None ) –

    DEM for ASP mapproject.

  • resolution (float, default: None ) –

    Map resolution in m/pixel (ASP --tr / cam2map resolution).

  • t_srs (str, default: None ) –

    PROJ string for ASP mapproject (default: the DEM's projection).

  • projection (str, default: DEFAULT_PROJECTION ) –

    ISIS projection for mosrange without dem.

  • keep (bool, default: False ) –

    Keep the ISIS map-projected cube.

  • force (bool, default: False ) –

    Redo every processing step (downloads are always reused).

  • spiceinit_params (dict, default: None ) –

    Overrides merged into SPICEINIT_PARAMS.

process(source)

Download (if needed) and process one product.

source is a ScProduct, a local .cub path or an observation / product ID (looked up on ODE).

process_batch(sources, max_workers=2)

Process several products in parallel (None for failures).

cube_path(product)

Where process downloads product's cube.

process_cube(cube)

Run the SPICE / CSM chain on a downloaded ShadowCam cube.

is_sc_product_id(product_id)

True for a ShadowCam observation (M…S) or product (M…SE / M…SC) ID.

product_id_for(source, product='raw')

Product ID for an observation or product ID.

Parameters:
  • source (str) –

    M013178466S (observation), M013178466SE or M013178466SC.

  • product (str, default: 'raw' ) –

    "raw" (…SE, the cube in ASP's example) or "cal" (…SC); only used for observation IDs.

select_sc_files(files, product_id=None)

Pick the cube and label of a ShadowCam product from its ODE files list.

Parameters:
  • files (iterable of dict) –

    ODE product-file dicts (FileName, Type, URL, KBytes).

  • product_id (str, default: None ) –

    Product ID; derived from the cube file name when omitted.

Returns:
  • ScProduct or None –

    None when the list has no Product .cub (mosaics, DTMs). The map-projected COGs and smear maps (Referenced) are never picked.

sc_products(df)

ShadowCam products with a downloadable cube from an ODE search.

Rows that are not …SE / …SC products (mosaics, DTMs) or lack a cube are skipped with a warning.

lookup_products(product_ids, client=None, product='raw')

Query ODE by observation / product ID (see product_id_for, OdeClient.lookup).

download_product(product, output_dir, force=False, show_progress=True)

Download one product's cube (and PDS4 label) into output_dir.

Existing files are reused unless force; interrupted downloads resume. Returns the cube path.

has_spice(cube)

True when spiceinit completed on cube.

A failed spiceinit can leave SPICE tables in the label, so the cube's History must also record a spiceinit run.

import_sc(cube, output_dir=None, **kwargs)

Process one downloaded ShadowCam cube; see ScProcessor for kwargs.