Changeset 1771 in Sophya for trunk/SophyaExt/FitsIOServer


Ignore:
Timestamp:
Nov 16, 2001, 11:26:58 AM (24 years ago)
Author:
lemeur
Message:

mises a jour pour ELDESTINO

Location:
trunk/SophyaExt/FitsIOServer
Files:
2 edited

Legend:

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

    r1752 r1771  
    350350      else hdunum_++;
    351351    }
    352   getHeader();
     352  getHeaderWithSophyaObject();
    353353  if ( hdutype_ == FitsExtensionType_NULL )
    354354    {
     
    356356        {
    357357          hdunum_++;
    358           getHeader();
     358          getHeaderWithSophyaObject();
    359359        }
    360360      else
     
    425425     }
    426426
     427void FitsInFile::GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const
     428{
     429  int status = 0;
     430  int hdutype;
     431  fits_movabs_hdu(fptr_,hdunum,&hdutype,&status);
     432  if( status ) fits_report_error(stderr,status);
     433
     434  // get number of keywords
     435  int nkeys,keypos;
     436  fits_get_hdrpos(fptr_, &nkeys, &keypos,&status);
     437  if( status ) fits_report_error(stderr,status);
     438  // shift with the number of mandatory keywords
     439  int num= 0;
     440  // if primary header
     441    if (hdunum == 1)
     442      {
     443        // read NAXIS
     444        int naxis=0;
     445        fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
     446        // number of mandatory keywords
     447        num = naxis+3;
     448      }
     449    // extensions
     450    else
     451      {
     452        if (hdutype == IMAGE_HDU)
     453          {
     454            // read NAXIS
     455            int naxis=0;
     456            fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
     457            // number of mandatory keywords
     458            num = naxis+5;
     459          }
     460        else
     461          if(hdutype == ASCII_TBL || hdutype == BINARY_TBL)
     462            {
     463              // number of mandatory keywords
     464              num = 8;
     465            }
     466      }
     467  int j;
     468  char keyname[LEN_KEYWORD]; 
     469  char value[FLEN_VALUE];
     470  char comment[FLEN_COMMENT];
     471  for(j = num+1; j <= nkeys; j++)
     472    {
     473      char dtype;
     474      fits_read_keyn(fptr_,j,keyname,value,comment,&status);
     475      if(status)
     476        {
     477          fits_report_error(stderr,status);
     478          status=0;
     479        }
     480      string  kn(keyname);
     481      string  cm(comment);
     482      string  val(value);
     483      FitsKeyword kw(kn, val, cm);
     484      mots_cles.push_back(kw);
     485    }
     486  if (hdunum_ > 0) fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
     487
     488}
    427489void FitsInFile::GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn)
    428490{
     
    482544   }
    483545
    484 void FitsInFile::getHeader()
     546void FitsInFile::getHeaderWithSophyaObject()
    485547{
    486548  // si hdunum_ > 1 lit le header correspondant
     
    526588          else
    527589            {
    528               cout << "WARNING (FitsInFile::getHeader) : error during movabs" << endl;
     590              cout << "WARNING (FitsInFile::getHeaderWithSophyaObject) : error during movabs" << endl;
    529591              hdutype_= FitsExtensionType_ERROR;
    530592              status =0;
     
    567629  int status = 0;
    568630  hdunum_++;
    569   getHeader();
     631  getHeaderWithSophyaObject();
    570632  if ( hdutype_ == FitsExtensionType_NULL )
    571633    {
     
    19281990void FitsOutFile::appendInputHeader(FitsInFile& infits, int hdunum)
    19291991{
     1992
     1993  infits.GetKeywordsFromHeader(hdunum, mots_cles_);
     1994  /*
    19301995  int status = 0;
    19311996  int hdutype;
     
    19862051      mots_cles_.push_back(kw);
    19872052    }
     2053  */
    19882054}
    19892055void FitsOutFile::writeAppendedHeaderOnFits()
  • trunk/SophyaExt/FitsIOServer/fitsfile.h

    r1703 r1771  
    105105   inline void firstImageOnPrimaryHeader(bool choice) {imageOnPrimary_=choice;}
    106106   inline int currentHeaderIndex() {return hdunum_;}
    107    inline fitsfile* fitsfilePtr() {return fptr_;}
    108107 
    109108
    110109 protected:
    111110
    112    void         ResetStatus(int& status) ;
    113    static  void printerror(int&) ;
    114    static  void printerror(int&,char* texte) ;
    115    static  void printerrorAndContinue(int& status, char* texte);
    116    inline void  InitNull() {fptr_ = NULL; hdutype_= FitsExtensionType_NULL; hdunum_ = 0;
    117    fits_status_ = 0; imageOnPrimary_ = true;}
     111void         ResetStatus(int& status) ;
     112static  void printerror(int&) ;
     113static  void printerror(int&,char* texte) ;
     114static  void printerrorAndContinue(int& status, char* texte);
     115inline void  InitNull()
     116  {
     117    fptr_ = NULL;
     118    hdutype_= FitsExtensionType_NULL;
     119    hdunum_ = 0;
     120    fits_status_ = 0; imageOnPrimary_ = true;
     121  }
     122inline fitsfile* fitsfilePtr() const {return fptr_;}
     123
     124
     125
    118126   fitsfile *fptr_;     /**<  pointer to the FITS file, defined in fitsio.h */
    119127   FitsExtensionType hdutype_;        /**<  image or bintable ? */
     
    145153  inline const DVList& DVListFromFits() const { return dvl_;}
    146154
     155  void GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const;
     156
     157
    147158  DVList  DVListFromPrimaryHeader() const;
    148159  void    moveToFollowingHeader();
     
    179190/*! \return data type of the current IMAGE extension */
    180191inline FitsFile::FitsDataType ImageType() const {return imageDataType_;}
     192
    181193
    182194
     
    237249
    238250void InitNull();
    239 void getHeader();
     251void getHeaderWithSophyaObject();
    240252static void KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum);
    241253static  void GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn);
Note: See TracChangeset for help on using the changeset viewer.