io

io

Open planetary data products with one call.

:func:open inspects a file and returns the most useful in-memory object:

  • Projected rasters (GeoTIFF, ISIS .cub) come back as a georeferenced :class:xarray.DataArray (via :func:rioxarray.open_rasterio).

  • Everything else (PDS3 .IMG/.LBL, PDS4, FITS, …) comes back as a dict-like data handle whose objects you reach by key::

    >>> import planetarypy
    >>> d = planetarypy.open("P02_001916_2221_XI_42N027W.LBL")
    >>> d.keys()
    ['LABEL', 'IMAGE']
    >>> arr = d["IMAGE"]          # numpy array
    >>> d.metaget("LINES")        # label metadata

The routing is automatic but overridable with the projected keyword.

Functions

Name Description
open Open a planetary data product and return it in memory.
read Alias for :func:open (pandas.read_* muscle memory).
read_image Read a projected raster (GeoTIFF / ISIS cube) as an xarray.DataArray.

open

io.open(path, *, projected=None, **kwargs)

Open a planetary data product and return it in memory.

Parameters

Name Type Description Default
path str | os.PathLike Path to a local data product. For detached-label PDS3 products, pass the label (.LBL) — it is the correct entry point. required
projected bool | None Routing control. None (default) auto-detects from the suffix: GeoTIFF / .cub → a georeferenced :class:xarray.DataArray; everything else → the generic multi-object reader. True forces the projected-raster path, False forces the generic reader. None
**kwargs Forwarded to the generic reader (ignored on the projected path). {}

Returns

Name Type Description
xarray.DataArray For projected rasters.
data handle For everything else: a dict-like object where handle.keys() lists the contained objects, handle["IMAGE"] returns a numpy array, handle["TABLE"] a :class:pandas.DataFrame, and handle.metaget(key) reads label metadata.

[source]

read

io.read(path, *, projected=None, **kwargs)

Alias for :func:open (pandas.read_* muscle memory).

[source]

read_image

io.read_image(p)

Read a projected raster (GeoTIFF / ISIS cube) as an xarray.DataArray.

Returns a masked, dask-backed, georeferenced array with x/y axis attributes set (so .hvplot does the right thing automatically).

[source]