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