Changeset 2453 in Sophya for trunk/SophyaExt/FitsIOServer/fabtwriter.h
- Timestamp:
- Nov 13, 2003, 4:49:45 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtwriter.h
r2450 r2453 16 16 namespace SOPHYA { 17 17 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) 21 class FitsWriter : public AnyDataObj { 22 protected: 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 20 29 public: 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 27 30 void Flush(void); 28 31 … … 36 39 inline void WriteKey(const char *keyname,char* val,char* comment=NULL) 37 40 {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 47 protected: 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 73 class FitsABTWriter : public FitsWriter { 74 public: 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;} 38 85 39 86 //! Add a new column to the FITS table and return its number (see addcol). … … 45 92 ,const char* tunit="",int datatype=TDOUBLE) 46 93 {return addcol(label,tform,tunit,datatype);} 47 48 //! Set the FITS table extension name49 inline void SetExtName(string extname=string("")) {ExtName = extname;}50 //! Set the FITS table extension name51 inline void SetExtName(char* extname="") {ExtName = extname;}52 //! Set debug level53 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}54 94 55 95 void Write(int col,long row,uint_1 val); … … 66 106 long Write(int col,long row,TVector<float>& val); 67 107 long Write(int col,long row,TVector<double>& val); 68 //! Return the number of overflows managed by cfitsio69 inline unsigned long GetNOverFlow(void) {return NOverFlow;}70 108 71 109 //! Return the number of created columns … … 78 116 79 117 protected: 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); 83 120 84 void cr_or_upd_fits(const char *cfname,bool update,int hdutype,int lp);85 int addcol(const char* label,const char* tform86 ,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;97 121 bool FirstTime; 98 122 vector<string> Label; 99 123 vector<string> TForm; 100 124 vector<string> TUnit; 101 unsigned long NOverFlow;125 }; 102 126 103 vector<struct KeyDouble> DoubleKey; 104 vector<struct KeyLong> LongKey; 105 vector<struct KeyString> StringKey; 127 /////////////////////////////////////////////////////////////////////////// 128 /////////////////////////////////////////////////////////////////////////// 129 //! Class for writing a FITS Image 130 class FitsImg2DWriter : public FitsWriter { 131 public: 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 148 protected: 149 void createimg(void); 150 151 int BitPix; 152 long Naxis[2]; 153 bool FirstTime; 106 154 }; 107 155
Note:
See TracChangeset
for help on using the changeset viewer.