Commit 2f863ff1 authored by Jay's avatar Jay Committed by Jason R Laura
Browse files

ISIS Serial issues with Davinci generated THEMIS

parent 7e49566c
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ def get_isis_translation(label):
                  A PVLModule object containing the extracted
                  translation file
    """

    # Instantiate a DB session if not already instantiated
    if not hasattr(autocnet, 'data_session'):
        autocnet.data_session = setup_db_session(get_data('data.db'))
@@ -35,6 +34,7 @@ def get_isis_translation(label):

    # Grab the spacecraft name and run it through the ISIS lookup
    spacecraft_name = find_in_dict(label, 'SpacecraftName')

    for row in autocnet.data_session.query(StringToMission).filter(StringToMission.key==spacecraft_name):
        spacecraft_name = row.value.lower()

@@ -43,6 +43,7 @@ def get_isis_translation(label):
        instrumentid = find_in_dict(label, 'InstrumentId').capitalize()
    except:
        instrumentid = None

    # Grab the translation PVL object using the lookup
    for row in autocnet.data_session.query(Translations).filter(Translations.mission==spacecraft_name,
                                                                Translations.instrument==instrumentid):
@@ -70,7 +71,6 @@ def generate_serial_number(label):
    """
    if not isinstance(label, PVLModule):
        label = pvl.load(label, cls=SerialNumberDecoder)

    # Get the translation information
    translation = get_isis_translation(label)
    serial_number = []
@@ -78,6 +78,7 @@ def generate_serial_number(label):
    # Sort the keys to ensure proper iteration order
    keys = sorted(translation.keys())
    for k in keys:
        try:
            group = translation[k]
            search_key = group['InputKey']
            search_position = group['InputPosition']
@@ -85,13 +86,15 @@ def generate_serial_number(label):

            sub_group = find_nested_in_dict(label, search_position)
            serial_entry = sub_group[search_key]
            print(serial_entry)
            if serial_entry in search_translation.keys():
                serial_entry = search_translation[serial_entry]
            elif '*' in search_translation.keys() and search_translation['*'] != '*':
                serial_entry = search_translation['*']

            serial_number.append(serial_entry)

        except:pass
    print('HERE!')
    return '/'.join(serial_number)


+1 KiB (53 KiB)

File changed.

No diff preview for this file type.