lunar_toolkit.kaguya

lunar_toolkit.kaguya.tc

Kaguya Terrain Camera Level 2B0: ODE file selection, download and ISIS import.

TcProduct(product_id, image_url, label_url, image_kbytes=None) dataclass

Data and label URLs of one Level 2B0 TC product.

sensor property

"TC1" or "TC2".

TcOutputs(product_id, cube, camera=None, map_cube=None, geotiff=None) dataclass

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

TcProcessor(output_dir=Path('kaguya'), *, web=True, csm=True, only_naif_spice=None, mapproject=False, projection=DEFAULT_PROJECTION, resolution=None, keep=False, force=False, kaguyatc2isis_params=None, spiceinit_params=None)

Download and import Kaguya TC Level 2B0 products into ISIS.

Each product ends up in output_dir as <id>.cub (spiceinit'ed), <id>.json (CSM camera, when csm) and, when mapproject, <id>.tif (GEOTIFF_OPTIONS), the same flat layout and resume / keep / force behaviour as NacProcessor. Steps whose output exists are skipped unless force.

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

    Where labels, images, cubes and cameras are written.

  • web (bool, default: True ) –

    Use the USGS SPICE web service in spiceinit (no local Kaguya kernels needed). Set False when $ISISDATA/kaguya is installed.

  • csm (bool, default: True ) –

    Write a CSM camera with isd_generate.

  • only_naif_spice (bool, default: None ) –

    Pass --only_naif_spice to isd_generate (ASP's recipe; needs local kernels). Default: not web.

  • mapproject (bool, default: False ) –

    Also cam2map the cube and write a GeoTIFF.

  • projection (str, default: DEFAULT_PROJECTION ) –

    ISIS projection for mosrange (default: equirectangular).

  • resolution (float, default: None ) –

    Map resolution in m/pixel (default: mosrange's estimate).

  • keep (bool, default: False ) –

    Keep the PDS .img and the map-projected cube after use.

  • force (bool, default: False ) –

    Redo every step even when its output exists.

  • kaguyatc2isis_params (dict, default: None ) –

    Overrides merged into KAGUYATC2ISIS_PARAMS / SPICEINIT_PARAMS.

  • spiceinit_params (dict, default: None ) –

    Overrides merged into KAGUYATC2ISIS_PARAMS / SPICEINIT_PARAMS.

process(source)

Download (if needed) and import one product.

source is a TcProduct, a local .lbl path or a product ID (looked up on ODE).

process_batch(sources, max_workers=2)

Process several products in parallel (None for failures).

import_label(label)

Run the ISIS chain on a downloaded PDS3 label (image beside it).

is_tc_product_id(product_id)

True for a Level 2B0 TC product ID that kaguyatc2isis can import.

select_tc_files(files, product_id=None)

Pick the data and label files of a TC 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 data file name when omitted.

Returns:
  • TcProduct or None –

    None when the list lacks a .img / .img.gz data file or a .lbl label. An uncompressed .img is preferred over .img.gz.

tc_products(df)

TC products with downloadable data + label files from an ODE search.

Rows that are not Level 2B0 products (DTMs, ortho maps) or lack either file are skipped with a warning.

lookup_products(product_ids, client=None)

Query ODE by product ID and return the observation DataFrame (see OdeClient.lookup).

image_pointer(label)

File name in the label's ^IMAGE pointer (None if attached / absent).

decompress(gz, out=None, remove=False)

Gunzip gz to out (default: name without .gz) via a .part file.

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

Download (and gunzip) one product's label and image into output_dir.

The image is written under the name in the label's ^IMAGE pointer so kaguyatc2isis finds it next to the label. Existing files are reused unless force. Returns the label path.

import_tc(label, output_dir=None, **kwargs)

Import one downloaded TC product; see TcProcessor for kwargs.

lunar_toolkit.kaguya.mi

Kaguya Multiband Imager Level 2B2: ODE file selection, download and ISIS import.

MiProduct(product_id, image_url, label_url, image_kbytes=None) dataclass

Data and label URLs of one Level 2B2 MI product.

sensor property

"VIS" (5 bands) or "NIR" (4 bands).

MiOutputs(product_id, cube, camera=None, map_cube=None, geotiff=None) dataclass

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

MiProcessor(output_dir=Path('kaguya'), *, web=True, csm=None, mapproject=False, projection=DEFAULT_PROJECTION, resolution=None, keep=False, force=False, kaguyami2isis_params=None, spiceinit_params=None)

Download and import Kaguya MI Level 2B2 products into ISIS.

Each product ends up in output_dir as <id>.cub (multi-band, spiceinit'ed), <id>.json (CSM camera, when csm) and, when mapproject, <id>.tif. Steps whose output exists are skipped unless force.

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

    Where labels, images, cubes and cameras are written.

  • web (bool, default: True ) –

    Use the USGS SPICE web service in spiceinit (no local Kaguya kernels needed). Set False when $ISISDATA/kaguya is installed.

  • csm (bool, default: None ) –

    Write a CSM camera with isd_generate. ALE only has NAIF-SPICE MI drivers, which need local kernels, so the default is not web.

  • mapproject (bool, default: False ) –

    Also cam2map the cube and write a GeoTIFF.

  • projection (str, default: DEFAULT_PROJECTION ) –

    ISIS projection for mosrange (default: equirectangular).

  • resolution (float, default: None ) –

    Map resolution in m/pixel (default: mosrange's estimate).

  • keep (bool, default: False ) –

    Keep the PDS .img and the map-projected cube after use.

  • force (bool, default: False ) –

    Redo every step even when its output exists.

  • kaguyami2isis_params (dict, default: None ) –

    Overrides merged into KAGUYAMI2ISIS_PARAMS / SPICEINIT_PARAMS.

  • spiceinit_params (dict, default: None ) –

    Overrides merged into KAGUYAMI2ISIS_PARAMS / SPICEINIT_PARAMS.

process(source)

Download (if needed) and import one product.

source is a MiProduct, a local .lbl path or a product ID (looked up on ODE).

process_batch(sources, max_workers=2)

Process several products in parallel (None for failures).

import_label(label)

Run the ISIS chain on a downloaded PDS3 label (image beside it).

is_mi_product_id(product_id)

True for a Level 2B2 MI product ID that kaguyami2isis can import.

select_mi_files(files, product_id=None)

Pick the data and label files of an MI product from its ODE files list.

MI products have the TC layout (detached .lbl + .img.gz), so this follows select_tc_files.

Returns:
  • MiProduct or None –

    None when the list lacks a .img / .img.gz data file or a .lbl label.

mi_products(df)

MI Level 2B2 products with downloadable data + label files from an ODE search.

Rows that are not Level 2B2 products (2C2, 3C5, maps) or lack either file are skipped with a warning.

lookup_mi_products(product_ids, client=None)

Query ODE by product ID and return the observation DataFrame (see OdeClient.lookup).

download_mi_product(product, output_dir, force=False, keep_gz=False, show_progress=True)

Download (and gunzip) one product's label and image; returns the label path.

See download_product.

import_mi(label, output_dir=None, **kwargs)

Import one downloaded MI product; see MiProcessor for kwargs.