def safe_pdstable_read(filename): preprocess_label_func = None preprocess_table_func = None # for (set_search, set_preprocess_label, # set_preprocess_table) in instruments.PDSTABLE_PREPROCESS: # if re.fullmatch(set_search, filename.upper()): # preprocess_label_func = set_preprocess_label # preprocess_table_func = set_preprocess_table replacements = {} for set_search, set_replacements in instruments.PDSTABLE_REPLACEMENTS: if re.fullmatch(set_search, filename.upper()): replacements = set_replacements break try: if preprocess_label_func is None: table = pdstable.PdsTable(filename, replacements=replacements, table_callback=preprocess_table_func) else: lines = pdsparser.PdsLabel.load_file(filename) lines = preprocess_label_func(lines) table = pdstable.PdsTable(filename, label_contents=lines, replacements=replacements, table_callback=preprocess_table_func) except KeyboardInterrupt: raise except: msg = f'Exception during reading of "{filename}"' if not impglobals.ARGUMENTS.log_suppress_traceback: msg += ':\n' + traceback.format_exc() impglobals.LOGGER.log('error', msg) return None, None if log_accumulated_warnings(f'table import of {filename}'): return None, None rows = table.dicts_by_row() label = table.info.label.as_dict() return rows, label
import julian import pdstable if len(sys.argv) != 4: print( 'Usage: python corss.py <profile_index.lbl> <vol_root> <supp_index.lbl>' ) sys.exit(-1) profile_index_filename = sys.argv[1] vol_root = sys.argv[2] print(vol_root) supp_index_label_filename = sys.argv[3] supp_index_tab_filename = supp_index_label_filename.replace('.lbl', '.tab') profile_index_table = pdstable.PdsTable(profile_index_filename) profile_rows = profile_index_table.dicts_by_row() profile_label = profile_index_table.info.label.as_dict() tol_fp = open('Final-Cassini-TOL.txt', 'r') tol_fp.readline() # Header tol_list = [] while True: line = tol_fp.readline().strip() if line == '': break fields = line.split('\t') obs_id = fields[0] if (not obs_id.startswith('RSS') or not obs_id.endswith('PRIME') or not 'OCC' in obs_id):
import os,sys import pdsparser import pdstable HOLDINGS = '/Volumes/pdsdata-offsite/holdings/' ROOT = HOLDINGS + 'volumes/COUVIS_8xxx/COUVIS_8001/data/' INDEX = HOLDINGS + 'metadata/COUVIS_8xxx/COUVIS_8001/COUVIS_8001_supplemental_index.tab' RAW_DICTS = pdstable.PdsTable( HOLDINGS + 'metadata/COUVIS_0xxx/COUVIS_0999/COUVIS_0999_index.lbl', columns = ['FILE_NAME', 'INTEGRATION_DURATION']).dicts_by_row() DURATIONS_VS_LBL = {os.path.basename(d['FILE_NAME']):d['INTEGRATION_DURATION'] for d in RAW_DICTS if 'HSP' in d['FILE_NAME']} SUPP_DICTS = pdstable.PdsTable( HOLDINGS + 'metadata/COUVIS_0xxx/COUVIS_0999/COUVIS_0999_supplemental_index.lbl', columns = ['FILE_SPECIFICATION_NAME', 'OBSERVATION_ID']).dicts_by_row() DURATIONS_VS_OBSID = {} for d in SUPP_DICTS: lbl = os.path.basename(d['FILE_SPECIFICATION_NAME']) if 'HSP' not in lbl: continue obsid = d['OBSERVATION_ID'] duration = DURATIONS_VS_LBL[lbl] if obsid in DURATIONS_VS_OBSID: DURATIONS_VS_OBSID[obsid].append(duration)