Changeset 2898 in Sophya for trunk/SophyaExt


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

Location:
trunk/SophyaExt/FitsIOServer
Files:
9 edited

Legend:

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

    r2897 r2898  
    3232//   Enregistrement des classes FitsHandler
    3333//  FitsManager::RegisterHandler(new FitsArrayHandler<int_2> , "TArray<int_2>");
    34   cout << " ---- FitsIOServerInitiator / DEBUG ---- debut RegisterHandler " << endl;
     34  //DBG   cout << " ---- FitsIOServerInitiator / DEBUG ---- debut RegisterHandler " << endl;
    3535  FitsManager::RegisterHandler(new FitsArrayHandler<int_4> , 1, "TArray<int_4> ");
    3636  FitsManager::RegisterHandler(new FitsArrayHandler<r_4> , 1, "TArray<r_4>");
     
    5454  FitsManager::RegisterHandler(new FITS_LocalMap<int_4> , 0, "LocalMap<int_4>");
    5555
    56   cout << " ---- FitsIOServerInitiator / DEBUG ---- ListHandlers() : " << endl;
    57   FitsManager::ListHandlers();
     56  //DBG  cout << " ---- FitsIOServerInitiator / DEBUG ---- ListHandlers() : " << endl;
     57  //DBG  FitsManager::ListHandlers();
    5858}
    5959
  • trunk/SophyaExt/FitsIOServer/fitsarrhand.h

    r2864 r2898  
    5252    long naxes[BASEARRAY_MAXNDIMS];
    5353    int naxis=BASEARRAY_MAXNDIMS;
    54     if (FitsTypes::ImageType(x) == is.GetImageHDUInfo(naxis, naxes))
    55       return 2;
     54    int imgtyp = is.GetImageHDUInfo(naxis, naxes);
     55    if (naxis < 1) return 0;
     56    if (FitsTypes::ImageType(x) == imgtyp)  return 2;
    5657    else return 1;
    5758  }
  • trunk/SophyaExt/FitsIOServer/fitsfile.cc

    r2897 r2898  
    247247{
    248248  FitsInFile fis(is);
    249   fis.ReadHeader(0);
     249  fis.ReadHeader(fis.CurrentHDU());
    250250  ReadFromFits(fis);
    251251}
  • trunk/SophyaExt/FitsIOServer/fitslocalmap.cc

    r2897 r2898  
    9393  long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
    9494  if (ncols < 1) return 0;
    95   T x;
     95  T x = 0;
    9696  if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
    9797  else return 1;
  • 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}
  • trunk/SophyaExt/FitsIOServer/fitsmanager.h

    r2895 r2898  
    44#include "machdefs.h"
    55#include <string>
     6#include <iostream>
    67#include "fitsinoutfile.h"
    78
     
    2627  //! Finds the appropriate reader for the current HDU and reads the data form \b is
    2728  static FitsHandlerInterface * Read(FitsInOutFile& is);
     29  //! Scans the fits file and prints information about each HDU on formatted stream \b os
     30  static int ScanFile(string filename, ostream& os, int slev=0);
     31  //! Scans the fits file and prints information about each HDU on \b cout
     32  static inline int ScanFile(string filename, int slev=0)
     33    { return ScanFile(filename, cout, slev); }
     34
    2835 protected:
    2936  //! Finds the appropriate handler for the object \b o in the list of registered handlers.
  • trunk/SophyaExt/FitsIOServer/fitsntuple.cc

    r2897 r2898  
    6161  string clsnm = is.KeyValue(key);
    6262  if (clsnm == "SOPHYA::NTuple")  return 2;
     63  key = "Content";
     64  if (is.KeyValue(key) == "NTuple") return 2;
    6365  else return 1;
    6466}
  • trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc

    r2897 r2898  
    102102  long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
    103103  if (ncols < 1) return 0;
    104   T x;
     104  T x = 0;
    105105  if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
    106106  else return 1;
  • trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.cc

    r2897 r2898  
    9494  long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
    9595  if (ncols < 1) return 0;
    96   T x;
     96  T x = 0;
    9797  if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
    9898  else return 1;
Note: See TracChangeset for help on using the changeset viewer.