From a1450ccbc7a6478f73ea74ea81b62a350714c154 Mon Sep 17 00:00:00 2001 From: Amy Stamile Date: Tue, 25 May 2021 09:34:53 -0700 Subject: [PATCH 1/2] Updates to cassis template. Corrections to isisimport to allow module tests to work properly. --- isis/appdata/import/cassis.lbl.tpl | 532 ++++++++++++++----- isis/src/base/apps/isisimport/isisimport.cpp | 100 +++- 2 files changed, 506 insertions(+), 126 deletions(-) diff --git a/isis/appdata/import/cassis.lbl.tpl b/isis/appdata/import/cassis.lbl.tpl index 9c64a9b5e7..126b7e204f 100644 --- a/isis/appdata/import/cassis.lbl.tpl +++ b/isis/appdata/import/cassis.lbl.tpl @@ -1,151 +1,443 @@ +{% set PO=Product_Observational %} +{% set CassHeader="Product_Observational.CaSSIS_Header" %} +{% set IdArea="Product_Observational.Identification_Area" %} +{% set FileArea="Product_Observational.File_Area_Observational" %} +{% set threeDArray="Product_Observational.File_Area_Observational.Array_3D_Image" %} +{% set cart="Product_Observational.Observation_Area.Discipline_Area.cart_Cartography" %} + Object = IsisCube Object = Core - StartByte = 65537 - Format = Tile - TileSamples = 512 - TileLines = 280 + {% if exists(threeDArray) %} + Group = Dimensions + Samples = {{ PO.File_Area_Observational.Array_3D_Image.Axis_Array.0.elements }} + Lines = {{ PO.File_Area_Observational.Array_3D_Image.Axis_Array.1.elements }} + Bands = {% if exists(FileArea + ".Array_3D_Image.Axis_Array.2.elements") %} + {{ PO.File_Area_Observational.Array_3D_Image.Axis_Array.2.elements }} + {% else %} + 1 + {% endif %} + End_Group + + Group = Pixels + {% if exists("Product_Observational.File_Area_Observational.Array_3D_Image.Element_Array.idl_data_type") %} + {% set type=PO.File_Area_Observational.Array_3D_Image.Element_Array.idl_data_type %} + Type = {% if type == "1" %} UnsignedByte + {% else if type == "2" %} SignedWord + {% else if type == "3" %} SignedInteger + {% else if type == "4" or type == "5" %} Real + {% else if type == "12" %} UnsignedWord + {% else if type == "13" %} UnsignedInteger + {% else if type == "14" %} SignedInteger + {% else if type == "14" %} UnsignedInteger + {% endif %} + {% else %} + Type = Real + {% endif %} + ByteOrder = Lsb + + Base = {% if exists("Product_Observational.File_Area_Observational.Array_3D_Image.Element_Array.offset") %} + {{ PO.File_Area_Observational.Array_3D_Image.Element_Array.offset }} + {% else %} + {{ PO.File_Area_Observational.Array_3D_Image.Element_Array.value_offset }} + {% endif %} + Multiplier = {{ PO.File_Area_Observational.Array_3D_Image.Element_Array.scaling_factor }} + End_Group + {% else %} Group = Dimensions - Samples = {{Product_Observational.File_Area_Observational.Array_2D_Image.Axis_Array.0.elements}} - Lines = {{Product_Observational.File_Area_Observational.Array_2D_Image.Axis_Array.1.elements}} - Bands = {%if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Axis_Array.2.elements")%}{{Product_Observational.File_Area_Observational.Array_2D_Image.Axis_Array.2.elements}}{%else%}1{%endif%} + Samples = {{ PO.File_Area_Observational.Array_2D_Image.Axis_Array.0.elements }} + Lines = {{ PO.File_Area_Observational.Array_2D_Image.Axis_Array.1.elements }} + Bands = {% if exists(FileArea + ".Array_2D_Image.Axis_Array.2.elements") %} + {{ PO.File_Area_Observational.Array_2D_Image.Axis_Array.2.elements }} + {% else %} + 1 + {% endif %} End_Group Group = Pixels + {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.idl_data_type") %} + {% set type=PO.File_Area_Observational.Array_2D_Image.Element_Array.idl_data_type %} + Type = {% if type == "1" %} UnsignedByte + {% else if type == "2" %} SignedWord + {% else if type == "3" %} SignedInteger + {% else if type == "4" or type == "5" %} Real + {% else if type == "12" %} UnsignedWord + {% else if type == "13" %} UnsignedInteger + {% else if type == "14" %} SignedInteger + {% else if type == "14" %} UnsignedInteger + {% endif %} + {% else %} Type = Real + {% endif %} ByteOrder = Lsb - Base = 0.0 - Multiplier = 1.0 + Base = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.offset") %} + {{ PO.File_Area_Observational.Array_2D_Image.Element_Array.offset }} + {% else %} + {{ PO.File_Area_Observational.Array_2D_Image.Element_Array.value_offset }} + {% endif %} + Multiplier = {{ PO.File_Area_Observational.Array_2D_Image.Element_Array.scaling_factor }} End_Group End_Object + {% endif %} Group = Instrument - SpacecraftName = {%if exists("Product_Observational.Observation_Area.Investigation_Area.name")%} "{{Product_Observational.Observation_Area.Investigation_Area.name}}"{%else%}"{{Product_Observational.Observation_Area.Investigation_Area.Instrument_Host_Name}}"{%endif%} - InstrumentId = {{Product_Observational.Observation_Area.Observing_System.Observing_System_Component.1.name}} - TargetName = {%if exists("Product_Observational.Observation_Area.Target_Identification.name")%}{{Product_Observational.Observation_Area.Target_Identification.name}}{%else%}{{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.TARGET}}{%endif%} - StartTime = {%if exists("Product_Observational.Observation_Area.Time_Coordinates.start_date_time")%}{{Product_Observational.Observation_Area.Time_Coordinates.start_date_time}}{%else%}{{Product_Observational.CaSSIS_Header.DERIVED_HEADER_DATA.OnboardImageAcquisitionTime._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}SpacecraftClockStartCount = {{Product_Observational.CaSSIS_Header.FSW_HEADER.attrib_ExposureTimestamp}}{%endif%} - ExposureDuration = {%if exists("Product_Observational.Observation_Area.Discipline_Area.img_Imaging")%}{{Product_Observational.Observation_Area.Discipline_Area.img_Imaging.img_Imaging_Instrument_Parameters.img_exposure_duration._text}}{%else%}{{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Exposure_Time}}{%endif%} - Filter = {%if exists("Product_Observational.Observation_Area.Discipline_Area.img_Imaging")%}{{Product_Observational.Observation_Area.Discipline_Area.img_Imaging.img_Image_Product_Information.img_Filter.img_filter_name}}{%else%}{{Product_Observational.CaSSIS_Header.DERIVED_HEADER_DATA.Filter._text}}{%endif%} - Expanded = {%if exists("Product_Observational.CaSSIS_Header")%}{{Product_Observational.CaSSIS_Header.DERIVED_HEADER_DATA.Expanded._text}}{%else%}1{%endif%} - SummingMode = 0 + SpacecraftName = {% if exists("Product_Observational.Observation_Area.Investigation_Area.name") %} + "{{ PO.Observation_Area.Investigation_Area.name }}" + {% else %} + "{{ PO.Observation_Area.Investigation_Area.Instrument_Host_Name }}" + {% endif %} + InstrumentId = {{ PO.Observation_Area.Observing_System.Observing_System_Component.1.name }} + TargetName = {% if exists("Product_Observational.Observation_Area.Target_Identification.name") %} + {{ PO.Observation_Area.Target_Identification.name }} + {% else %} + {{ PO.CaSSIS_Header.GEOMETRIC_DATA.TARGET }} + {% endif %} + StartTime = {% if exists("Product_Observational.Observation_Area.Time_Coordinates.start_date_time") %} + {{ PO.Observation_Area.Time_Coordinates.start_date_time }} + {% else %} + {{ PO.CaSSIS_Header.DERIVED_HEADER_DATA.OnboardImageAcquisitionTime._text }} + {% endif %} + {% if exists(CassHeader) %} + SpacecraftClockStartCount = {{ PO.CaSSIS_Header.FSW_HEADER.attrib_ExposureTimestamp }} + {% endif %} + ExposureDuration = {% if exists("Product_Observational.Observation_Area.Discipline_Area.img_Imaging") %} + {{ PO.Observation_Area.Discipline_Area.img_Imaging.img_Imaging_Instrument_Parameters.img_exposure_duration._text }} + {% else %} + {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Exposure_Time }} + {% endif %} + Filter = {% if exists("Product_Observational.Observation_Area.Discipline_Area.img_Imaging") %} + {{ PO.Observation_Area.Discipline_Area.img_Imaging.img_Image_Product_Information.img_Filter.img_filter_name }} + {% else %} {{ PO.CaSSIS_Header.DERIVED_HEADER_DATA.Filter._text }} + {% endif %} + Expanded = {% if exists(CassHeader) %} + {% set expanded=int(PO.CaSSIS_Header.DERIVED_HEADER_DATA.Expanded._text) %} + {{ PO.CaSSIS_Header.DERIVED_HEADER_DATA.Expanded._text }} + {% else %} + 1 + {% set expanded=1 %} + {% endif %} + SummingMode = {% if expanded == 1 %} + 0 + {% else %} + Window{{ PO.CaSSIS_Header.FSW_HEADER.attrib_WindowCounter }}Binning + {% endif %} End_Group Group = Archive - {%if exists("Product_Observational.Identification_Area.Alias_List")%}ObservationId = {{Product_Observational.Identification_Area.Alias_List.Alias.alternate_id}}{%endif%} - DataSetId = {{Product_Observational.Identification_Area.logical_identifier}} - {%if exists("Product_Observational.Identification_Area.version_id")%}ProductVersionId = {{Product_Observational.Identification_Area.version_id}}{%endif%} - {%if exists("Product_Observational.Identification_Area.Producer_data")%}ProducerId = {{Product_Observational.Identification_Area.Producer_data.Producer_id}}{%endif%} - {%if exists("Product_Observational.Identification_Area.Producer_data")%}ProducerName = "{{Product_Observational.Identification_Area.Producer_data.Producer_full_name}}"{%endif%} - {%if exists("Product_Observational.File_Area_Observational.File.creation_date_time")%}ProductCreationTime = {{Product_Observational.File_Area_Observational.File.creation_date_time}}{%endif%} - FileName = {{Product_Observational.File_Area_Observational.File.file_name}} - ScalingFactor = {{Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.scaling_factor}} - {%if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.offset")%}Offset = {{Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.offset}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PredictMaximumExposureTime = {{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.PREDICTED_MAXIMUM_EXPOSURE_TIME._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}CassisOffNadirAngle = {{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.CASSIS_OFF_NADIR_ANGLE._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PredictedRepetitionFrequency = {{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.PREDICTED_REQUIRED_REPETITION_FREQUENCY._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}GroundTrackVelocity = {{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.TGO_GROUND_TRACK_VELOCITY._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ForwardRotationAngle = {{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.FORWARD_ROTATION_ANGLE_REQUIRED._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}SpiceMisalignment = {{Product_Observational.CaSSIS_Header.GEOMETRIC_DATA.SPICE_KERNEL_MISALIGNMENT_PREDICT._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}FocalLength = {{Product_Observational.CaSSIS_Header.CaSSIS_General.TELESCOPE_FOCAL_LENGTH._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}FNumber = {{Product_Observational.CaSSIS_Header.CaSSIS_General.TELESCOPE_F_NUMBER}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ExposureTimeCommand = {{Product_Observational.CaSSIS_Header.IMAGE_COMMAND.T_exp._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}FrameletNumber = {{Product_Observational.CaSSIS_Header.FSW_HEADER.attrib_SequenceCounter}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}NumberOfFramelets = {{Product_Observational.CaSSIS_Header.IMAGE_COMMAND.Num_exp._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ImageFrequency = {{Product_Observational.CaSSIS_Header.IMAGE_COMMAND.Step_exp._text}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}NumberOfWindows = {{Product_Observational.CaSSIS_Header.IMAGE_COMMAND.Num_win._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header.hasSymbol")%}UniqueIdentifier = {{Product_Observational.CaSSIS_Header.IMAGE_COMMAND.Unique_Identifier._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}UID = {{Product_Observational.CaSSIS_Header.FSW_HEADER.attrib_UID}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ExposureTimestamp = {{Product_Observational.CaSSIS_Header.FSW_HEADER.attrib_ExposureTimestamp}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ExposureTimePEHK = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Exposure_Time}} {%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PixelsPossiblySaturated = {{Product_Observational.CaSSIS_Header.DERIVED_HEADER_DATA.PixelsPossiblySaturated._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}IFOV = {{Product_Observational.CaSSIS_Header.CaSSIS_General.INSTRUMENT_IFOV._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}IFOVUnit = {{Product_Observational.CaSSIS_Header.CaSSIS_General.INSTRUMENT_IFOV.attrib_Unit}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}FiltersAvailable = "{{Product_Observational.CaSSIS_Header.CaSSIS_General.FILTERS_AVAILABLE}}"{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}FocalLength = {{Product_Observational.CaSSIS_Header.CaSSIS_General.TELESCOPE_FOCAL_LENGTH._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}FocalLengthUnit = {{Product_Observational.CaSSIS_Header.CaSSIS_General.TELESCOPE_FOCAL_LENGTH.attrib_Unit}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}TelescopeFNumber = {{Product_Observational.CaSSIS_Header.CaSSIS_General.TELESCOPE_F_NUMBER}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}TelescopeType = "{{Product_Observational.CaSSIS_Header.CaSSIS_General.TELESCOPE_TYPE}}"{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}DetectorDescription = "{{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_DESC}}"{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PixelHeight = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_HEIGHT._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PixelHeightUnit = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_HEIGHT.attrib_Unit}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PixelWidth = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_WIDTH._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}PixelWidthUnit = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_WIDTH.attrib_Unit}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}DetectorType = "{{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_TYPE}}"{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ReadNoise = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_READ_NOISE._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}ReadNoiseUnit = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_READ_NOISE.attrib_Unit}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}MissionPhase = {{Product_Observational.CaSSIS_Header.DERIVED_HEADER_DATA.MissionPhase._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}SubInstrumentIdentifier = {{Product_Observational.CaSSIS_Header.CaSSIS_General.DETECTOR_READ_NOISE._text}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}WindowCount = {{Product_Observational.CaSSIS_Header.FSW_HEADER.attrib_WindowCounter}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window1Binning = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_1}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window1StartSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window1_Start_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window1EndSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window1_End_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window1StartLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window1_Start_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window1EndLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window1_End_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window2Binning = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_2}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window2StartSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window2_Start_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window2EndSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window2_End_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window2StartLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window2_Start_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window2EndLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window2_End_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window3Binning = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_3}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window3StartSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window3_Start_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window3EndSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window3_End_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window3StartLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window3_Start_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window3EndLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window3_End_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window4Binning = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_4}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window4StartSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window4_Start_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window4EndSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window4_End_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window4StartLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window4_Start_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window4EndLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window4_End_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window5Binning = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_5}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window5StartSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window5_Start_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window5EndSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window5_End_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window5StartLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window5_Start_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window5EndLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window5_End_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window6Binning = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_6}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window6StartSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window6_Start_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window6EndSample = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window6_End_Col}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window6StartLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window6_Start_Row}}{%endif%} - {%if exists("Product_Observational.CaSSIS_Header")%}Window6EndLine = {{Product_Observational.CaSSIS_Header.PEHK_HEADER.attrib_Window6_End_Row}}{%endif%} + {% if exists(IdArea + ".Alias_List") %} + ObservationId = {{ PO.Identification_Area.Alias_List.Alias.alternate_id }} + {% endif %} + DataSetId = {{ PO.Identification_Area.logical_identifier }} + {% if exists(IdArea + ".version_id") %} + ProductVersionId = {{ PO.Identification_Area.version_id }} + {% endif %} + {% if exists(IdArea + ".Producer_data") %} + ProducerId = {{ PO.Identification_Area.Producer_data.Producer_id }} + {% endif %} + {% if exists(IdArea + ".Producer_data") %} + ProducerName = "{{ PO.Identification_Area.Producer_data.Producer_full_name }}" + {% endif %} + {% if exists(IdArea + ".Product_Id") %} + ProductId = "{{ PO.Identification_Area.Product_Id }}" + {% endif %} + {% if exists(FileArea + ".File.creation_date_time") %} + ProductCreationTime = {{ PO.File_Area_Observational.File.creation_date_time }} + {% endif %} + FileName = {{ PO.File_Area_Observational.File.file_name }} + ScalingFactor = {{ PO.File_Area_Observational.Array_2D_Image.Element_Array.scaling_factor }} + {% if exists(FileArea + ".Array_2D_Image.Element_Array.offset") %} + Offset = {{ PO.File_Area_Observational.Array_2D_Image.Element_Array.offset }} + {% endif %} + {% if exists(CassHeader) %} + PredictMaximumExposureTime = {{ PO.CaSSIS_Header.GEOMETRIC_DATA.PREDICTED_MAXIMUM_EXPOSURE_TIME._text }} + {% endif %} + {% if exists(CassHeader) %} + CassisOffNadirAngle = {{ PO.CaSSIS_Header.GEOMETRIC_DATA.CASSIS_OFF_NADIR_ANGLE._text }} + {% endif %} + {% if exists(CassHeader) %} + PredictedRepetitionFrequency = {{ PO.CaSSIS_Header.GEOMETRIC_DATA.PREDICTED_REQUIRED_REPETITION_FREQUENCY._text }} + {% endif %} + {% if exists(CassHeader) %} + GroundTrackVelocity = {{ PO.CaSSIS_Header.GEOMETRIC_DATA.TGO_GROUND_TRACK_VELOCITY._text }} + {% endif %} + {% if exists(CassHeader) %} + ForwardRotationAngle = {{ PO.CaSSIS_Header.GEOMETRIC_DATA.FORWARD_ROTATION_ANGLE_REQUIRED._text }} + {% endif %} + {% if exists(CassHeader) %} + SpiceMisalignment = {{ PO.CaSSIS_Header.GEOMETRIC_DATA.SPICE_KERNEL_MISALIGNMENT_PREDICT._text }} + {% endif %} + {% if exists(CassHeader) %} + FocalLength = {{ PO.CaSSIS_Header.CaSSIS_General.TELESCOPE_FOCAL_LENGTH._text }} + {% endif %} + {% if exists(CassHeader) %} + FNumber = {{ PO.CaSSIS_Header.CaSSIS_General.TELESCOPE_F_NUMBER }} + {% endif %} + {% if exists(CassHeader) %} + ExposureTimeCommand = {{ PO.CaSSIS_Header.IMAGE_COMMAND.T_exp._text }} + {% endif %} + {% if exists(CassHeader) %} + FrameletNumber = {{ PO.CaSSIS_Header.FSW_HEADER.attrib_SequenceCounter }} + {% endif %} + {% if exists(CassHeader) %} + NumberOfFramelets = {{ PO.CaSSIS_Header.IMAGE_COMMAND.Num_exp._text }} + {% endif %} + {% if exists(CassHeader) %} + ImageFrequency = {{ PO.CaSSIS_Header.IMAGE_COMMAND.Step_exp._text }} + {% endif %} + {% if exists(CassHeader) %} + NumberOfWindows = {{ PO.CaSSIS_Header.IMAGE_COMMAND.Num_win._text }} + {% endif %} + {% if exists(CassHeader + ".IMAGE_COMMAND") %} + UniqueIdentifier = {{ PO.CaSSIS_Header.IMAGE_COMMAND.Unique_Identifier._text }} + {% endif %} + {% if exists(CassHeader) %} + UID = {{ PO.CaSSIS_Header.FSW_HEADER.attrib_UID }} + {% endif %} + {% if exists(CassHeader) %} + ExposureTimestamp = {{ PO.CaSSIS_Header.FSW_HEADER.attrib_ExposureTimestamp }} + {% endif %} + {% if exists(CassHeader) %} + ExposureTimePEHK = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Exposure_Time }} + {% endif %} + {% if exists(CassHeader + ".DERIVED_HEADER_DATA.PixelsPossiblySaturated") %} + PixelsPossiblySaturated = {{ PO.CaSSIS_Header.DERIVED_HEADER_DATA.PixelsPossiblySaturated._text }} + {% endif %} + {% if exists(CassHeader) %} + IFOV = {{ PO.CaSSIS_Header.CaSSIS_General.INSTRUMENT_IFOV._text }} + {% endif %} + {% if exists(CassHeader) %} + IFOVUnit = {{ PO.CaSSIS_Header.CaSSIS_General.INSTRUMENT_IFOV.attrib_Unit }} + {% endif %} + {% if exists(CassHeader) %} + FiltersAvailable = "{{ PO.CaSSIS_Header.CaSSIS_General.FILTERS_AVAILABLE }}" + {% endif %} + {% if exists(CassHeader) %} + FocalLengthUnit = {{ PO.CaSSIS_Header.CaSSIS_General.TELESCOPE_FOCAL_LENGTH.attrib_Unit }} + {% endif %} + {% if exists(CassHeader) %} + TelescopeType = "{{ PO.CaSSIS_Header.CaSSIS_General.TELESCOPE_TYPE }}" + {% endif %} + {% if exists(CassHeader) %} + DetectorDescription = "{{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_DESC }}"{% endif %} + {% if exists(CassHeader) %} + PixelHeight = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_HEIGHT._text }}{% endif %} + {% if exists(CassHeader) %} + PixelHeightUnit = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_HEIGHT.attrib_Unit }}{% endif %} + {% if exists(CassHeader) %} + PixelWidth = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_WIDTH._text }}{% endif %} + {% if exists(CassHeader) %} + PixelWidthUnit = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_PIXEL_WIDTH.attrib_Unit }}{% endif %} + {% if exists(CassHeader) %} + DetectorType = "{{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_TYPE }}" + {% endif %} + {% if exists(CassHeader) %} + ReadNoise = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_READ_NOISE._text }} + {% endif %} + {% if exists(CassHeader) %} + ReadNoiseUnit = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_READ_NOISE.attrib_Unit }} + {% endif %} + {% if exists(CassHeader) %} + MissionPhase = {{ PO.CaSSIS_Header.DERIVED_HEADER_DATA.MissionPhase._text }} + {% endif %} + {% if exists(CassHeader) %} + SubInstrumentIdentifier = {{ PO.CaSSIS_Header.CaSSIS_General.DETECTOR_READ_NOISE._text }} + {% endif %} + {% if exists(CassHeader) %} + WindowCount = {{ PO.CaSSIS_Header.FSW_HEADER.attrib_WindowCounter }} + {% endif %} + {% if exists(CassHeader) %} + Window1Binning = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_1 }} + {% endif %} + {% if exists(CassHeader) %} + Window1StartSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_Start_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window1EndSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_End_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window1StartLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_Start_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window1EndLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_End_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window2Binning = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_2 }} + {% endif %} + {% if exists(CassHeader) %} + Window2StartSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_Start_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window2EndSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_End_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window2StartLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_Start_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window2EndLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_End_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window3Binning = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_3 }} + {% endif %} + {% if exists(CassHeader) %} + Window3StartSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_Start_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window3EndSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_End_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window3StartLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_Start_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window3EndLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_End_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window4Binning = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_4 }} + {% endif %} + {% if exists(CassHeader) %} + Window4StartSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_Start_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window4EndSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_End_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window4StartLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_Start_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window4EndLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_End_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window5Binning = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_5 }} + {% endif %} + {% if exists(CassHeader) %} + Window5StartSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_Start_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window5EndSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_End_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window5StartLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_Start_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window5EndLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_End_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window6Binning = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Binning_window_6 }} + {% endif %} + {% if exists(CassHeader) %} + Window6StartSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_Start_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window6EndSample = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_End_Col }} + {% endif %} + {% if exists(CassHeader) %} + Window6StartLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_Start_Row }} + {% endif %} + {% if exists(CassHeader) %} + Window6EndLine = {{ PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_End_Row }} + {% endif %} End_Group Group = BandBin - FilterName = PAN - Center = 675 - Width = 250 - NaifIkCode = -143421 + {% if exists("Product_Observational.Observation_Area.Discipline_Area.img_Imaging") %} + {% set filterName=Product_Observational.Observation_Area.Discipline_Area.img_Imaging.img_Image_Product_Information.img_Filter.img_filter_name %} + {% else %} + {% set filterName=Product_Observational.CaSSIS_Header.DERIVED_HEADER_DATA.Filter._text %} + {% endif %} + FilterName = {{ filterName }} + Center = {% if filterName == "RED" %} 835.4 + {% else if filterName == "PAN" %} 677.4 + {% else if filterName == "NIR" %} 940.2 + {% else if filterName == "BLU" %} 497.4 + {% endif %} + Width = {% if filterName == "RED" %} 98.0 + {% else if filterName == "PAN" %} 231.5 + {% else if filterName == "NIR" %} 120.6 + {% else if filterName == "BLU" %} 134.3 + {% endif %} + NaifIkCode = {% if filterName == "RED" %} -143422 + {% else if filterName == "PAN" %} -143421 + {% else if filterName == "NIR" %} -143423 + {% else if filterName == "BLU" %} -143424 + {% else %} -143400{% endif %} End_Group Group = Kernels NaifFrameCode = -143400 End_Group + {% if exists(cart) %} + Group = Mapping + ProjectionName = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Map_Projection.cart_map_projection_name }} + CenterLongitude = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Map_Projection.cart_Equirectangular.cart_longitude_of_central_meridian }} + CenterLatitude = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Map_Projection.cart_Equirectangular.cart_latitude_of_projection_origin }} + Scale = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Planar_Coordinate_Information.cart_Coordinate_Representation.cart_pixel_scale_x }} + PixelResolution = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Planar_Coordinate_Information.cart_Coordinate_Representation.cart_pixel_resolution_x }} + MaximumLatitude = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Domain.cart_Bounding_Coordinates.cart_north_bounding_coordinate }} + MinimumLatitude = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Domain.cart_Bounding_Coordinates.cart_south_bounding_coordinate }} + MaximumLongitude = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Domain.cart_Bounding_Coordinates.cart_west_bounding_coordinate }} + MinimumLongitude = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Domain.cart_Bounding_Coordinates.cart_east_bounding_coordinate }} + UpperLeftCornerX = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Geo_Transformation.cart_upperleft_corner_x }} + UpperLeftCornerY = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Planar.cart_Geo_Transformation.cart_upperleft_corner_y }} + EquatorialRadius = {% if exists(cart + ".cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Geodetic_Model.cart_semi_major_radius") %} + {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Geodetic_Model.cart_semi_major_radius }} + {% endif %} + PolarRadius = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Geodetic_Model.cart_polar_radius }} + LatitudeType = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Geodetic_Model.cart_latitude_type }} + LongitudeDirection = {{ PO.Observation_Area.Discipline_Area.cart_Cartography.cart_Spatial_Reference_Information.cart_Horizontal_Coordinate_System_Definition.cart_Geodetic_Model.cart_longitude_direction }} + TargetName = {{ PO.Observation_Area.Target_Identification.name }} + LongitudeDomain = 360 + End_Group + {% endif %} + + {% if exists(CassHeader) %} + {% set windowNumber=int(PO.CaSSIS_Header.FSW_HEADER.attrib_WindowCounter) + 1 %} + {% if windowNumber == 1 %} + {% set frameletStartSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_Start_Col) + 1 %} + {% set frameletEndSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_End_Col) + 1 %} + {% set frameletStartLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_Start_Row) + 1 %} + {% set frameletEndLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window1_End_Row) + 1 %} + {% endif %} + {% if windowNumber == 2 %} + {% set frameletStartSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_Start_Col) + 1 %} + {% set frameletEndSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_End_Col) + 1 %} + {% set frameletStartLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_Start_Row) + 1 %} + {% set frameletEndLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window2_End_Row) + 1 %} + {% endif %} + {% if windowNumber == 3 %} + {% set frameletStartSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_Start_Col) + 1 %} + {% set frameletEndSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_End_Col) + 1 %} + {% set frameletStartLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_Start_Row) + 1 %} + {% set frameletEndLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window3_End_Row) + 1 %} + {% endif %} + {% if windowNumber == 4 %} + {% set frameletStartSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_Start_Col) + 1 %} + {% set frameletEndSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_End_Col) + 1 %} + {% set frameletStartLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_Start_Row) + 1 %} + {% set frameletEndLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window4_End_Row) + 1 %} + {% endif %} + {% if windowNumber == 5 %} + {% set frameletStartSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_Start_Col) + 1 %} + {% set frameletEndSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_End_Col) + 1 %} + {% set frameletStartLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_Start_Row) + 1 %} + {% set frameletEndLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window5_End_Row) + 1 %} + {% endif %} + {% if windowNumber == 6 %} + {% set frameletStartSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_Start_Col) + 1 %} + {% set frameletEndSample = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_End_Col) + 1 %} + {% set frameletStartLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_Start_Row) + 1 %} + {% set frameletEndLine = int(PO.CaSSIS_Header.PEHK_HEADER.attrib_Window6_End_Row) + 1 %} + {% endif %} + Group = AlphaCube AlphaSamples = 2048 AlphaLines = 2048 - AlphaStartingSample = 0.5 - AlphaStartingLine = 354.5 - AlphaEndingSample = 2048.5 - AlphaEndingLine = 634.5 - BetaSamples = 2048 - BetaLines = 280 + AlphaStartingSample = {{ frameletStartSample - 0.5 }} + AlphaStartingLine = {{ frameletStartLine - 0.5 }} + AlphaEndingSample = {{ frameletEndSample + 0.5 }} + AlphaEndingLine = {{ frameletEndLine + 0.5 }} + BetaSamples = {{ frameletEndSample - frameletStartSample + 1 }} + BetaLines = {{ frameletEndLine - frameletStartLine + 1 }} End_Group -End_Object - -Object = Label - Bytes = 65536 -End_Object - -Object = History - Name = IsisCube - StartByte = 2359297 - Bytes = 572 -End_Object - -Object = OriginalXmlLabel - Name = IsisCube - StartByte = 2359869 - Bytes = 13408 - ByteOrder = Lsb + {% endif %} End_Object End diff --git a/isis/src/base/apps/isisimport/isisimport.cpp b/isis/src/base/apps/isisimport/isisimport.cpp index f1103f3593..358cadc558 100644 --- a/isis/src/base/apps/isisimport/isisimport.cpp +++ b/isis/src/base/apps/isisimport/isisimport.cpp @@ -2,9 +2,13 @@ #include #include +#include +#include #include "CubeAttribute.h" #include "FileName.h" +#include "iTime.h" +#include "OriginalXmlLabel.h" #include "XmlToJson.h" #include "ProcessImport.h" @@ -16,6 +20,8 @@ using json = nlohmann::json; namespace Isis { + static QString convertUniqueIdToObservationId(Pvl &outputLabel); + void isisimport(UserInterface &ui, Pvl *log) { FileName xmlFileName = ui.GetFileName("FROM"); @@ -36,16 +42,26 @@ namespace Isis { // To read the DN data ProcessImport importer; - importer.SetInputFile(xmlFileName.removeExtension().addExtension("img").expanded()); + if(xmlFileName.removeExtension().addExtension("dat").fileExists()){ + importer.SetInputFile(xmlFileName.removeExtension().addExtension("dat").expanded()); + } + else if (xmlFileName.removeExtension().addExtension("img").fileExists()) { + importer.SetInputFile(xmlFileName.removeExtension().addExtension("img").expanded()); + } + else { + QString msg = "Cannot find image file for [" + xmlFileName.name() + "]. Confirm that the " + ".dat or .img file for this XML exists and is located in the same directory."; + throw IException(IException::User, msg, _FILEINFO_); + } // Set everything needed by ProcessImport - PvlGroup dimensions = newLabel.findObject("IsisCube").findGroup("Dimensions"); + PvlGroup dimensions = newLabel.findObject("IsisCube").findObject("Core").findGroup("Dimensions"); int ns = toInt(dimensions["Samples"]); int nl = toInt(dimensions["Lines"]); int nb = toInt(dimensions["Bands"]); importer.SetDimensions(ns, nl, nb); - PvlGroup pixels = newLabel.findObject("IsisCube").findGroup("Pixels"); + PvlGroup pixels = newLabel.findObject("IsisCube").findObject("Core").findGroup("Pixels"); QString pixelType = pixels["Type"]; QString byteOrder = pixels["ByteOrder"]; double base = pixels["Base"]; @@ -55,15 +71,20 @@ namespace Isis { importer.SetBase(base); importer.SetMultiplier(multiplier); - // TODO: how to handle this? - importer.SetFileHeaderBytes(0); + // TODO: how to handle this? + importer.SetFileHeaderBytes(0); CubeAttributeOutput &att = ui.GetOutputAttribute("TO"); Cube *outputCube = importer.SetOutputCube(ui.GetFileName("TO"), att); + OriginalXmlLabel xmlLabel; + xmlLabel.readFromXmlFile(xmlFileName); + importer.StartProcess(); - // Write the updated label + outputCube->write(xmlLabel); + + // Write the updated label Isis::PvlObject &newCubeLabel = newLabel.findObject("IsisCube"); Isis::Pvl &outLabel(*outputCube->label()); Isis::PvlObject &outCubeLabel = outLabel.findObject("IsisCube"); @@ -71,8 +92,75 @@ namespace Isis { for(int g = 0; g < newCubeLabel.groups(); g++) { outCubeLabel.addGroup(newCubeLabel.group(g)); } + + // Remove trailing "Z" from PDS4 .xml (on re-ingestion) and create YearDoy keyword in Archive group + PvlKeyword *startTime = &outLabel.findGroup("Instrument", Pvl::Traverse)["StartTime"]; + QString startTimeString = startTime[0]; + if (startTimeString.endsWith("Z", Qt::CaseInsensitive)) { + startTimeString.chop(1); + startTime->setValue(startTimeString); + } + iTime stime(startTimeString); + PvlGroup &archive = outLabel.findGroup("Archive", Pvl::Traverse); + PvlKeyword yeardoy("YearDoy", toString(stime.Year()*1000 + stime.DayOfYear())); + archive.addKeyword(yeardoy); + + if (!outputCube->group("Archive").hasKeyword("ObservationId")){ + convertUniqueIdToObservationId(outLabel); + } + importer.EndProcess(); return; } + + QString convertUniqueIdToObservationId(Pvl &outputLabel) { + if (outputLabel.findObject("IsisCube").hasGroup("Mosaic")) { + return ""; // translation file should auto translate this case to Mosaic group. + // For any other product, this ID goes in the Archive group. + } + + QString target = ""; + if (outputLabel.findObject("IsisCube").hasGroup("Instrument")) { + target = outputLabel.findGroup("Instrument", Pvl::Traverse) + .findKeyword("TargetName")[0]; + } + else { + target = outputLabel.findGroup("Mapping", Pvl::Traverse) + .findKeyword("TargetName")[0]; + } + + PvlGroup &archiveGroup = outputLabel.findGroup("Archive", Pvl::Traverse); + QString uniqueId = archiveGroup.findKeyword("UniqueIdentifier")[0]; + + QString observationId = ""; + BigInt uniqueIdDecimalValue = uniqueId.toLongLong(); + BigInt operationPeriod = (uniqueIdDecimalValue & 1879048192); + operationPeriod /= qPow(2,28); + FileName transFile("$ISISROOT/appdata/translations/TgoCassisOperationPeriod.trn"); + PvlTranslationTable transTable(transFile); + observationId = transTable.Translate("OperationPeriod", toString(operationPeriod)); + BigInt orbitNumber = (uniqueIdDecimalValue & 268433408); + orbitNumber /= qPow(2,11); + observationId += "_"; + observationId += QString("%1").arg(orbitNumber, 6, 10, QChar('0')); + + int orbitPhase = (uniqueIdDecimalValue & 2044); + if (target.compare("mars", Qt::CaseInsensitive) == 0) { + orbitPhase /= qPow(2,2); + } + else { + orbitPhase = 900; + } + observationId += "_"; + observationId += QString("%1").arg(orbitPhase, 3, 10, QChar('0')); + + int imageType = (uniqueIdDecimalValue & 3); + observationId += "_"; + observationId += toString(imageType); + + archiveGroup += PvlKeyword("ObservationId", observationId); + + return observationId; + } } From 4062383accecbf50ce6c18dd79f8c8225e222db6 Mon Sep 17 00:00:00 2001 From: Amy Stamile Date: Tue, 25 May 2021 09:37:24 -0700 Subject: [PATCH 2/2] Added disclaimer to xml file. --- isis/src/base/apps/isisimport/isisimport.xml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/isis/src/base/apps/isisimport/isisimport.xml b/isis/src/base/apps/isisimport/isisimport.xml index e7cc304653..2797fa749f 100644 --- a/isis/src/base/apps/isisimport/isisimport.xml +++ b/isis/src/base/apps/isisimport/isisimport.xml @@ -2,20 +2,25 @@ - Convert from PDS 4 format (other formats will be supported in the future) using template XML files to an ISIS Cube. + Convert from PDS 4 format (other formats will be supported in the future) using template XML files to an ISIS Cube. +

+ NOTE: This program and the associated template files are incomplete. The documentation + describes what the eventual intended capabilities are. Many capabiliteis are not implemented + at this time. +

Reads a PDS4 compatible label file and image file. The contents of the ISIS cube label file are generated using the template file specified by the TEMPLATE parameter.

This application uses the Inja templating engine - to render the template file. The input data from the PDS4 label + to render the template file. The input data from the PDS4 label is converted to JSON and then it is accessed via the Inja templating syntax. See the Inja documentation for the full template - syntax. + syntax.

@@ -64,7 +69,7 @@ Isis Cube - The ingested ISIS Cube. + The ingested ISIS Cube.