Unverified Commit b224a0fa authored by Adam Paquette's avatar Adam Paquette Committed by GitHub
Browse files

EIS Import Fixes (#5630)



* Fixed small typo in isisimport.cpp

* Added support for writing clipper line time tables for pushbroom images

* Adjust Clipper EIS plugin name

* Fixed clipper line time import function

* Minor Clipper PB camera adjustments

* Address breaking change

* Capture detector offset in isisimport and the ClipperPushBroomCamera

* Adjusted detector offset

* Reverted detector origin

* Updated Clipper pushbroom camera tests

* Fixed detector center and offset

* Fixes EIS Import Tests

* Fixes ClipperPushBroomTests

* Fix "Failed to open file" failures

---------

Co-authored-by: default avataramystamile-usgs <astamile@usgs.gov>
parent 3793da6f
Loading
Loading
Loading
Loading
+25 −20
Original line number Diff line number Diff line
{% set sub_sensor = Product_Observational.Label_TBD.Observation_Area.Observing_System.Observing_System_Component.0.name %}
{% if sub_sensor == "WAC FC" or sub_sensor == "WAC PB" %}
{% set sensor="WAC" %}
{% else if sub_sensor == "NAC FC" or sub_sensor == "NAC PB" %}
{% set sensor="NAC" %}
{% else %}
{% set sensor="UNK" %}
{% endif %}
{% set sensor = Product_Observational.Observation_Area.Observing_System.Observing_System_Component.1.name %}
{% set sub_sensor = Product_Observational.Observation_Area.Mission_Area.clipper_Observation_Information.clipper_EIS_Parameters.clipper_mode %}

{% set ImageArray = Product_Observational.File_Area_Observational.0.Array_2D_Image %}

{% set ImageArray = Product_Observational.File_Area_Observational.Array_2D_Image %}

Object = IsisCube
  Object = Core
    Group = Dimensions
      Samples = {{ ImageArray.Axis_Array.0.elements }}
      Lines   = {{ ImageArray.Axis_Array.1.elements }}
      Samples = {{ ImageArray.Axis_Array.1.elements }}
      Lines   = {{ ImageArray.Axis_Array.0.elements }}
      Bands   = 1
    End_Group

@@ -21,7 +16,7 @@ Object = IsisCube

    Group = Pixels
      {% set pixelType = ImageArray.Element_Array.data_type %}
      {% if exists("Product_Observational.File_Area_Observational.0.Array_2D_Image.Element_Array.data_type") %}
      {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.data_type") %}
      Type       = {% if pixelType == "IEEE754LSBDouble" %} Double
                   {% else if pixelType == "IEEE754LSBSingle" %} Real
                   {% else if pixelType == "IEEE754MSBDouble" %} Double
@@ -59,14 +54,14 @@ Object = IsisCube
      ByteOrder  = Lsb
      {% endif %}

      Base       = {% if exists("Product_Observational.File_Area_Observational.0.Array_2D_Image.Element_Array.value_offset") %}
      Base       = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.value_offset") %}
                   {{ ImageArray.Element_Array.value_offset }}
                   {% else if exists("Product_Observational.File_Area_Observational.0.Array_2D_Image.offset._text") %}
                   {% else if exists("Product_Observational.File_Area_Observational.Array_2D_Image.offset._text") %}
                   {{ ImageArray.offset._text }}
                   {% else %}
                   0
                   {% endif %}
      Multiplier = {% if exists("Product_Observational.File_Area_Observational.0.Array_2D_Image.Element_Array.scaling_factor") %}
      Multiplier = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.scaling_factor") %}
                   {{ ImageArray.Element_Array.scaling_factor._text }}
                   {% else %}
                   1
@@ -75,14 +70,19 @@ Object = IsisCube
  End_Object

  Group = Instrument
    SpacecraftName            = "{{ Product_Observational.Observation_Area.Investigation_Area.name }}"
    InstrumentId              = "{{ Product_Observational.Observation_Area.Observing_System.Observing_System_Component.1.name }} {{ Product_Observational.Label_TBD.Observation_Area.Observing_System.Observing_System_Component.0.name }}"
    TargetName                = {{ at(splitOnChar(Product_Observational.Observation_Area.Target_Identification.name, " "), 1) }}
    SpacecraftName            = "{{ Product_Observational.Observation_Area.Observing_System.Observing_System_Component.0.name }}"
    InstrumentId              = "{{ sensor }}-{{ sub_sensor }}"
    TargetName                = {{ Product_Observational.Observation_Area.Target_Identification.name }}
    StartTime                 = {{ RemoveStartTimeZ(Product_Observational.Observation_Area.Time_Coordinates.start_date_time) }}
    ExposureDuration          = {{ Product_Observational.Observation_Area.Discipline_Area.img_Exposure.img_exposure_duration._text }}<seconds>
    ExposureDuration          = {{ Product_Observational.Observation_Area.Discipline_Area.img_Exposure.img_exposure_duration._text }} <{{ Product_Observational.Observation_Area.Discipline_Area.img_Exposure.img_exposure_duration.attrib_unit }}>
    DetectorLineOffset        = {% if exists("Product_Observational.Observation_Area.Mission_Area.clipper_Observation_Information.clipper_EIS_Parameters.clipper_Detector_Region.clipper_readout_start_row") %}
                                {{ Product_Observational.Observation_Area.Mission_Area.clipper_Observation_Information.clipper_EIS_Parameters.clipper_Detector_Region.clipper_readout_start_row }}
                                {% else %}
                                {{ Product_Observational.Observation_Area.Mission_Area.clipper_Observation_Information.clipper_EIS_Parameters.clipper_Detector_Region.0.clipper_readout_start_row }}
                                {% endif %}
  End_Group

{% set filter=Product_Observational.Label_TBD.Observation_Area.Observing_System.Observing_System_Component.1.name %}
{% set filter=Product_Observational.Observation_Area.Mission_Area.clipper_Observation_Information.clipper_EIS_Parameters.clipper_filter_used %}
  Group = BandBin
    FilterName = {{ filter }}
    Center = {% if filter == "CLEAR" %}
@@ -154,5 +154,10 @@ Object = IsisCube
End_Object

Object = Translation
  {% if sub_sensor == "PUSHBROOM" %}
  Object = AncillaryProcess
    ProcessFunction = clipperEisPBCreateLineTable
  End_Object
  {% endif %}
End_Object
End
+58 −0
Original line number Diff line number Diff line
#ifndef CLIPPER_H
#define CLIPPER_H

#include "iTime.h"
#include "Pvl.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"
#include "Table.h"
#include "TableField.h"
#include "TableRecord.h"

using namespace std;

namespace Isis {
  
    void clipperEisPBCreateLineTable(Cube *cube) {
      TableField ephTimeField("EphemerisTime", TableField::Double);
      TableField expTimeField("ExposureTime", TableField::Double);
      TableField lineStartField("LineStart", TableField::Integer);

      TableRecord timesRecord;
      timesRecord += ephTimeField;
      timesRecord += expTimeField;
      timesRecord += lineStartField;

      Table timesTable("LineScanTimes", timesRecord);

      Pvl *inputCubeLabel = cube->label();

      PvlGroup instGroup;
      try {
        instGroup = inputCubeLabel->findGroup("Instrument", PvlObject::FindOptions::Traverse);
      }
      catch(IException &e) {
        QString msg = "Unable to find instrument group in [" + cube->fileName() + "]";
        throw IException(e, IException::User, msg, _FILEINFO_); 
      }

      QString startTime = QString(instGroup.findKeyword("StartTime"));
      iTime time(startTime);
      PvlKeyword exposureDuration = instGroup.findKeyword("ExposureDuration");
      double lineDuration = (double)exposureDuration;
      if (exposureDuration.unit() == "ms") {
        lineDuration /= 1000;
      }
      lineDuration /= cube->lineCount();

      timesRecord[0] = time.Et();
      timesRecord[1] = lineDuration;
      timesRecord[2] = 1;
      timesTable += timesRecord;

      cube->write(timesTable);
    }
  
  }

#endif
 No newline at end of file
+8 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "Stretch.h"

#include "CassiniImportUtils.h"
#include "ClipperImportUtils.h"

using namespace std;

@@ -24,7 +25,8 @@ std::map<std::string, int> processMap = {

std::map<std::string, int> ancillaryProcessMap = {
  {"cassiniIssCreateLinePrefixTable", 1},
  {"cassiniIssFixLabel", 2}
  {"cassiniIssFixLabel", 2},
  {"clipperEisPBCreateLineTable", 3}
};

namespace Isis {
@@ -48,14 +50,18 @@ namespace Isis {
                             QString processFunction,
                             PvlObject translation,
                             ProcessImport *process) {
    vector<vector<char *>> prefixData = process->DataPrefix();
    vector<vector<char *>> prefixData;
    switch (ancillaryProcessMap[processFunction.toStdString()]) {
      case 1:
        prefixData = process->DataPrefix();
        return cassiniIssCreateLinePrefixTable(cube,
                                               prefixData.at(0),
                                               translation);
      case 2:
        return cassiniIssFixLabel(cube, translation, process);

      case 3:
        return clipperEisPBCreateLineTable(cube);
    }

    throw IException(IException::Programmer, "Unable to find prefix/suffix function [" + processFunction.toStdString() + "]", _FILEINFO_);
+2 −2
Original line number Diff line number Diff line
@@ -587,7 +587,7 @@ namespace Isis {
    importer.EndProcess();

    if (translation.hasObject("PostProcess")) {
      // Expand for potentially more than one prefix process
      // Expand for potentially more than one postfix process
      // See AncillaryProcess section above
      runProcess(ui.GetCubeName("TO"), translation.findObject("PostProcess"));
    }
+23 −27
Original line number Diff line number Diff line
@@ -152,55 +152,51 @@ namespace Isis {
      QDomElement next = element.firstChildElement();
      if (next.isNull()) {
        json converted = convertLastChildNodeToJson(element);
        if (!converted.is_null()) {
          // Simple case with no repeated tags at the same level
          if (!output.contains(cleanTagName)) {
          output.update(converted);
            output[cleanTagName] = converted[cleanTagName];
          }
          else {
            // There is a repeated tag at the same level in the XML, i.e: <a>val1</a><a>val2</a>
            // Translated json goal: a:[val1, val2]
            // If the converted json has an array already, append, else make it an array
            if (!output[cleanTagName].is_array()) {
            json repeatedArray;
            repeatedArray.push_back(output[element.tagName().toStdString()]);
              json repeatedArray = json::array();
              repeatedArray.push_back(output[cleanTagName]);
              output[cleanTagName] = repeatedArray;
            }
            output[cleanTagName].push_back(converted[cleanTagName]);
          }
        }
      }
      else {
        // If there is already an element with this tag name at any level besides the same one,
        // add it to a list rather than 
        // overwriting. This is the following situation:
        // XML: <a> <first>value1</first> </a> <a> <second>value2</second></a>
        // JSON: a: [ {first:value1, second:value2} ]
        if (output.contains(cleanTagName)) {
          // If it's an array already, append, else make it an array
        json temporaryJson;
        convertXmlToJson(next, temporaryJson);

        if (output.contains(cleanTagName)) {
          // If it's an array already, append, else make it an array
          if (!output[cleanTagName].is_array()) {
            json repeatedArray;
            repeatedArray.push_back(output[element.tagName().toStdString()]);
            json repeatedArray = json::array();
            repeatedArray.push_back(output[cleanTagName]);
            output[cleanTagName] = repeatedArray;
          }
          output[cleanTagName].push_back(temporaryJson);
        }
        else {
          if (element.hasAttributes()) {
            json tempArea;
            QDomNamedNodeMap attrMap = element.attributes();
            for (int j=0; j < attrMap.size(); j++) {
              QDomAttr attr = attrMap.item(j).toAttr(); 
              tempArea["attrib_"+attr.name().toStdString()] = attr.value().toStdString();
              temporaryJson["attrib_"+attr.name().toStdString()] = attr.value().toStdString();
            }
            tempArea.update(
                convertXmlToJson(next, output[cleanTagName]));
            output[cleanTagName] = tempArea;
          }
          else {
            output[cleanTagName] = 
              convertXmlToJson(next, output[cleanTagName]);
          }
          output[cleanTagName] = temporaryJson;
        }
      }
      element = element.nextSiblingElement();
Loading