Skip to main content

Python Tools for Planetary Science

Project description

PlanetaryPy

Potential logo:image.png

Install

pip install planetarypy

This will pull in these other dependencies and their dependencies:

tomlkit pandas pvl numpy python-dateutil tqdm lxml yarl hirise-tools kalasiris

Suggested standard abbreviations:

  • Inside these docs the package will be called PLPY for brevity.
  • A standard Python import could be: plp or plpy
    • because the last p in plp can be pronounced out, we consider these equivalent for human conversation and pronounce these “plippy”.

General scope

First and foremost this package should provide support in working with planetary science data.

With working we mean:

  • locating
  • retrieving
  • reading
  • further processing

of data.

Locating

This library manages, via its PDS tools, multiple PDS3 index files per instrument that can be used for identifying data of interest. These index files are automatically downloaded and converted to the very performant (and cloud-ready) parquet file format. > Parquet is able to store advanced datatypes like nan-capable integer and full datetime objects, as opposed to HDF5.

Retrieving

The interface to getting data is via a path-retrieving function based on a PDS product-id. If that product-id is available locally, the path will be returned. If it is not, it will previously be downloaded, stored in a systematic fashion organized by mission and instrument, and then the local path will be returned.

Reading

For now, the library only returns the path to the object and the user needs to sort out the reading process. A recently funded NASA project Planetary Data Reader will be integrated here, so that basic reading into memory can be provided.

As such, we anticipate two classes of reading support: 1. basic reading into numpy and/or xarray 1. added reader functionality like basic plots and basic geospatial processing, as supported by interested parties

There will exist larger other packages that focus on working with a given instrument’s data, in which case that package could become an affiliated package with the planetarypy GitHub organization, if so desired.

Further processing

In the future, additional frequently used procedures will be added to this library, e.g. * frequently used GDAL/rasterio procedures * frequently used SPICE operations * like surface illumination on a given body

PDS tools

Look at the Apps docs to see what pds.apps exist for easily getting PDS indexes. The find_index app is specifically useful when you don’t know what index files exist.

So far, the following indexes are supported (but not necessarily all tested within PLPY):

  • Cassini
    • ISS (all)
    • UVIS (all)
  • MRO
    • CTX EDR
    • HiRISE
      • EDR, RDR, DTM
        • EDR index has a bug (as delivered by the team, reported), where I need to activate an existing fix for it.
  • LRO
    • Diviner (DLRE)
      • EDR, RDR
    • LOLA
      • EDR, RDR

More indexes

More indexes of other instruments can be easily added by following the existing structure of what has been copied into your config at ~/.planetarypy_config.toml.

Please consider submitting a pull request for adding further PDS index files into the config file at its source: https://github.com/michaelaye/nbplanetary/blob/master/planetarypy/data/planetarypy_config.toml

Utils

Find something in Utils for working with NASA timestamps and a well working URL download function url_retrieve, among other stuff.

Experiment/Instrument Specific

So far, planetarypy supports CTX EDR and HiRISE RGB.NOMAP data. Look at the CTX and HiRISE pages for descriptions of classes for working with these data.

Bug reports

Please submit bug reports at https://github.com/michaelaye/nbplanetary/issues

How to use

Indexes

See PDS apps for more details.

from planetarypy.pds.apps import get_index
ctrindex = get_index("mro.ctx", "edr")
ctrindex.sample(5, random_state=42)  # setting random_state to always get same files for docs
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
VOLUME_ID FILE_SPECIFICATION_NAME ORIGINAL_PRODUCT_ID PRODUCT_ID IMAGE_TIME INSTRUMENT_ID INSTRUMENT_MODE_ID LINE_SAMPLES LINES SPATIAL_SUMMING ... SUB_SOLAR_LATITUDE SUB_SPACECRAFT_LONGITUDE SUB_SPACECRAFT_LATITUDE SOLAR_DISTANCE SOLAR_LONGITUDE LOCAL_TIME IMAGE_SKEW_ANGLE RATIONALE_DESC DATA_QUALITY_DESC ORBIT_NUMBER
33054 MROX_1189 DATA/G01_018691_2639_XN_83N125W.IMG 4A_04_105C021D00 G01_018691_2639_XN_83N125W 2010-07-22 22:26:50.279 CTX NIFL 5056 7168 1 ... 21.37 125.18 83.96 240053143.9 122.10 13.69 89.9 Ride-along with HiRISE OK 18691
93213 MROX_2936 DATA/J18_051799_1768_XN_03S008W.IMG 4A_04_1106006B00 J18_051799_1768_XN_03S008W 2017-08-14 16:52:08.694 CTX NIFL 5056 7168 1 ... 18.43 8.94 -3.30 247073409.4 47.31 14.79 90.1 Ride-along with HiRISE OK 51799
116150 MROX_3682 DATA/N07_065025_2026_XN_22N001W.IMG 4A_04_114A010700 N07_065025_2026_XN_22N001W 2020-06-10 06:19:59.533 CTX NIFL 5056 52224 1 ... -15.04 0.80 22.71 209715242.3 217.08 15.65 89.7 Ride-along with CRISM OK 65025
84411 MROX_2710 DATA/J06_047059_1670_XN_13S194W.IMG 4A_04_10EE015900 J06_047059_1670_XN_13S194W 2016-08-10 07:59:51.331 CTX NIFL 2336 16384 1 ... -9.00 194.58 -13.04 213104117.6 201.30 15.46 90.2 Landforms near Al Qahira Vallis OK 47059
93055 MROX_2931 DATA/J17_051369_1512_XI_28S145W.IMG 4A_04_110500C700 J17_051369_1512_XI_28S145W 2017-07-12 04:36:20.503 CTX ITL 5056 7168 1 ... 13.27 146.43 -28.94 243673970.8 32.23 14.74 90.1 Sirenum Fossae trough cut through landslide de... OK 51369

