69 p_instrumentId = (QString) inst[
"InstrumentId"];
70 p_startingSample = inst[
"FirstLineSample"];
71 p_crosstrackSumming = inst[
"CrosstrackSumming"];
72 p_downtrackSumming = inst[
"DowntrackSumming"];
73 p_exposureDuration = inst[
"LineExposureDuration"];
74 p_focalPlaneTemp = inst[
"FocalPlaneTemperature"];
75 p_clockCount = (QString) inst[
"SpacecraftClockCount"];
77 if(inst.hasKeyword(
"OrbitNumber")) {
78 p_orbitNumber = inst[
"OrbitNumber"];
80 p_gainModeId = (QString) inst[
"GainModeId"];
81 p_offsetModeId = inst[
"OffsetModeId"];
82 p_startTime = (QString) inst[
"StartTime"];
85 p_dataQuality =
"Unknown";
87 if(arch.hasKeyword(
"DataQualityDesc")) {
88 p_dataQuality = (QString) arch[
"DataQualityDesc"];
93 p_filter = (QString) bandBin[
"FilterName"];
103 p_lsk =
FileName(kerns[
"LeapSecond"][0]);
104 p_sclk =
FileName(kerns[
"SpacecraftClock"][0]);
163 p_trueLineRate = p_exposureDuration * (double) p_downtrackSumming;
164 p_trueLineRate /= 1000.0;
168 p_exposureDuration *= p_downtrackSumming;
172 map<QString, double>::iterator p;
174 p = p_gainMapNA.find(p_gainModeId);
175 if(p == p_gainMapNA.end()) {
176 QString msg =
"Invalid value for PVL keyword GainModeId [" +
182 p = p_gainMapWA.find(p_gainModeId);
183 if(p == p_gainMapWA.end()) {
184 QString msg =
"Invalid value for PVL keyword GainModeId [" +
192 p_offset = p_offsetModeId * 5.0;
198 iTime currentTime(p_startTime);
199 iTime mappingPhaseBeginTime(
"1999-04-03T01:00:40.441");
200 if(currentTime < mappingPhaseBeginTime) {
201 double newGain = p_gain / (double) p_downtrackSumming;
202 double mindiff = DBL_MAX;
203 map<QString, double>::iterator p;
205 p = p_gainMapNA.begin();
206 while(p != p_gainMapNA.end()) {
207 double diff = abs(newGain - p->second);
216 p = p_gainMapNA.find(index);
217 if(p == p_gainMapNA.end()) {
218 string msg =
"Could not find new gain for pre-mapping narrow angle image";
231 furnsh_c(lsk.toLatin1().data());
232 furnsh_c(sclk.toLatin1().data());
235 scs2e_c(-94, p_clockCount.toLatin1().data(), &p_etStart);
239 unload_c(lsk.toLatin1().data());
240 unload_c(sclk.toLatin1().data());
328 if(p_crosstrackSumming == 13) {
329 for(
int i = 0; i < p_ns; i++) {
330 p_startDetector[i] = mode13_table[i].starting_pixel +
331 p_startingSample - 1;
332 p_endDetector[i] = mode13_table[i].ending_pixel +
333 p_startingSample - 1;
336 else if(p_crosstrackSumming == 27) {
337 for(
int i = 0; i < p_ns; i++) {
338 p_startDetector[i] = mode27_table[i].starting_pixel +
339 p_startingSample - 1;
340 p_endDetector[i] = mode27_table[i].ending_pixel +
341 p_startingSample - 1;
345 int detector = (p_startingSample - 1);
346 for(
int i = 0; i < p_ns; i++) {
347 p_startDetector[i] = detector;
348 detector += p_crosstrackSumming - 1;
349 p_endDetector[i] = detector;
356 for(
int det = 0; det <
Detectors(); det++) {
357 p_sample[det] = -1.0;
360 for(
int samp = 1; samp <= p_ns; samp++) {
361 int sd = p_startDetector[samp-1];
362 int ed = p_endDetector[samp-1];
364 double m = ((samp + 0.5) - (samp - 0.5)) / ((ed + 0.5) - (sd - 0.5));
365 for(
int det = sd; det <= ed; det++) {
366 p_sample[det] = m * (det - (sd - 0.5)) + (samp - 0.5);
426 static bool firstTime =
true;
427 if(!firstTime)
return;
432 QString sclkKern = p_sclk.
expanded();
433 furnsh_c(lskKern.toLatin1().data());
434 furnsh_c(sclkKern.toLatin1().data());
437 FileName wagoFile(
"$mgs/calibration/MGSC_????_wago.tab");
438 wagoFile = wagoFile.highestVersion();
439 QString nameOfFile = wagoFile.expanded();
440 ifstream temp(nameOfFile.toLatin1().data());
441 vector<int> wholeFile;
445 int nextByte = temp.get();
446 if(nextByte != 10 && nextByte != 13) {
447 wholeFile.push_back(nextByte);
454 int high = wholeFile.size() / 35;
456 IString line, filter, sclk, offsetId;
464 middle = (low + high) / 2;
465 int SclkStart = middle * 35 + 8;
466 int SclkEnd = SclkStart + 15;
470 for(
int i = SclkStart; i < SclkEnd; i++) {
471 currentSclk += (char)wholeFile[i];
477 scs2e_c(-94, currentSclk.c_str(), &et);
480 if(et < p_etEnd && et > p_etStart) {
481 int linenum = middle;
486 while(et >= p_etStart) {
488 int lineStart = (linenum * 35);
489 int lineEnd = lineStart + 35;
491 string currentLine =
"";
492 for(
int i = lineStart; i < lineEnd; i++) {
493 currentLine += (char)wholeFile[i];
498 for(
int i = 8; i < 23; ++i) {
499 currentSclk += currentLine[i];
503 scs2e_c(-94, currentSclk.c_str(), &et);
508 while(et <= p_etEnd) {
510 int lineStart = (linenum * 35);
511 int lineEnd = lineStart + 35;
513 string currentLine =
"";
514 for(
int i = lineStart; i < lineEnd; i++) {
515 currentLine += (char)wholeFile[i];
520 for(
int i = 8; i < 23; ++i) {
521 currentSclk += currentLine[i];
525 scs2e_c(-94, currentSclk.c_str(), &et);
530 for(
int i = bottom; i <= top; ++i) {
531 int lineStart = (i * 35);
532 int lineEnd = lineStart + 35;
533 string currentLine =
"";
534 for(
int j = lineStart; j < lineEnd; j++) {
535 currentLine += (char)wholeFile[j];
540 filter = line.
Token(
",");
549 sclk = line.
Token(
",");
553 scs2e_c(-94, sclk.c_str(), &et);
556 gainId = line.
Token(
",").
ToQt().remove(
"\"").trimmed();
565 map<QString, double>::iterator p;
566 p = p_gainMapWA.find(gainId);
567 if(p == p_gainMapWA.end()) {
569 unload_c(lskKern.toLatin1().data());
570 unload_c(sclkKern.toLatin1().data());
572 QString msg =
"Invalid GainModeId [" + gainId +
"] in wago table";
575 double gain = p->second;
578 double offset = offsetId.ToDouble() * 5.0;
583 wago.offset = offset;
584 p_wagos.push_back(wago);
591 else if(et < p_etStart) {
601 sort(p_wagos.begin(), p_wagos.end());
602 boost::ignore_unused((unique(p_wagos.begin(), p_wagos.end())));
605 unload_c(lskKern.toLatin1().data());
606 unload_c(sclkKern.toLatin1().data());