pds3_utils
A module of utilities to work with PDS3 data, built on top of pvl.
Dependencies
The following dependencies must be met:
- python 3
- pandas
- pyyaml
- pvl
Installation
pip
pip install pds3_utils
should do the job, although creating a dedicated environment is recommended (see below).
conda
First, clone this repository. If you are using conda, the dependencies can be installed in a new environment using the provided environment file:
conda env create -f environment.yml
The newly created environment can be activated with:
conda activate pds3_utils
Otherwise, please make sure the dependencies are installed with your system package manager, or a tool like pip. Use of a conda environment or virtualenv is recommended!
The package can then be installed with:
python setup.py install
Usage
index_products(directory='.', pattern='*.lbl', recursive=True):
This function loads the labels of products with pattern in directory (recursively if requested) and retrieves key hard-coded meta-data and loads them into a pandas dataframe:
- PRODUCT_ID
- INSTRUMENT_ID
- DATA_SET_ID
- MISSION_ID
- START_TIME
- STOP_TIME
Database (class)
The Database class is used to create one or more tables (pandas DataFrames) from PDS3 meta-data according to a configuration file. This can be retrieved, saved to/loaded from disk and used in later analysis.
This class is instantiated with:
files=None, directory='.', config_file=default_config, recursive=True
where files, directory and recursive are as above. config_file gives the filepath to a YAML formatted file which defines which additional meta-data are retrieved.
The configuration file has a format like:
INSTRUMENT_ID:
table_name:
prod_id: "TEST_RAW"
keywords:
altitude:
path: 'ALTITUDE'
pixel_x:
path: 'IMAGE_POI/IMAGE_POI_PIXEL'
index: 0
pixel_y:
path: 'IMAGE_POI/IMAGE_POI_PIXEL'
index: 1
In this case when using this configuration, any PDS3 products in directory with file pattern files will be checked for INSTRUMENT_ID. For those that match, each table_name entry will be used to defined a unique table built from products with PRODUCT_ID containing prod_id. Keywords then specify fields to be scraped from the labels.
For simple key/pair entries, it is only necessary to specify the keyword (e.g. altitude above) which will be used as the field name in the database, and the path (e.g. ALTITUDE). If the keyword has an attached unit, this wil be ignored and the value used. For keywords that have lists, the index parameter can be used to select which one is mapped into the corresponding field.
Putting this together with a few examples:
SC_TARGET_POSITION_VECTOR = (-23.936 <km>, -43.917 <km>, -31.456 <km>)
to retrieve the 3 components, one would specify something like:
sc_position_x:
path: 'SC_TARGET_POSITION_VECTOR'
index: 0
sc_position_x:
path: 'SC_TARGET_POSITION_VECTOR'
index: 1
sc_position_x:
path: 'SC_TARGET_POSITION_VECTOR'
index: 2
In the case of groups, the input file should use a slash to describe the path, for example:
GROUP = SCIENCE_ACTIVITY
ROSETTA:MISSION_PHASE = ("LTP001", "MTP006", "STP015")
ROSETTA:RATIONALE_DESC = "NUCLEUS"
ROSETTA:OPERATIONAL_ACTIVITY = "TAG_NUCLEUS_SHAPE"
ROSETTA:ACTIVITY_NAME = "STP015_SHAP4S_002"
END_GROUP = SCIENCE_ACTIVITY
to get the mission phase here, one would use:
ltp:
path: 'SCIENCE_ACTIVITY/ROSETTA:ROSETTA:MISSION_PHASE'
index: 0
mtp:
path: 'SCIENCE_ACTIVITY/ROSETTA:ROSETTA:MISSION_PHASE'
index: 1
stp:
path: 'SCIENCE_ACTIVITY/ROSETTA:ROSETTA:MISSION_PHASE'
index: 2
Example
The Jupyter notebook included with this repository shows an example of how to use the code. To view the notebook, click here.
Metadata
Release files for pds3-utils 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pds3_utils-0.1.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pds3_utils-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.5 kB
Release files / pds3_utils-0.1.tar.gz
| Download URL | pds3_utils-0.1.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6912f7695a017ef9ff802f7f7c36a305e6cc01835a51f741f6902ecfb6fcbfb3
|
|
BLAKE2b-256 checksum How to use checksums |
67758613257cb92bfae2f83b045916de6a392de9044484f86bea2e06448fe98a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 8, 2025.
Transparency logRelease files / pds3_utils-0.1-py3-none-any.whl
| Download URL | pds3_utils-0.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c24511606a45fec29bb1bf2de71e7e39ad05d4ce80758a1a5e517574e16fb7e
|
|
BLAKE2b-256 checksum How to use checksums |
66b323c1bad0ea3d5c70791b055257adedb2df56ff26869abd7074742363a30f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 8, 2025.
Transparency log