Changeset 1779 for branches/mergetest/external/atnf/PKSIO/MBFITSreader.cc
- Timestamp:
- 07/29/10 19:13:46 (14 years ago)
- Location:
- branches/mergetest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mergetest
- Property svn:mergeinfo changed
-
branches/mergetest/external/atnf/PKSIO/MBFITSreader.cc
r1720 r1779 41 41 #include <atnf/PKSIO/MBrecord.h> 42 42 43 #include <casa/Logging/LogIO.h> 44 43 45 #include <casa/math.h> 44 46 #include <casa/iostream.h> … … 57 59 const double HALFPI = PI / 2.0; 58 60 const double R2D = 180.0 / PI; 61 62 // Class name 63 const string className = "MBFITSreader" ; 59 64 60 65 //------------------------------------------------- MBFITSreader::MBFITSreader … … 99 104 100 105 // Tell RPFITSIN not to report errors directly. 101 iostat_.errlun = -1; 102 103 // By default, messages are written to stderr. 104 initMsg(); 106 //iostat_.errlun = -1; 105 107 } 106 108 … … 131 133 int &extraSysCal) 132 134 { 133 // Clear the message stack.134 clearMsg();135 const string methodName = "open()" ; 136 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 135 137 136 138 if (cMBopen) { … … 143 145 int jstat = -3; 144 146 if (rpfitsin(jstat)) { 145 sprintf(cMsg, " ERROR: Failed to open MBFITS file\n%s", rpname);146 logMsg(cMsg);147 sprintf(cMsg, "Failed to open MBFITS file\n%s", rpname); 148 os << LogIO::SEVERE << cMsg << LogIO::POST ; 147 149 return 1; 148 150 } … … 161 163 jstat = -1; 162 164 if (rpfitsin(jstat)) { 163 sprintf(cMsg, " ERROR:Failed to read MBFITS header in file\n"164 " 165 logMsg(cMsg);165 sprintf(cMsg, "Failed to read MBFITS header in file\n" 166 "%s", rpname); 167 os << LogIO::SEVERE << cMsg << LogIO::POST ; 166 168 close(); 167 169 return 1; … … 173 175 // Non-ATNF data may not store the position in (u,v,w). 174 176 if (strncmp(names_.sta, "tid", 3) == 0) { 175 sprintf(cMsg, " WARNING:Found Tidbinbilla data");177 sprintf(cMsg, "Found Tidbinbilla data"); 176 178 cSUpos = 1; 177 179 } else if (strncmp(names_.sta, "HOB", 3) == 0) { 178 sprintf(cMsg, " WARNING:Found Hobart data");180 sprintf(cMsg, "Found Hobart data"); 179 181 cSUpos = 1; 180 182 } else if (strncmp(names_.sta, "CED", 3) == 0) { 181 sprintf(cMsg, " WARNING:Found Ceduna data");183 sprintf(cMsg, "Found Ceduna data"); 182 184 cSUpos = 1; 183 185 } else { … … 187 189 if (cSUpos) { 188 190 strcat(cMsg, ", using telescope position\n from SU table."); 189 logMsg(cMsg);191 os << LogIO::WARN << cMsg << LogIO::POST ; 190 192 cInterp = 0; 191 193 } … … 207 209 208 210 if (cNBeam <= 0) { 209 logMsg("ERROR: Couldn't determine number of beams.");211 os << LogIO::SEVERE << "Couldn't determine number of beams." << LogIO::POST ; 210 212 close(); 211 213 return 1; … … 232 234 233 235 sprintf(cMsg, 234 " WARNING:RPFITSIN returned beam number %2d for AN table\n"235 " 236 "RPFITSIN returned beam number %2d for AN table\n" 237 "entry %2d with name '%.8s'", beamNo, iBeam+1, sta); 236 238 237 239 char text[8]; … … 245 247 } 246 248 247 logMsg(cMsg);249 os << LogIO::WARN << cMsg << LogIO::POST ; 248 250 } 249 251 … … 339 341 // Read the first syscal record. 340 342 if (rpget(1, cEOS)) { 341 logMsg("ERROR: Failed to read first syscal record.");343 os << LogIO::SEVERE << "Failed to read first syscal record." << LogIO::POST ; 342 344 close(); 343 345 return 1; … … 374 376 double &bandwidth) 375 377 { 378 const string methodName = "getHeader()" ; 379 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 380 376 381 if (!cMBopen) { 377 logMsg("ERROR: An MBFITS file has not been opened.");382 os << LogIO::SEVERE << "An MBFITS file has not been opened." << LogIO::POST ; 378 383 return 1; 379 384 } … … 511 516 MBrecord &MBrec) 512 517 { 518 const string methodName = "read()" ; 519 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 520 513 521 int beamNo = -1; 514 522 int haveData, pCode = 0, status; … … 517 525 518 526 if (!cMBopen) { 519 logMsg("ERROR: An MBFITS file has not been opened.");527 os << LogIO::SEVERE << "An MBFITS file has not been opened." << LogIO::POST ; 520 528 return 1; 521 529 } … … 562 570 563 571 #ifdef PKSIO_DEBUG 564 fprintf(stderr, "\nEnd-of-file detected, flushing last cycle.\n");572 os << LogIO::DEBUGGING << "\nEnd-of-file detected, flushing last cycle.\n" << LogIO::POST ; 565 573 #endif 566 574 … … 646 654 647 655 if (cNBin > 1 && cNBeamSel > 1) { 648 logMsg("ERROR: Cannot handle binning mode for multiple beams.\n" 649 " Select a single beam for input."); 656 os << LogIO::SEVERE << "Cannot handle binning mode for multiple beams.\nSelect a single beam for input." << LogIO::POST ; 650 657 close(); 651 658 return 1; … … 717 724 // the start of the next. 718 725 #ifdef PKSIO_DEBUG 719 fprintf(stderr, "Change-of-day on cUTC: %.1f -> %.1f\n", 720 cPrevUTC, cUTC); 726 char buf[256] ; 727 sprintf(buf, "Change-of-day on cUTC: %.1f -> %.1f\n", cPrevUTC, cUTC); 728 os << LogIO::DEBUGGING << buf << LogIO::POST ; 721 729 #endif 722 730 // Can't change the recorded value of cUTC directly (without also … … 724 732 // an offset to be applied when comparing integration timestamps. 725 733 cod = 86400.0; 726 } 734 735 } 727 736 728 737 if ((cUTC+cod) < cPrevUTC - 1.0) { … … 738 747 // All other data should be fully time ordered. 739 748 sprintf(cMsg, 740 " WARNING:Cycle %d:%03d-%03d, UTC went backwards from\n"741 " 742 " 749 "Cycle %d:%03d-%03d, UTC went backwards from\n" 750 "%.1f to %.1f! Incrementing day number,\n" 751 "positions may be unreliable.", cScanNo, cCycleNo, 743 752 cCycleNo+1, cPrevUTC, cUTC); 744 logMsg(cMsg); 753 //logMsg(cMsg); 754 os << LogIO::WARN << cMsg << LogIO::POST ; 745 755 cUTC += 86400.0; 746 756 } … … 782 792 } 783 793 784 fprintf(stderr, "\n In:%4d%4d%3d%3d %.3f %c %.3f (%+.3fs) - "794 sprintf(buf, "\n In:%4d%4d%3d%3d %.3f %c %.3f (%+.3fs) - " 785 795 "%sflushing\n", cScanNo, cCycleNo, beamNo, cIFno, cUTC, rel, cW, dt, 786 796 cFlushing ? "" : "not "); 797 os << LogIO::DEBUGGING << buf << LogIO::POST ; 787 798 if (cEOS) { 788 fprintf(stderr, "Start of new scan, flushing previous scan.\n"); 799 sprintf(buf, "Start of new scan, flushing previous scan.\n"); 800 os << LogIO::DEBUGGING << buf << LogIO::POST ; 789 801 } 790 802 #endif … … 884 896 885 897 #ifdef PKSIO_DEBUG 886 fprintf(stderr, "This (%d) ra, dec, UTC: %9.4f %9.4f %10.3f %9.4f\n",898 sprintf(buf, "This (%d) ra, dec, UTC: %9.4f %9.4f %10.3f %9.4f\n", 887 899 iMBuff->cycleNo, thisRA*R2D, thisDec*R2D, thisUTC, thisPA*R2D); 900 os << LogIO::DEBUGGING << buf << LogIO::POST ; 888 901 #endif 889 902 … … 921 934 922 935 #ifdef PKSIO_DEBUG 923 fprintf(stderr, "Next (%d) ra, dec, UTC: %9.4f %9.4f %10.3f "936 sprintf(buf, "Next (%d) ra, dec, UTC: %9.4f %9.4f %10.3f " 924 937 "(0.000s)\n", cCycleNo, cU*R2D, cV*R2D, cW); 938 os << LogIO::DEBUGGING << buf << LogIO::POST ; 925 939 #endif 926 940 … … 937 951 938 952 #ifdef PKSIO_DEBUG 939 fprintf(stderr, "Next (%d) ra, dec, UTC: %9.4f %9.4f %10.3f "953 sprintf(buf, "Next (%d) ra, dec, UTC: %9.4f %9.4f %10.3f " 940 954 "(%+.3fs)\n", cCycleNo, nextRA*R2D, nextDec*R2D, nextUTC, 941 955 utcDiff(nextUTC, thisUTC)); 956 os << LogIO::DEBUGGING << buf << LogIO::POST ; 942 957 #endif 943 958 … … 1089 1104 #ifdef PKSIO_DEBUG 1090 1105 double avRate = sqrt(cAvRate[0]*cAvRate[0] + cAvRate[1]*cAvRate[1]); 1091 fprintf(stderr, "RA, Dec, Av & PA rates: %8.4f %8.4f %8.4f %8.4f "1106 sprintf(buf, "RA, Dec, Av & PA rates: %8.4f %8.4f %8.4f %8.4f " 1092 1107 "pCode %d\n", raRate*R2D, decRate*R2D, avRate*R2D, paRate*R2D, pCode); 1108 os << LogIO::DEBUGGING << buf << LogIO::POST ; 1093 1109 #endif 1094 1110 … … 1113 1129 1114 1130 #ifdef PKSIO_DEBUG 1115 fprintf(stderr, "Intp (%d) ra, dec, UTC: %9.4f %9.4f %10.3f (pCode, "1131 sprintf(buf, "Intp (%d) ra, dec, UTC: %9.4f %9.4f %10.3f (pCode, " 1116 1132 "age: %d %.1fs)\n", iMBuff->cycleNo, cBuffer[jbuff].ra*R2D, 1117 1133 cBuffer[jbuff].dec*R2D, cBuffer[jbuff].utc, iMBuff->pCode, 1118 1134 iMBuff->rateAge); 1135 os << LogIO::DEBUGGING << buf << LogIO::POST ; 1119 1136 #endif 1120 1137 } … … 1130 1147 1131 1148 #ifdef PKSIO_DEBUG 1132 fprintf(stderr, "Out:%4d%4d%3d%3d\n", MBrec.scanNo, MBrec.cycleNo,1149 sprintf(buf, "Out:%4d%4d%3d%3d\n", MBrec.scanNo, MBrec.cycleNo, 1133 1150 MBrec.beamNo, MBrec.IFno[0]); 1151 os << LogIO::DEBUGGING << buf << LogIO::POST ; 1134 1152 #endif 1135 1153 … … 1172 1190 // Sanity check on the number of IFs in the new scan. 1173 1191 if (if_.n_if != cNIF) { 1174 sprintf(cMsg, " WARNING:Scan %d has %d IFs instead of %d, "1192 sprintf(cMsg, "Scan %d has %d IFs instead of %d, " 1175 1193 "continuing.", cScanNo, if_.n_if, cNIF); 1176 logMsg(cMsg);1194 os << LogIO::WARN << cMsg << LogIO::POST ; 1177 1195 } 1178 1196 } … … 1186 1204 1187 1205 #ifdef PKSIO_DEBUG 1188 fprintf(stderr, "Buf:%4d%4d%3d%3d\n", cScanNo, cCycleNo, beamNo, cIFno); 1206 sprintf(buf, "Buf:%4d%4d%3d%3d\n", cScanNo, cCycleNo, beamNo, cIFno); 1207 os << LogIO::DEBUGGING << buf << LogIO::POST ; 1189 1208 #endif 1190 1209 … … 1265 1284 // Integration cycle written to the output file twice (the only known 1266 1285 // example is 1999-05-22_1914_000-031805_03v.hpf). 1267 sprintf(cMsg, " WARNING:Integration cycle %d:%d, beam %2d, \n"1268 " 1286 sprintf(cMsg, "Integration cycle %d:%d, beam %2d, \n" 1287 "IF %d was duplicated.", cScanNo, cCycleNo-1, 1269 1288 beamNo, cIFno); 1270 logMsg(cMsg);1289 os << LogIO::WARN << cMsg << LogIO::POST ; 1271 1290 } 1272 1291 iMBuff->nChan[iIFSel] = nChan; … … 1454 1473 int MBFITSreader::rpget(int syscalonly, int &EOS) 1455 1474 { 1475 const string methodName = "rpget()" ; 1476 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 1477 1456 1478 EOS = 0; 1457 1479 … … 1469 1491 // Read failed; retry. 1470 1492 numErr++; 1471 logMsg("WARNING: RPFITS read failed - retrying.");1493 os << LogIO::WARN << "RPFITS read failed - retrying." << LogIO::POST ; 1472 1494 jstat = 0; 1473 1495 break; … … 1525 1547 default: 1526 1548 // Shouldn't reach here. 1527 sprintf(cMsg, " WARNING:Unrecognized RPFITSIN return code: %d "1549 sprintf(cMsg, "Unrecognized RPFITSIN return code: %d " 1528 1550 "(retrying).", jstat); 1529 logMsg(cMsg);1551 os << LogIO::WARN << cMsg << LogIO::POST ; 1530 1552 jstat = 0; 1531 1553 break; … … 1533 1555 } 1534 1556 1535 logMsg("ERROR: RPFITS read failed too many times.");1557 os << LogIO::SEVERE << "RPFITS read failed too many times." << LogIO::POST ; 1536 1558 return 2; 1537 1559 } … … 1549 1571 1550 1572 // Handle messages from RPFITSIN. 1573 /** 1551 1574 if (names_.errmsg[0] != ' ') { 1552 1575 int i; … … 1559 1582 logMsg(cMsg); 1560 1583 } 1561 1584 **/ 1562 1585 return jstat; 1563 1586 }
Note:
See TracChangeset
for help on using the changeset viewer.