Isis 3 Programmer Reference
CissLabels.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include <string>
10 #include "CissLabels.h"
11 #include "Pvl.h"
12 #include "PvlGroup.h"
13 #include "SpecialPixel.h"
14 #include "IException.h"
15 #include "IString.h"
16 
17 using namespace std;
18 namespace Isis {
24  CissLabels::CissLabels(Pvl &lab) {
25  Init(lab);
26  }
27 
33  CissLabels::CissLabels(const QString &file) {
34  Pvl lab(file);
35  Init(lab);
36  }
37 
45  void CissLabels::Init(Pvl &lab) {
46  try {
47  ReadLabels(lab);
48  ComputeImgProperties();
49  }
50  catch(IException &e) {
51  e.print();
52  string msg = "Labels do not appear contain a valid Cassini ISS instrument";
53  throw IException(IException::Unknown, msg, _FILEINFO_);
54  }
55  }
56 
65  void CissLabels::ReadLabels(Pvl &lab) {
66  // Get values out of the instrument group
67  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
68  p_ABflag = (QString) inst["AntiBloomingStateFlag"]; //valid values: On, Off, Unknown
69  p_biasStripMean = (double) inst["BiasStripMean"]; //valid values: real numbers
70  p_compressionRatio = (QString) inst["CompressionRatio"]; //valid values: NotCompressed or real number
71  p_compressionType = (QString) inst["CompressionType"]; //valid values: Lossy, Lossless, NotCompressed
72  p_dataConversionType = (QString) inst["DataConversionType"]; //valid values: 12Bit, 8LSB, Table
73  p_delayedReadoutFlag = (QString) inst["DelayedReadoutFlag"]; //valid values: Yes, No, Unknown
74  p_exposureDuration = (double) inst["ExposureDuration"]; //valid values: real numbers
75  p_flightSoftwareVersion = (QString) inst["FlightSoftwareVersionId"]; //valid values: Unknown, 1.2, 1.3, 1.4
76  p_gainModeId = (int) inst["GainModeId"]; //valid values: 12, 29, 95, 215
77  p_gainState = (int) inst["GainState"]; //valid values: 0, 1, 2, 3
78  p_instrumentDataRate = (double) inst["InstrumentDataRate"]; //valid values: 60.9, 121.9, 182.8, 243.7, 304.6, 365.6, -999.0
79  p_instrumentModeId = (QString) inst["InstrumentModeId"]; //valid values: Full, Sum2, Sum4
80  p_instrumentId = (QString) inst["InstrumentId"]; //valid values: ISSNA, ISSWA
81  p_readoutCycleIndex = (QString) inst["ReadoutCycleIndex"]; //valid values: Unknown or integers 0-15
82  p_readoutOrder = (int) inst["ReadoutOrder"]; //valid values: 0 or 1
83  p_shutterModeId = (QString) inst["ShutterModeId"]; //valid values: BothSim, NacOnly, WacOnly
84  p_shutterStateId = (QString) inst["ShutterStateId"]; //valid values: Enabled or Disabled
85  p_summingMode = (int) inst["SummingMode"]; //valid values: 1, 2, 4
86  p_frontOpticsTemp = toDouble(inst["OpticsTemperature"][0]); //valid values: real numbers
87  p_imageTime = (QString) inst["ImageTime"];
88  p_targetName = (QString) inst["TargetName"]; //valid values: may change overtime, any subject of a Cassini image
89  // Get values out of the archive group
90  PvlGroup &arch = lab.findGroup("Archive", Pvl::Traverse);
91  p_imageNumber = (double) arch["ImageNumber"];
92  // Get values out of the bandbin group
93  PvlGroup &bandbin = lab.findGroup("BandBin", Pvl::Traverse);
94  IString filter = (QString) bandbin["FilterName"];
95  p_filter.push_back(filter.Token("/").ToQt());
96  p_filter.push_back(filter.ToQt());
97  }
98 
99 
107  void CissLabels::ComputeImgProperties() {
108  //set boolean p_antiblooming if antiblooming flag is on
109  if(p_ABflag == "On") p_antiblooming = true;
110  else p_antiblooming = false;
111 
112  //set boolean p_cissNA if camera type is narrow
113  if(p_instrumentId == "ISSNA") p_cissNA = true;
114  else p_cissNA = false;
115 
116  //set filter 1 and filter 2 indices
117  if(p_filter[0] == "UV1") p_filterIndex.push_back(0);
118  else if(p_filter[0] == "UV2") p_filterIndex.push_back(1);
119  else if(p_filter[0] == "BL1") p_filterIndex.push_back(3);
120  else if(p_filter[0] == "RED") p_filterIndex.push_back(6);
121  else if(p_filter[0] == "IR2") p_filterIndex.push_back(8);
122  else if(p_filter[0] == "IR4") p_filterIndex.push_back(10);
123  else if(p_filter[0] == "CL1") p_filterIndex.push_back(17);
124  else if(p_filter[0] == "HAL") p_filterIndex.push_back(19);
125  else if(p_filter[0] == "IRP0") p_filterIndex.push_back(20);
126  else if(p_filter[0] == "P0") p_filterIndex.push_back(21);
127  else if(p_filter[0] == "P60") p_filterIndex.push_back(22);
128  else if(p_filter[0] == "P120") p_filterIndex.push_back(23);
129  else if(p_filter[0] == "IR3") p_filterIndex.push_back(24);
130  else if(p_filter[0] == "IR5") p_filterIndex.push_back(25);
131  else if(p_filter[0] == "CB3") p_filterIndex.push_back(26);
132  else if(p_filter[0] == "MT3") p_filterIndex.push_back(27);
133  else if(p_filter[0] == "CB2") p_filterIndex.push_back(28);
134  else if(p_filter[0] == "MT2") p_filterIndex.push_back(29);
135  else throw IException(IException::Unknown, "Labels have invalid filter 1 name. Cannot get filter 1 index.", _FILEINFO_);
136 
137  if(p_filter[1] == "UV3") p_filterIndex.push_back(2);
138  else if(p_filter[1] == "BL2") p_filterIndex.push_back(4);
139  else if(p_filter[1] == "GRN") p_filterIndex.push_back(5);
140  else if(p_filter[1] == "IR1") p_filterIndex.push_back(7);
141  else if(p_filter[1] == "IR3") p_filterIndex.push_back(9);
142  else if(p_filter[1] == "CB1") p_filterIndex.push_back(11);
143  else if(p_filter[1] == "CB2") p_filterIndex.push_back(12);
144  else if(p_filter[1] == "CB3") p_filterIndex.push_back(13);
145  else if(p_filter[1] == "MT1") p_filterIndex.push_back(14);
146  else if(p_filter[1] == "MT2") p_filterIndex.push_back(15);
147  else if(p_filter[1] == "MT3") p_filterIndex.push_back(16);
148  else if(p_filter[1] == "CL2") p_filterIndex.push_back(18);
149  else if(p_filter[1] == "RED") p_filterIndex.push_back(30);
150  else if(p_filter[1] == "BL1") p_filterIndex.push_back(31);
151  else if(p_filter[1] == "VIO") p_filterIndex.push_back(32);
152  else if(p_filter[1] == "HAL") p_filterIndex.push_back(33);
153  else if(p_filter[1] == "IRP90") p_filterIndex.push_back(34);
154  else if(p_filter[1] == "IRP0") p_filterIndex.push_back(35);
155  else throw IException(IException::Unknown, "Labels have invalid filter 2 name. Cannot get filter 2 index.", _FILEINFO_);
156  return;
157  }
158 }
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::IException::print
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:445
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::toDouble
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:149
std
Namespace for the standard library.
Isis::IString::Token
IString Token(const IString &separator)
Returns the first token in the IString.
Definition: IString.cpp:897
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IString::ToQt
QString ToQt() const
Retuns the object string as a QString.
Definition: IString.cpp:869