From 35b21fc9107b186984beee954ce321deb32426d9 Mon Sep 17 00:00:00 2001 From: Amy Stamile <74275278+amystamile-usgs@users.noreply.github.com> Date: Wed, 3 Apr 2024 21:24:02 -0700 Subject: [PATCH] Tgocassis ingest fixes for cas_cal_sc images (#5435) * fixes cas_cal_sc ingest errors * fixed tests --- CHANGELOG.md | 1 + .../TgoCassisExportedInstrument_PSA.trn | 85 +++------ ...sExportedInstrument_PSA_Optical_Filter.trn | 168 ++++++++++++++++++ .../tgo/apps/tgocassis2isis/TgoCassisRdr.trn | 2 + .../apps/tgocassis2isis/tgocassis2isis.cpp | 14 +- 5 files changed, 204 insertions(+), 66 deletions(-) create mode 100644 isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA_Optical_Filter.trn diff --git a/CHANGELOG.md b/CHANGELOG.md index b227d81099..9f0079e3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,7 @@ release. - Fixed ProgramLauncher failing while reporting errors from launched programs [#5331](https://github.com/DOI-USGS/ISIS3/pull/5331) - Fixed high/low filter functionality in trimfilter [#5311](https://github.com/DOI-USGS/ISIS3/issues/5311) - Fixed downloadIsisData script excluding needed files in the calibration folder [#5272](https://github.com/DOI-USGS/ISIS3/issues/5272) +- Fixed tgocassis2isis cas_cal_sc ingest errors and added error for cas_raw_sc images [#5413](https://github.com/DOI-USGS/ISIS3/issues/5413) ## [8.0.1] - 2023-08-23 diff --git a/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA.trn b/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA.trn index c2eb601b6d..fe4ce1ee16 100644 --- a/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA.trn +++ b/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA.trn @@ -1,47 +1,5 @@ -# Translates CaSSIS xml labels into the Instrument PvlGroup values +# Translates CaSSIS PSA Calibrated xml labels into the Instrument PvlGroup values # for the ingested ISIS cube labels. -# -# The Dependencies keyword specifies a tag or attribute at the same level as -# the InputKey that uniquely identifies the InputKey. -# -# Consider the following translation group and xml -# -# Group = Samples -# Auto -# InputPosition = (Array_2D_Image, Axis_Array) -# Dependencies = "tag@axis_name|Sample" -# InputKey = elements -# OutputName = Samples -# OutputPosition = (Group, Dimensions) -# Translation = (*, *) -# End_Group -# -# -# -# Line -# 1 -# 2048 -# -# -# Sample -# 2 -# 279 -# -# -# -# There are two Axis_Array tags below Array_2D_Image and both of them have an -# elements tag. So, the Dependencies keyword specifies to take the value of -# the elements tag under the second Axis_Array array tag because it also has a -# axis_name tag with a value of Sample. -# -# -# This translation table is for translating CaSSIS xml labels into pvl cube -# labels. -# -# See $ISISROOT/appdata/translations/XmlExample.trn for an example xml translation table -# and documentation for the different options. -# -# history 2018-05-17 Kaitlyn Lee - Added ObservationId with a placeholder value for now. Group = SpacecraftName Auto @@ -50,11 +8,9 @@ Group = SpacecraftName InputKey = name OutputName = SpacecraftName OutputPosition = (Object,IsisCube,Group,Instrument) - Translation = (*, *) + Translation = ("TRACE GAS ORBITER", "TGO") End_Group - - Group = InstrumentId Auto InputPosition = (Observation_Area, Observing_System, Observing_System_Component) @@ -76,15 +32,6 @@ Group = Expanded Translation = (1, *) End_Group -Group = ObservationId - Auto - InputPosition = (Identification_Area, Alias_List, Alias) - InputKey = alternate_id - OutputName = ObservationId - OutputPosition = (Object, IsisCube, Group, Archive) - Translation = (*, *) -End_Group - Group = TargetName Auto InputPosition = (Observation_Area, Target_Identification) @@ -114,8 +61,8 @@ End_Group Group = Filter Auto - InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) - InputKey = img:filter_name + InputPosition = (Observation_Area, Mission_Area, em16_tgo_cas:Cassis_Data, em16_tgo_cas:HK_Derived_Data) + InputKey = em16_tgo_cas:filter OutputName = Filter OutputPosition = (Object,IsisCube,Group,Instrument) Translation = (*, *) @@ -123,8 +70,8 @@ End_Group Group = FilterName Auto - InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) - InputKey = img:filter_name + InputPosition = (Observation_Area, Mission_Area, em16_tgo_cas:Cassis_Data, em16_tgo_cas:HK_Derived_Data) + InputKey = em16_tgo_cas:filter OutputName = Filter OutputPosition = (Object,IsisCube,Group,BandBin) Translation = (*, *) @@ -132,28 +79,26 @@ End_Group Group = Center Auto - InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) - InputKey = img:filter_name + InputPosition = (Observation_Area, Mission_Area, em16_tgo_cas:Cassis_Data, em16_tgo_cas:HK_Derived_Data) + InputKey = em16_tgo_cas:filter OutputName = Center OutputPosition = (Object, IsisCube, Group, BandBin) Translation = (678.2, PAN) Translation = (494.8, BLU) Translation = (836.0, RED) Translation = (939.3, NIR) - End_Group Group = Width Auto - InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) - InputKey = img:filter_name + InputPosition = (Observation_Area, Mission_Area, em16_tgo_cas:Cassis_Data, em16_tgo_cas:HK_Derived_Data) + InputKey = em16_tgo_cas:filter OutputName = Width OutputPosition = (Object, IsisCube, Group, BandBin) Translation = (231.9, PAN) Translation = (121.8, BLU) Translation = (98.5, RED) Translation = (133.6, NIR) - End_Group Group = Expanded @@ -166,4 +111,14 @@ Group = Expanded Translation = (*, *) End_Group +Group = UniqueIdentifier + Auto + Optional + InputPosition = (Observation_Area, Mission_Area, em16_tgo_cas:Cassis_Data, em16_tgo_cas:Image_Command) + InputKey = em16_tgo_cas:unique_identifier + OutputName = UniqueIdentifier + OutputPosition = (Object, IsisCube, Group, Archive) + Translation = (*, *) +End_Group + End diff --git a/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA_Optical_Filter.trn b/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA_Optical_Filter.trn new file mode 100644 index 0000000000..cc4025f198 --- /dev/null +++ b/isis/src/tgo/apps/tgocassis2isis/TgoCassisExportedInstrument_PSA_Optical_Filter.trn @@ -0,0 +1,168 @@ +# Translates CaSSIS xml labels into the Instrument PvlGroup values +# for the ingested ISIS cube labels. +# +# The Dependencies keyword specifies a tag or attribute at the same level as +# the InputKey that uniquely identifies the InputKey. +# +# Consider the following translation group and xml +# +# Group = Samples +# Auto +# InputPosition = (Array_2D_Image, Axis_Array) +# Dependencies = "tag@axis_name|Sample" +# InputKey = elements +# OutputName = Samples +# OutputPosition = (Group, Dimensions) +# Translation = (*, *) +# End_Group +# +# +# +# Line +# 1 +# 2048 +# +# +# Sample +# 2 +# 279 +# +# +# +# There are two Axis_Array tags below Array_2D_Image and both of them have an +# elements tag. So, the Dependencies keyword specifies to take the value of +# the elements tag under the second Axis_Array array tag because it also has a +# axis_name tag with a value of Sample. +# +# +# This translation table is for translating CaSSIS xml labels into pvl cube +# labels. +# +# See $ISISROOT/appdata/translations/XmlExample.trn for an example xml translation table +# and documentation for the different options. +# +# history 2018-05-17 Kaitlyn Lee - Added ObservationId with a placeholder value for now. + +Group = SpacecraftName + Auto + InputPosition = (Observation_Area, Observing_System, Observing_System_Component) + InputKeyDependencies = "tag@type|Host" + InputKey = name + OutputName = SpacecraftName + OutputPosition = (Object,IsisCube,Group,Instrument) + Translation = (*, *) +End_Group + + + +Group = InstrumentId + Auto + InputPosition = (Observation_Area, Observing_System, Observing_System_Component) + InputKeyDependencies = "tag@type|Instrument" + InputKey = name + OutputName = InstrumentId + OutputPosition = (Object,IsisCube,Group,Instrument) + Translation = (*, *) +End_Group + +Group = Expanded + Auto + InputDefault = 1 + InputPosition = (Observation_Area, Observing_System, Observing_System_Component) + InputKeyDependencies = "tag@type|Host" + InputKey = name + OutputName = Expanded + OutputPosition = (Object,IsisCube,Group,Instrument) + Translation = (1, *) +End_Group + +Group = ObservationId + Auto + InputPosition = (Identification_Area, Alias_List, Alias) + InputKey = alternate_id + OutputName = ObservationId + OutputPosition = (Object, IsisCube, Group, Archive) + Translation = (*, *) +End_Group + +Group = TargetName + Auto + InputPosition = (Observation_Area, Target_Identification) + InputKey = name + OutputName = TargetName + OutputPosition = (Object,IsisCube,Group,Instrument) + Translation = (*, *) +End_Group + +Group = StartTime + Auto + InputPosition = (Observation_Area, Time_Coordinates) + InputKey = start_date_time + OutputName = StartTime + OutputPosition = (Object,IsisCube,Group,Instrument) + Translation = (*, *) +End_Group + +Group = ExposureDuration + Auto + InputPosition = (Observation_Area, Mission_Area, em16_tgo_cas:Cassis_Data, em16_tgo_cas:PEHK_Derived_Data) + InputKey = em16_tgo_cas:exposure_time + OutputName = ExposureDuration + OutputPosition = (Object, IsisCube, Group, Instrument) + Translation = (*, *) +End_Group + +Group = Filter + Auto + InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) + InputKey = img:filter_name + OutputName = Filter + OutputPosition = (Object,IsisCube,Group,Instrument) + Translation = (*, *) +End_Group + +Group = FilterName + Auto + InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) + InputKey = img:filter_name + OutputName = Filter + OutputPosition = (Object,IsisCube,Group,BandBin) + Translation = (*, *) +End_Group + +Group = Center + Auto + InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) + InputKey = img:filter_name + OutputName = Center + OutputPosition = (Object, IsisCube, Group, BandBin) + Translation = (678.2, PAN) + Translation = (494.8, BLU) + Translation = (836.0, RED) + Translation = (939.3, NIR) + +End_Group + +Group = Width + Auto + InputPosition = (Observation_Area, Discipline_Area, img:Imaging, img:Optical_Filter) + InputKey = img:filter_name + OutputName = Width + OutputPosition = (Object, IsisCube, Group, BandBin) + Translation = (231.9, PAN) + Translation = (121.8, BLU) + Translation = (98.5, RED) + Translation = (133.6, NIR) +End_Group + +Group = Expanded + Auto + Optional + InputPosition = (CaSSIS_Header, DERIVED_HEADER_DATA) + InputKey = Expanded + OutputName = Expanded + OutputPosition = (Object, IsisCube, Group, Instrument) + Translation = (*, *) +End_Group + +End \ No newline at end of file diff --git a/isis/src/tgo/apps/tgocassis2isis/TgoCassisRdr.trn b/isis/src/tgo/apps/tgocassis2isis/TgoCassisRdr.trn index f93ce14868..012ff7d888 100644 --- a/isis/src/tgo/apps/tgocassis2isis/TgoCassisRdr.trn +++ b/isis/src/tgo/apps/tgocassis2isis/TgoCassisRdr.trn @@ -80,6 +80,7 @@ Group = CoreType OutputName = CoreType OutputPosition = (Group, Pixels) Translation = (Real, IEEE754LSBSingle) + Translation = (UnsignedWord, UnsignedLSB2) End_Group Group = CoreByteOrder @@ -92,6 +93,7 @@ Group = CoreByteOrder OutputPosition = (Group, Pixels) Translation = (Lsb, IEEE754LSBSingle) Translation = (Lsb, SignedLSB2) + Translation = (Lsb, UnsignedLSB2) End_Group Group = CoreBase diff --git a/isis/src/tgo/apps/tgocassis2isis/tgocassis2isis.cpp b/isis/src/tgo/apps/tgocassis2isis/tgocassis2isis.cpp index c0c2b21372..ad4177146b 100644 --- a/isis/src/tgo/apps/tgocassis2isis/tgocassis2isis.cpp +++ b/isis/src/tgo/apps/tgocassis2isis/tgocassis2isis.cpp @@ -36,6 +36,16 @@ namespace Isis { void tgocassis2isis(UserInterface &ui) { FileName xmlFileName = ui.GetFileName("FROM"); + if (!xmlFileName.removeExtension().addExtension("dat").fileExists() && !xmlFileName.removeExtension().addExtension("img").fileExists()) { + 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_); + } + if(xmlFileName.name().contains("cas_raw_sc")){ + QString msg = "tgocassis2isis is unable to process cas_raw_sc data. Please use cas_cal_sc data instead."; + throw IException(IException::User, msg, _FILEINFO_); + } + try { ProcessImport importer; translateCoreInfo(xmlFileName, importer); @@ -59,9 +69,11 @@ namespace Isis { QFile xmlFile(xmlFileName.expanded()); QDomDocument xmlDoc; xmlDoc.setContent(&xmlFile, true); - // If any instances of "Optical_Filter" exist, use PSA .trn file + // If any instances of "Optical_Filter" or "Mission_Area" exist, use PSA .trn file QString transExportFile; if (xmlDoc.elementsByTagName("Optical_Filter").size()){ + transExportFile = "TgoCassisExportedInstrument_PSA_Optical_Filter.trn"; + } else if (xmlDoc.elementsByTagName("Mission_Area").size()) { transExportFile = "TgoCassisExportedInstrument_PSA.trn"; } else { transExportFile = "TgoCassisExportedInstrument.trn";