Ignore:
Timestamp:
Jan 13, 2006, 7:26:40 PM (20 years ago)
Author:
ansari
Message:

Ajout methode FitsManager::ScanFile() et corrections diverses - Reza 13/01/2006

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fitsmanager.cc

    r2895 r2898  
    7575  for(it = hlistp->begin(); it != hlistp->end(); it++) {
    7676    hfg = (*it).fhi->CheckHandling(o);
     77    if (hfg < 1) continue;
    7778    if ( ( hfg > bhfg ) || ( (hfg == bhfg) && ((*it).glev > blev) ) ) {
    7879      fhi = (*it).fhi;  bhfg = hfg;  blev = (*it).glev;
     
    114115  for(it = hlistp->begin(); it != hlistp->end(); it++) {
    115116    hfg = (*it).fhi->CheckReadability(is);
     117    if (hfg < 1) continue;
    116118    if ( ( hfg > bhfg ) || ( (hfg == bhfg) && ((*it).glev > blev) ) ) {
    117119      fhi = (*it).fhi;  bhfg = hfg;  blev = (*it).glev;
     
    136138  return fhi2;
    137139}
     140
     141/*!
     142  \param filename : FITS file name to be scanned
     143  \param os : infomation will be sent to formatted stream os
     144  \param slev : scan level , bit 0 (1/3) print HDU keywords,
     145  bit 2 (2,3) try to read HDU data using the appropraite handler
     146  \param Rc : return number of scanned HDU's
     147 */
     148int FitsManager::ScanFile(string filename, ostream& os, int slev)
     149{
     150  FitsInOutFile is(filename, FitsInOutFile::Fits_RO);
     151  os << "=== FitsManager::ScanFile( " << filename << " ) NbHDUs= "
     152     << is.NbHDUs() << endl;
     153  int rc = 0;
     154  for(int k=0; k<is.NbHDUs(); k++) {
     155    os << " ------ HDU No " << is.CurrentHDU() << " Type= "
     156         << is.CurrentHDUTypeStr() << endl;
     157    int hdutyp = is.CurrentHDUType();
     158    if (hdutyp == IMAGE_HDU) {
     159      long naxes[5] = {0,0,0,0,0};
     160      int naxis=5;
     161      int imgtyp = is.GetImageHDUInfo(naxis, naxes);
     162      os << ">> IMAGE_HDU:  naxis= " << naxis << " : ";
     163      for(int i=0; i<naxis; i++) {
     164        if (i>0) os << " x " ;
     165        os << naxes[i];
     166      }
     167      os << endl;
     168    }
     169    else {
     170      vector<string> colnames;
     171      vector<int> coltypes;
     172      vector<long> repcnt;
     173      vector<long> width;
     174      int ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
     175      if (hdutyp == BINARY_TBL) os << ">> BINARY_TBL :  NRows= " << is.GetNbRows();
     176      else os << ">> ASCII_TBL :  NRows= " << is.GetNbRows();
     177      os << " x NCols= " << ncols << endl;
     178      for(int kk=0; kk<colnames.size(); kk++) {
     179        os << "Col[" << kk+1 << "]  Name= " << colnames[kk]
     180             << " Type= " << FitsTypes::DataTypeToTypeString(coltypes[kk])
     181             << " Repeat= " << repcnt[kk]
     182             << " W= " << width[kk] << endl;
     183      }
     184    }
     185    // Fin the appropriate handler :
     186    ChkHLP();
     187    FitsHandlerInterface * fhi = NULL;
     188    HandlerList::iterator it;
     189    string hdesc;
     190    int hfg = 0;
     191    int bhfg = 0;
     192    int blev = 0;
     193    for(it = hlistp->begin(); it != hlistp->end(); it++) {
     194      hfg = (*it).fhi->CheckReadability(is);
     195      if (hfg < 1) continue;
     196      if ( ( hfg > bhfg ) || ( (hfg == bhfg) && ((*it).glev > blev) ) ) {
     197        fhi = (*it).fhi;  bhfg = hfg;  blev = (*it).glev; hdesc = (*it).desc;
     198      }
     199    }
     200    if (fhi == NULL)
     201      os << ">>> Warning : No handler found for this HDU ... " << endl;
     202    else
     203      os << ">>> Reader/handler: " <<  hdesc << " : "
     204         << typeid(*fhi).name() << " HandLevel= " << blev << ", "  << bhfg << endl;
     205    if (fhi && (slev >= 2)) {
     206      os << ">>> Trying to read HDU data using the handler ..." << endl;
     207      FitsHandlerInterface* fhic = fhi->Clone();
     208      fhic->Read(is);
     209      os << " FitsHandler.Read() OK " << endl;
     210    }
     211    if ( (slev == 1) || (slev == 3) ) {
     212      os << ">>>> HDU keywords list :  " <<  endl;
     213      DVList dvl;
     214      is.GetHeaderRecords(dvl);
     215      os << dvl;
     216    }
     217    os << "               --------------------- " << endl;
     218    is.MoveToNextHDU();
     219    rc++;
     220  }
     221  os << "===================================================" << endl;
     222  return rc;
     223}
Note: See TracChangeset for help on using the changeset viewer.