5 rows × 51 columns

hirise_rdr = get_index("mro.hirise", "rdr")
hirise_rdr.sample(5, random_state=42)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
VOLUME_ID FILE_NAME_SPECIFICATION INSTRUMENT_HOST_ID INSTRUMENT_ID OBSERVATION_ID PRODUCT_ID PRODUCT_VERSION_ID TARGET_NAME ORBIT_NUMBER MISSION_PHASE_NAME ... LINE_PROJECTION_OFFSET SAMPLE_PROJECTION_OFFSET CORNER1_LATITUDE CORNER1_LONGITUDE CORNER2_LATITUDE CORNER2_LONGITUDE CORNER3_LATITUDE CORNER3_LONGITUDE CORNER4_LATITUDE CORNER4_LONGITUDE
17724 MROHR_0001 RDR/PSP/ORB_010500_010599/PSP_010580_2115/PSP_... MRO HIRISE PSP_010580_2115 PSP_010580_2115_RED 2 MARS 10580 Primary Science Phase ... 7363560.0 -25472900.0 30.9561 304.379 30.9448 304.262 31.0917 304.240 31.1030 304.358
2964 MROHR_0001 RDR/PSP/ORB_003500_003599/PSP_003519_0950/PSP_... MRO HIRISE PSP_003519_0950 PSP_003519_0950_RED 2 MARS 3519 Primary Science Phase ... -554006.0 13544.5 -85.2476 181.385 -85.3015 180.594 -85.1038 178.725 -85.0520 179.504
53360 MROHR_0001 RDR/ESP/ORB_028900_028999/ESP_028997_0945/ESP_... MRO HIRISE ESP_028997_0945 ESP_028997_0945_COLOR 1 MARS 28997 Extended Science Phase ... -124310.0 -508464.0 -85.5280 105.028 -85.5372 104.843 -85.2871 102.919 -85.2784 103.098
81502 MROHR_0001 RDR/ESP/ORB_044700_044799/ESP_044724_1480/ESP_... MRO HIRISE ESP_044724_1480 ESP_044724_1480_COLOR 1 MARS 44724 Extended Science Phase ... -3727530.0 -1381090.0 -31.8762 193.542 -31.8781 193.521 -31.4914 193.472 -31.4895 193.493
119683 MROHR_0001 RDR/ESP/ORB_059200_059299/ESP_059292_1310/ESP_... MRO HIRISE ESP_059292_1310 ESP_059292_1310_RED 1 MARS 59292 Extended Science Phase ... -11438078.0 -17117128.0 -48.5358 282.545 -48.5439 282.423 -48.3930 282.401 -48.3849 282.522

5 rows × 54 columns

Instrument tools

CTX

from planetarypy.ctx import CTXEDR
Unable to display output for mime type(s): application/javascript, application/vnd.holoviews_load.v0+json

Unable to display output for mime type(s): application/javascript, application/vnd.holoviews_load.v0+json
<style>.bk-root, .bk-root .bk:before, .bk-root .bk:after { font-family: var(--jp-ui-font-size1); font-size: var(--jp-ui-font-size1); color: var(--jp-ui-font-color1); } </style>
pid = ctrindex.sample(random_state=42).squeeze().PRODUCT_ID
pid
'G01_018691_2639_XN_83N125W'
ctxedr = CTXEDR(pid)
ctxedr.local_path
Path('/home/ayek72/mnt/slowdata/planetarypy/missions/mro/ctx/edr/G01_018691_2639_XN_83N125W/G01_018691_2639_XN_83N125W.IMG')
ctxedr
PRODUCT_ID: G01_018691_2639_XN_83N125W
URL: https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_1189/data/G01_018691_2639_XN_83N125W.IMG
Local: /home/ayek72/mnt/slowdata/planetarypy/missions/mro/ctx/edr/G01_018691_2639_XN_83N125W/G01_018691_2639_XN_83N125W.IMG
Shape: (1, 7168, 5056)
ctxedr.download()
File exists. Use `overwrite=True` to download fresh.
ctxedr
PRODUCT_ID: G01_018691_2639_XN_83N125W
URL: https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_1189/data/G01_018691_2639_XN_83N125W.IMG
Local: /home/ayek72/mnt/slowdata/planetarypy/missions/mro/ctx/edr/G01_018691_2639_XN_83N125W/G01_018691_2639_XN_83N125W.IMG
Shape: (1, 7168, 5056)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

planetarypy-0.22.0.tar.gz (52.9 kB view hashes)

Uploaded Source

Built Distribution

planetarypy-0.22.0-py3-none-any.whl (53.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page