Changeset 3047 in Sophya


Ignore:
Timestamp:
Aug 11, 2006, 10:42:10 AM (19 years ago)
Author:
ansari
Message:

Ajout FitsInOutFile::SkipEmptyFirstHDU() , positionnement sur HDU 2 si HDU 1 vide ds operateur >> lisant des tables + autres petites corrections , Reza 11/08/2006

Location:
trunk/SophyaExt/FitsIOServer
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fitshdtable.h

    r2864 r3047  
    2121
    2222inline FitsInOutFile& operator >> (FitsInOutFile& is, BaseDataTable & obj)
    23   { FitsHandler<BaseDataTable> fio(obj); fio.Read(is); is.MoveToNextHDU(); return(is); }
     23  { FitsHandler<BaseDataTable> fio(obj); is.SkipEmptyFirstHDU();
     24  fio.Read(is); is.MoveToNextHDU(); return(is); }
    2425
    2526
  • trunk/SophyaExt/FitsIOServer/fitsinoutfile.cc

    r2937 r3047  
    322322    return MoveRelToHDU(1);
    323323  else return -1;
     324}
     325
     326/*-- Methode --*/
     327/*!
     328  Skip HDU 1 if NAXIS=0 (no data), on a file opened for reading.
     329  return true if moved to HDU No 2
     330*/
     331bool FitsInOutFile::SkipEmptyFirstHDU()
     332{
     333  if (fptr_ == NULL) return false;
     334  if (mode_ == Fits_Create) return false;
     335  if (CurrentHDU() != 1) return false;
     336  int naxis = 2;
     337  long naxes[2];
     338  GetImageHDUInfo(naxis, naxes);
     339  if ((naxis == 0) &&  (NbHDUs() > 1)) {
     340    MoveRelToHDU(1);
     341    return true;
     342  }
     343  return false;
    324344}
    325345
  • trunk/SophyaExt/FitsIOServer/fitsinoutfile.h

    r2974 r3047  
    112112 //! Move to the next HDU specified by relhdu. Returns the newly opened HDU type (<0 at EOF)
    113113 int               MoveToNextHDU();
     114 //! Skip the first HDU if it contains no data.
     115 bool              SkipEmptyFirstHDU();
    114116
    115117 //---- IMAGE_HDU manipulation methods
  • trunk/SophyaExt/FitsIOServer/fitslocalmap.cc

    r2898 r3047  
    8181int FITS_LocalMap<T>::CheckReadability(FitsInOutFile& is)
    8282{
    83   if (is.CurrentHDUType() !=  BINARY_TBL ) return 0;
     83  if (is.CurrentHDUType() !=  IMAGE_HDU ) return 0;
    8484  string key;
    8585  key = "Content";
    8686  string clsnm = is.KeyValue(key);
    8787  if (clsnm != "LocalMap") return 0;
    88 
    89   vector<string> colnames;
    90   vector<int> coltypes;
    91   vector<long> repcnt;
    92   vector<long> width;
    93   long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
    94   if (ncols < 1) return 0;
     88 
     89  long naxes[2];
     90  int naxis=2;
     91  int imgtyp = is.GetImageHDUInfo(naxis, naxes);
     92  if (naxis != 2) return 0;
     93
    9594  T x = 0;
    96   if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
     95  if (imgtyp == FitsTypes::ImageType(x)) return 2 ;
    9796  else return 1;
    9897}
     
    132131  //
    133132  if (!is.IsFitsImage())
    134     {
    135       throw PException("ReadFromFits: the fits file seems not to be an image");
    136     }
     133    throw PException("ReadFromFits: the fits file seems not to be an image");
    137134  int dimension = is.nbDimOfImage();
    138135  if (dimension != 2 )
    139     {
    140       cout << " WARNING::ReadFromFits: the fits image seems not to be a matrix" << endl;
    141     }
     136    cout << " WARNING::ReadFromFits: the fits image seems not to be a matrix" << endl;
     137
    142138  nbentries =  is.nbOfImageData();
    143139  //
     
    149145  int_4 nPix = dvl.GetI("NPIX");
    150146  if (nPix != nbentries)
    151     {
    152       throw IOExc("longueur datablock incompatible avec nPix");
    153     }
     147    throw IOExc("longueur datablock incompatible avec nPix");
    154148  dobj_->ReSize(nSzX, nSzY);
    155149  int_4 localMappingDone = dvl.GetI("LCMP");
  • trunk/SophyaExt/FitsIOServer/fitslocalmap.h

    r3035 r3047  
    5252template <class T>
    5353inline FitsInOutFile& operator >> (FitsInOutFile& fiis, LocalMap<T> & lm)
    54   { FITS_LocalMap<T> fih(&lm); fih.Read(fiis); return (fiis); }
     54  { FITS_LocalMap<T> fih(&lm); fih.Read(fiis);
     55  fiis.MoveToNextHDU(); return (fiis); }
    5556
    5657} // Fin du namespace
  • trunk/SophyaExt/FitsIOServer/fitsntuple.h

    r3035 r3047  
    8181
    8282inline FitsInOutFile& operator >> (FitsInOutFile& fiis, NTuple & nt)
    83   { FITS_NTuple fih(&nt); fih.Read(fiis); return (fiis); }
     83  { FITS_NTuple fih(&nt); fiis.SkipEmptyFirstHDU();
     84  fih.Read(fiis); fiis.MoveToNextHDU(); return (fiis); }
    8485
    8586
  • trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc

    r2979 r3047  
    172172void FITS_SphereHEALPix<T>::ReadFromFits(FitsInFile& is)
    173173{
    174   if(dobj_ == NULL)
    175     {
    176       dobj_= new SphereHEALPix<T>;
    177       ownobj_= true;     
    178     }
     174  if (is.CurrentHDUType() != BINARY_TBL )
     175    throw FitsIOException("FITS_SphereHEALPix<T>::ReadFromFits Not a binary table HDU");
     176
     177  if(dobj_ == NULL) {
     178    dobj_= new SphereHEALPix<T>;
     179    ownobj_= true;     
     180  }
    179181  int nbcols, nbentries;
    180182  //
  • trunk/SophyaExt/FitsIOServer/fitsspherehealpix.h

    r3035 r3047  
    5656template <class T>
    5757inline FitsInOutFile& operator >> (FitsInOutFile& fiis, SphereHEALPix<T> & sph)
    58   { FITS_SphereHEALPix<T> fih(&sph); fih.Read(fiis); return (fiis); }
     58  { FITS_SphereHEALPix<T> fih(&sph); fiis.SkipEmptyFirstHDU();
     59  fih.Read(fiis); fiis.MoveToNextHDU(); return (fiis); }
    5960
    6061
  • trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.h

    r3035 r3047  
    5858template <class T>
    5959inline FitsInOutFile& operator >> (FitsInOutFile& fiis, SphereThetaPhi<T> & sph)
    60   { FITS_SphereThetaPhi<T> fih(&sph); fih.Read(fiis); return (fiis); }
     60  { FITS_SphereThetaPhi<T> fih(&sph); fiis.SkipEmptyFirstHDU();
     61  fih.Read(fiis); fiis.MoveToNextHDU(); return (fiis); }
    6162
    6263
Note: See TracChangeset for help on using the changeset viewer.