I wrote highly generalized PDS index readers, that wrap the Python Parameter Value Language module PVL (The syntax for Planetary Data System label files). Relevant functions are in https://github.com/michaelaye/planetarypy/blob/master/planetarypy/pdstools.py
But possibly it's more efficient that you just quickly parse the specific data files yourself:
Download cumulative RDR index and label file here:
The label file has the column names for the .TAB file, but in PVL format. The .TAB file is a fixed format text file. You can read out the column names and the column specification (i.e. start and end byte for each column) below, in case you can feed them to a Ruby text parser.
In [6]:
from planetarypy import pdstools as pds
In [7]:
labelfname = '/Users/klay6683/Dropbox/data/hirise/index/RDRCUMINDEX.LBL'
tablefname = '/Users/klay6683/Dropbox/data/hirise/index/RDRCUMINDEX.TAB'
In [8]:
label = pds.IndexLabel(labelfname)
In [9]:
label.colnames
Out[9]:
In [10]:
label.colspecs
Out[10]:
In [13]:
label.index_path
Out[13]:
In [15]:
df = label.read_index_data()
In [16]:
df.info()
I have never seen the data-item "SOUTH_AZIMUTH". Possibly, this was confused with the item called "SUB-SOLAR AZIMUTH"? I put that column in there for now.
In [17]:
list_of_image_names = [
'ESP_040246_0935',
'ESP_039969_0935',
'ESP_039824_0935',
'ESP_039547_0935',
'ESP_039468_0935',
'ESP_038822_0935',
'ESP_038625_0930',
'ESP_038492_0935',
'ESP_038215_0935',
'ESP_038149_0935',
'ESP_038110_0930',
'ESP_037964_0935',
'ESP_040311_0940',
'ESP_040193_0940',
'ESP_037977_0940',
'ESP_037976_0940',
]
In [18]:
df.set_index('OBSERVATION_ID', inplace=True)
In [25]:
data = df.loc[list_of_image_names]
# second line for the fact that lots/all metadata exists for _RED and _COLOR channels
data = data[data.PRODUCT_ID.str.endswith('_COLOR')]
In [26]:
data.info()
In [29]:
# don't really have a center lat/lon in this index, so calculating a rough avg value
data['MEAN_LATITUDE'] = (data.MAXIMUM_LATITUDE + data.MINIMUM_LATITUDE) / 2
data['MEAN_LONGITUDE'] = (data.MAXIMUM_LONGITUDE + data.MINIMUM_LONGITUDE) / 2
In [30]:
translator = {
'acquisition_date': 'START_TIME',
'local_mars_time': 'LOCAL_TIME',
'latitude': 'MEAN_LATITUDE',
'longitude': 'MEAN_LONGITUDE',
'range_to_target': 'TARGET_CENTER_DISTANCE',
'original_image_scale': 'MAP_SCALE',
'emission_angle': 'EMISSION_ANGLE',
'phase_angle': 'PHASE_ANGLE',
'solar_incidence': 'INCIDENCE_ANGLE',
'solar_longitude': 'SOLAR_LONGITUDE',
'north_azimuth': 'NORTH_AZIMUTH',
'south_azimuth': 'SUB_SOLAR_AZIMUTH',
}
In [33]:
output = data[list(translator.values())]
output
Out[33]:
In [34]:
output.to_csv('planet4_metadata.csv')
In [35]:
!open .
In [ ]: