Ignore:
Timestamp:
Nov 13, 2003, 4:49:45 PM (22 years ago)
Author:
cmv
Message:

Restructuration des fits ecriteur et lecteur:

  • en lecture: lecture des images 2D
  • en ecriture: ecriture des images 2D d'ou restructuration des classes avec heritage sur une class FitWriter

Pour demande DY...

cmv 13/11/2003

File:
1 edited

Legend:

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

    r2450 r2453  
    1616namespace SOPHYA {
    1717
    18 //! Class for writing a FITS ASCII or BINARY table
    19 class FitsABTWriter : public AnyDataObj {
     18///////////////////////////////////////////////////////////////////////////
     19///////////////////////////////////////////////////////////////////////////
     20//! Class for writing into a FITS file (DO NOT USE)
     21class FitsWriter : public AnyDataObj {
     22protected:
     23  FitsWriter(string fname,int lp=0);
     24  FitsWriter(const char* cfname,int lp=0);
     25  FitsWriter(string fname,bool update,int lp=0);
     26  FitsWriter(const char* cfname,bool update,int lp=0);
     27  virtual ~FitsWriter();
     28
    2029public:
    21   FitsABTWriter(string fname,int hdutype=BINARY_TBL,int lp=0);
    22   FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
    23   FitsABTWriter(string fname,bool update,int hdutype=BINARY_TBL,int lp=0);
    24   FitsABTWriter(const char* cfname,bool update,int hdutype=BINARY_TBL,int lp=0);
    25   virtual ~FitsABTWriter();
    26 
    2730  void Flush(void);
    2831
     
    3639  inline void WriteKey(const char *keyname,char* val,char* comment=NULL)
    3740                      {string dum=val; WriteKey(keyname,dum,comment);}
     41  //! Set debug level
     42  inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
     43
     44  //! Return the number of overflows managed by cfitsio
     45  inline unsigned long GetNOverFlow(void) {return NOverFlow;}
     46
     47protected:
     48  struct KeyDouble {string keyname; double val; string comment;};
     49  struct KeyLong   {string keyname; long   val; string comment;};
     50  struct KeyString {string keyname; string val; string comment;};
     51
     52  void cr_or_upd_fits(const char *cfname,bool update,int lp);
     53
     54  void writekeys(void);
     55  void printerrorwrite(const char* type,int col,long row,int sta);
     56  void printerror(int sta) const;
     57
     58  string FitsFN,ExtName;
     59  bool Update;
     60  int HduType;
     61  unsigned short DbgLevel;
     62  fitsfile *FitsPtr;
     63  unsigned long NOverFlow;
     64
     65  vector<struct KeyDouble> DoubleKey;
     66  vector<struct KeyLong>   LongKey;
     67  vector<struct KeyString> StringKey;
     68};
     69
     70///////////////////////////////////////////////////////////////////////////
     71///////////////////////////////////////////////////////////////////////////
     72//! Class for writing a FITS ASCII or BINARY table
     73class FitsABTWriter : public FitsWriter {
     74public:
     75  FitsABTWriter(string fname,int hdutype=BINARY_TBL,int lp=0);
     76  FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
     77  FitsABTWriter(string fname,bool update,int hdutype=BINARY_TBL,int lp=0);
     78  FitsABTWriter(const char* cfname,bool update,int hdutype=BINARY_TBL,int lp=0);
     79  virtual ~FitsABTWriter();
     80
     81  //! Set the FITS table extension name
     82  inline void SetExtName(string extname=string("")) {ExtName = extname;}
     83  //! Set the FITS table extension name
     84  inline void SetExtName(char* extname="") {ExtName = extname;}
    3885
    3986  //! Add a new column to the FITS table and return its number (see addcol).
     
    4592                   ,const char* tunit="",int datatype=TDOUBLE)
    4693     {return addcol(label,tform,tunit,datatype);}
    47 
    48   //! Set the FITS table extension name
    49   inline void SetExtName(string extname=string("")) {ExtName = extname;}
    50   //! Set the FITS table extension name
    51   inline void SetExtName(char* extname="") {ExtName = extname;}
    52   //! Set debug level
    53   inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
    5494
    5595  void Write(int col,long row,uint_1 val);
     
    66106  long Write(int col,long row,TVector<float>& val);
    67107  long Write(int col,long row,TVector<double>& val);
    68   //! Return the number of overflows managed by cfitsio
    69   inline unsigned long GetNOverFlow(void) {return NOverFlow;}
    70108
    71109  //! Return the number of created columns
     
    78116
    79117protected:
    80   struct KeyDouble {string keyname; double val; string comment;};
    81   struct KeyLong   {string keyname; long   val; string comment;};
    82   struct KeyString {string keyname; string val; string comment;};
     118  int addcol(const char* label,const char* tform,const char* tunit,int datatype);
     119  void createtbl(void);
    83120
    84   void cr_or_upd_fits(const char *cfname,bool update,int hdutype,int lp);
    85   int addcol(const char* label,const char* tform
    86             ,const char* tunit,int datatype);
    87   void createtbl(void);
    88   void writekeys(void);
    89   void printerrorwrite(const char* type,int col,long row,int sta);
    90   void printerror(int sta) const;
    91 
    92   string FitsFN,ExtName;
    93   bool Update;
    94   int HduType;
    95   unsigned short DbgLevel;
    96   fitsfile *FitsPtr;
    97121  bool FirstTime;
    98122  vector<string> Label;
    99123  vector<string> TForm;
    100124  vector<string> TUnit;
    101   unsigned long NOverFlow;
     125};
    102126
    103   vector<struct KeyDouble> DoubleKey;
    104   vector<struct KeyLong>   LongKey;
    105   vector<struct KeyString> StringKey;
     127///////////////////////////////////////////////////////////////////////////
     128///////////////////////////////////////////////////////////////////////////
     129//! Class for writing a FITS Image
     130class FitsImg2DWriter : public FitsWriter {
     131public:
     132  FitsImg2DWriter(string fname,int bitpix=FLOAT_IMG,int lp=0);
     133  FitsImg2DWriter(const char* cfname,int bitpix=FLOAT_IMG,int lp=0);
     134  FitsImg2DWriter(string fname,bool update,int bitpix=FLOAT_IMG,int lp=0);
     135  FitsImg2DWriter(const char* cfname,bool update,int bitpix=FLOAT_IMG,int lp=0);
     136  virtual ~FitsImg2DWriter();
     137
     138  void Write(TMatrix<uint_2>& data);
     139  void Write(TMatrix<int_4>& data);
     140  void Write(TMatrix<float>& data);
     141  void Write(TMatrix<double>& data);
     142
     143  //! Print to os
     144  virtual void   Print(ostream& os) const;
     145  //! Print to stdout
     146  inline  void   Print(void) const {Print(cout);}
     147
     148protected:
     149  void createimg(void);
     150
     151  int BitPix;
     152  long Naxis[2];
     153  bool FirstTime;
    106154};
    107155
Note: See TracChangeset for help on using the changeset viewer.