Skip to main content

Python Tools for Planetary Science

Project description

PlanetaryPy

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 xarray1. 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

from planetarypy.pds.apps import get_index
ctrindex = get_index("mro.ctx.indexes.edr")
ctrindex.sample(5)
<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
75900 MROX_2455 DATA/F20_043687_1325_XN_47S294W.IMG 4A_04_10DC014000 F20_043687_1325_XN_47S294W 2015-11-21 14:14:36.567 CTX NIFL 5056 24576 1 ... 24.04 294.73 -47.57 249238218.9 71.38 15.21 89.2 Hellas Planitia OK 43687
40726 MROX_1392 DATA/G14_023794_1798_XN_00S092W.IMG 4A_04_1076020900 G14_023794_1798_XN_00S092W 2011-08-24 13:13:49.110 CTX NIFL 5056 43008 1 ... -4.36 91.79 -0.23 229203270.8 349.83 14.16 90.4 Terrain north of Tithonium Chasma OK 23794
5325 MROX_0205 DATA/P11_005346_1735_XI_06S063W.IMG 4A_04_1019013500 P11_005346_1735_XI_06S063W 2007-09-17 00:20:29.319 CTX ITL 5056 52224 1 ... -17.67 63.21 -6.51 217090580.2 315.16 14.26 90.2 West Juventae Chasma and Ophir Planum OK 5346
114845 MROX_3635 DATA/N05_064486_1481_XN_31S039W.IMG 4A_04_1146024F00 N05_064486_1481_XN_31S039W 2020-04-29 06:06:04.787 CTX NIFL 3776 8192 1 ... -5.07 39.72 -32.00 215654598.6 191.85 15.94 90.1 Crater north of Argyre OK 64486
44851 MROX_1524 DATA/G20_026030_1390_XN_41S290W.IMG 4A_04_108201CF00 G20_026030_1390_XN_41S290W 2012-02-14 18:31:34.526 CTX NIFL 3776 21504 1 ... 23.91 290.76 -41.05 249226043.2 70.55 15.23 90.2 Hellas Planitia OK 26030

5 rows × 51 columns

hirise_rdr = get_index("mro.hirise.indexes.rdr")
hirise_rdr.sample(5)
<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
124314 MROHR_0001 RDR/ESP/ORB_062500_062599/ESP_062586_1840/ESP_... MRO HIRISE ESP_062586_1840 ESP_062586_1840_RED 1 MARS 62586 Extended Science Phase ... 493636.5 -20081462.0 3.9142 349.5270 3.9017 349.4270 4.1513 349.3930 4.1640 349.4940
112358 MROHR_0001 RDR/ESP/ORB_056900_056999/ESP_056945_1090/ESP_... MRO HIRISE ESP_056945_1090 ESP_056945_1090_COLOR 1 MARS 56945 Extended Science Phase ... 405073.5 2258479.5 -71.0468 280.3410 -71.0497 280.2890 -70.7174 280.1170 -70.7146 280.1680
23249 MROHR_0001 RDR/ESP/ORB_015900_015999/ESP_015916_1640/ESP_... MRO HIRISE ESP_015916_1640 ESP_015916_1640_RED 1 MARS 15916 Extended Science Phase ... -3691490.0 24911000.0 -15.9461 71.3223 -15.9568 71.2317 -15.5863 71.1847 -15.5756 71.2753
126778 MROHR_0001 RDR/ESP/ORB_064500_064599/ESP_064551_1745/ESP_... MRO HIRISE ESP_064551_1745 ESP_064551_1745_RED 1 MARS 64551 Extended Science Phase ... -1267461.5 -38647224.0 -5.4864 343.7370 -5.4974 343.6490 -5.3569 343.6310 -5.3460 343.7190
27793 MROHR_0001 RDR/ESP/ORB_017100_017199/ESP_017182_1380/ESP_... MRO HIRISE ESP_017182_1380 ESP_017182_1380_COLOR 1 MARS 17182 Extended Science Phase ... -4928590.0 9843080.0 -42.0208 71.4254 -42.0228 71.4017 -41.6764 71.3470 -41.6743 71.3705

5 rows × 54 columns

Instrument tools

CTX

from planetarypy.ctx import CTXEDR
pid = ctrindex.sample().squeeze().PRODUCT_ID
pid
'P15_007095_2017_XI_21N299W'
ctxedr = CTXEDR(pid)
ctxedr.local_path
PosixPath('/home/maye/big_drive/planetary_data/mro/ctx/edr/MROX_0403/P15_007095_2017_XI_21N299W/P15_007095_2017_XI_21N299W.IMG')
ctxedr
PRODUCT_ID: P15_007095_2017_XI_21N299W
URL: https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_0403/data/P15_007095_2017_XI_21N299W.IMG
Local: /home/maye/big_drive/planetary_data/mro/ctx/edr/MROX_0403/P15_007095_2017_XI_21N299W/P15_007095_2017_XI_21N299W.IMG
Not downloaded yet.
ctxedr.download()
ctxedr
PRODUCT_ID: P15_007095_2017_XI_21N299W
URL: https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_0403/data/P15_007095_2017_XI_21N299W.IMG
Local: /home/maye/big_drive/planetary_data/mro/ctx/edr/MROX_0403/P15_007095_2017_XI_21N299W/P15_007095_2017_XI_21N299W.IMG
Shape: (1, 35840, 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.17.3.tar.gz (1.5 MB view hashes)

Uploaded Source

Built Distribution

planetarypy-0.17.3-py3-none-any.whl (38.2 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