Ignore:
Timestamp:
07/29/10 19:13:46 (14 years ago)
Author:
Kana Sugimoto
Message:

New Development: Yes

JIRA Issue: No (test merging alma branch)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s):

Description:


Location:
branches/mergetest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/mergetest

  • branches/mergetest/external/atnf/PKSIO/MBFITSreader.cc

    r1720 r1779  
    4141#include <atnf/PKSIO/MBrecord.h>
    4242
     43#include <casa/Logging/LogIO.h>
     44
    4345#include <casa/math.h>
    4446#include <casa/iostream.h>
     
    5759const double HALFPI = PI / 2.0;
    5860const double R2D = 180.0 / PI;
     61
     62// Class name
     63const string className = "MBFITSreader" ;
    5964
    6065//------------------------------------------------- MBFITSreader::MBFITSreader
     
    99104
    100105  // 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;
    105107}
    106108
     
    131133        int  &extraSysCal)
    132134{
    133   // Clear the message stack.
    134   clearMsg();
     135  const string methodName = "open()" ;
     136  LogIO os( LogOrigin( className, methodName, WHERE ) ) ;
    135137
    136138  if (cMBopen) {
     
    143145  int jstat = -3;
    144146  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 ;
    147149    return 1;
    148150  }
     
    161163  jstat = -1;
    162164  if (rpfitsin(jstat)) {
    163     sprintf(cMsg, "ERROR: Failed to read MBFITS header in file\n"
    164                   "       %s", rpname);
    165     logMsg(cMsg);
     165    sprintf(cMsg, "Failed to read MBFITS header in file\n"
     166                  "%s", rpname);
     167    os << LogIO::SEVERE << cMsg << LogIO::POST ;
    166168    close();
    167169    return 1;
     
    173175  // Non-ATNF data may not store the position in (u,v,w).
    174176  if (strncmp(names_.sta, "tid", 3) == 0) {
    175     sprintf(cMsg, "WARNING: Found Tidbinbilla data");
     177    sprintf(cMsg, "Found Tidbinbilla data");
    176178    cSUpos = 1;
    177179  } else if (strncmp(names_.sta, "HOB", 3) == 0) {
    178     sprintf(cMsg, "WARNING: Found Hobart data");
     180    sprintf(cMsg, "Found Hobart data");
    179181    cSUpos = 1;
    180182  } else if (strncmp(names_.sta, "CED", 3) == 0) {
    181     sprintf(cMsg, "WARNING: Found Ceduna data");
     183    sprintf(cMsg, "Found Ceduna data");
    182184    cSUpos = 1;
    183185  } else {
     
    187189  if (cSUpos) {
    188190    strcat(cMsg, ", using telescope position\n         from SU table.");
    189     logMsg(cMsg);
     191    os << LogIO::WARN << cMsg << LogIO::POST ;
    190192    cInterp = 0;
    191193  }
     
    207209
    208210  if (cNBeam <= 0) {
    209     logMsg("ERROR: Couldn't determine number of beams.");
     211    os << LogIO::SEVERE << "Couldn't determine number of beams." << LogIO::POST ;
    210212    close();
    211213    return 1;
     
    232234
    233235      sprintf(cMsg,
    234         "WARNING: RPFITSIN returned beam number %2d for AN table\n"
    235         "         entry %2d with name '%.8s'", beamNo, iBeam+1, sta);
     236        "RPFITSIN returned beam number %2d for AN table\n"
     237        "entry %2d with name '%.8s'", beamNo, iBeam+1, sta);
    236238
    237239      char text[8];
     
    245247      }
    246248
    247       logMsg(cMsg);
     249      os << LogIO::WARN << cMsg << LogIO::POST ;
    248250    }
    249251
     
    339341  // Read the first syscal record.
    340342  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 ;
    342344    close();
    343345    return 1;
     
    374376        double &bandwidth)
    375377{
     378  const string methodName = "getHeader()" ;
     379  LogIO os( LogOrigin( className, methodName, WHERE ) ) ;
     380
    376381  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 ;
    378383    return 1;
    379384  }
     
    511516        MBrecord &MBrec)
    512517{
     518  const string methodName = "read()" ;
     519  LogIO os( LogOrigin( className, methodName, WHERE ) ) ;
     520
    513521  int beamNo = -1;
    514522  int haveData, pCode = 0, status;
     
    517525
    518526  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 ;
    520528    return 1;
    521529  }
     
    562570
    563571#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 ;
    565573#endif
    566574
     
    646654
    647655          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 ;
    650657            close();
    651658            return 1;
     
    717724          // the start of the next.
    718725#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 ;
    721729#endif
    722730          // Can't change the recorded value of cUTC directly (without also
     
    724732          // an offset to be applied when comparing integration timestamps.
    725733          cod = 86400.0;
    726         }
     734
     735        }
    727736
    728737        if ((cUTC+cod) < cPrevUTC - 1.0) {
     
    738747            // All other data should be fully time ordered.
    739748            sprintf(cMsg,
    740               "WARNING: Cycle %d:%03d-%03d, UTC went backwards from\n"
    741               "         %.1f to %.1f!  Incrementing day number,\n"
    742               "         positions may be unreliable.", cScanNo, cCycleNo,
     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,
    743752              cCycleNo+1, cPrevUTC, cUTC);
    744             logMsg(cMsg);
     753            //logMsg(cMsg);
     754            os << LogIO::WARN << cMsg << LogIO::POST ;
    745755            cUTC += 86400.0;
    746756          }
     
    782792        }
    783793
    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) - "
    785795          "%sflushing\n", cScanNo, cCycleNo, beamNo, cIFno, cUTC, rel, cW, dt,
    786796          cFlushing ? "" : "not ");
     797        os << LogIO::DEBUGGING << buf << LogIO::POST ;
    787798        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 ;
    789801        }
    790802#endif
     
    884896
    885897#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",
    887899        iMBuff->cycleNo, thisRA*R2D, thisDec*R2D, thisUTC, thisPA*R2D);
     900      os << LogIO::DEBUGGING << buf << LogIO::POST ;
    888901#endif
    889902
     
    921934
    922935#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 "
    924937            "(0.000s)\n", cCycleNo, cU*R2D, cV*R2D, cW);
     938          os << LogIO::DEBUGGING << buf << LogIO::POST ;
    925939#endif
    926940
     
    937951
    938952#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 "
    940954            "(%+.3fs)\n", cCycleNo, nextRA*R2D, nextDec*R2D, nextUTC,
    941955            utcDiff(nextUTC, thisUTC));
     956          os << LogIO::DEBUGGING << buf << LogIO::POST ;
    942957#endif
    943958
     
    10891104#ifdef PKSIO_DEBUG
    10901105      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 "
    10921107        "pCode %d\n", raRate*R2D, decRate*R2D, avRate*R2D, paRate*R2D, pCode);
     1108      os << LogIO::DEBUGGING << buf << LogIO::POST ;
    10931109#endif
    10941110
     
    11131129
    11141130#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, "
    11161132          "age: %d %.1fs)\n", iMBuff->cycleNo, cBuffer[jbuff].ra*R2D,
    11171133          cBuffer[jbuff].dec*R2D, cBuffer[jbuff].utc, iMBuff->pCode,
    11181134          iMBuff->rateAge);
     1135        os << LogIO::DEBUGGING << buf << LogIO::POST ;
    11191136#endif
    11201137      }
     
    11301147
    11311148#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,
    11331150        MBrec.beamNo, MBrec.IFno[0]);
     1151      os << LogIO::DEBUGGING << buf << LogIO::POST ;
    11341152#endif
    11351153
     
    11721190        // Sanity check on the number of IFs in the new scan.
    11731191        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, "
    11751193            "continuing.", cScanNo, if_.n_if, cNIF);
    1176           logMsg(cMsg);
     1194          os << LogIO::WARN << cMsg << LogIO::POST ;
    11771195        }
    11781196      }
     
    11861204
    11871205#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 ;
    11891208#endif
    11901209
     
    12651284        // Integration cycle written to the output file twice (the only known
    12661285        // example is 1999-05-22_1914_000-031805_03v.hpf).
    1267         sprintf(cMsg, "WARNING: Integration cycle %d:%d, beam %2d, \n"
    1268                       "         IF %d was duplicated.", cScanNo, cCycleNo-1,
     1286        sprintf(cMsg, "Integration cycle %d:%d, beam %2d, \n"
     1287                      "IF %d was duplicated.", cScanNo, cCycleNo-1,
    12691288                      beamNo, cIFno);
    1270         logMsg(cMsg);
     1289        os << LogIO::WARN << cMsg << LogIO::POST ;
    12711290      }
    12721291      iMBuff->nChan[iIFSel] = nChan;
     
    14541473int MBFITSreader::rpget(int syscalonly, int &EOS)
    14551474{
     1475  const string methodName = "rpget()" ;
     1476  LogIO os( LogOrigin( className, methodName, WHERE ) ) ;
     1477
    14561478  EOS = 0;
    14571479
     
    14691491      // Read failed; retry.
    14701492      numErr++;
    1471       logMsg("WARNING: RPFITS read failed - retrying.");
     1493      os << LogIO::WARN << "RPFITS read failed - retrying." << LogIO::POST ;
    14721494      jstat = 0;
    14731495      break;
     
    15251547    default:
    15261548      // Shouldn't reach here.
    1527       sprintf(cMsg, "WARNING: Unrecognized RPFITSIN return code: %d "
     1549      sprintf(cMsg, "Unrecognized RPFITSIN return code: %d "
    15281550                    "(retrying).", jstat);
    1529       logMsg(cMsg);
     1551      os << LogIO::WARN << cMsg << LogIO::POST ;
    15301552      jstat = 0;
    15311553      break;
     
    15331555  }
    15341556
    1535   logMsg("ERROR: RPFITS read failed too many times.");
     1557  os << LogIO::SEVERE << "RPFITS read failed too many times." << LogIO::POST ;
    15361558  return 2;
    15371559}
     
    15491571
    15501572  // Handle messages from RPFITSIN.
     1573/**
    15511574  if (names_.errmsg[0] != ' ') {
    15521575    int i;
     
    15591582    logMsg(cMsg);
    15601583  }
    1561 
     1584**/
    15621585  return jstat;
    15631586}
Note: See TracChangeset for help on using the changeset viewer.