A set of utilities to analyse PDS3 meta-data
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pds3_utils-0.1.tar.gz.
File metadata
- Download URL: pds3_utils-0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6912f7695a017ef9ff802f7f7c36a305e6cc01835a51f741f6902ecfb6fcbfb3
|
|
| MD5 |
4fb0810615f25174321250d706e82ce5
|
|
| BLAKE2b-256 |
67758613257cb92bfae2f83b045916de6a392de9044484f86bea2e06448fe98a
|
Provenance
The following attestation bundles were made for pds3_utils-0.1.tar.gz:
Publisher:
publish-to-pypi.yml on msbentley/pds3_utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pds3_utils-0.1.tar.gz -
Subject digest:
6912f7695a017ef9ff802f7f7c36a305e6cc01835a51f741f6902ecfb6fcbfb3 - Sigstore transparency entry: 193720722
- Sigstore integration time:
-
Permalink:
msbentley/pds3_utils@e572c8d6b5339d59afe04d604554a21012b975e6 -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/msbentley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e572c8d6b5339d59afe04d604554a21012b975e6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pds3_utils-0.1-py3-none-any.whl.
File metadata
- Download URL: pds3_utils-0.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c24511606a45fec29bb1bf2de71e7e39ad05d4ce80758a1a5e517574e16fb7e
|
|
| MD5 |
c77e3546dc5e53e5fa66c4866524cd32
|
|
| BLAKE2b-256 |
66b323c1bad0ea3d5c70791b055257adedb2df56ff26869abd7074742363a30f
|
Provenance
The following attestation bundles were made for pds3_utils-0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on msbentley/pds3_utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pds3_utils-0.1-py3-none-any.whl -
Subject digest:
5c24511606a45fec29bb1bf2de71e7e39ad05d4ce80758a1a5e517574e16fb7e - Sigstore transparency entry: 193720725
- Sigstore integration time:
-
Permalink:
msbentley/pds3_utils@e572c8d6b5339d59afe04d604554a21012b975e6 -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/msbentley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e572c8d6b5339d59afe04d604554a21012b975e6 -
Trigger Event:
release
-
Statement type: