Changeset 1814 in Sophya for trunk/SophyaExt/FitsIOServer
- Timestamp:
- Dec 14, 2001, 12:00:21 PM (24 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtcolread.cc
r1660 r1814 244 244 } 245 245 246 ////////////////////////////////////////////////////////////// 247 double FitsABTColRead::ReadKey(char *keyname) 248 { 249 if(keyname==NULL) return 0.; 250 int sta=0; double val; 251 if(fits_read_key(FitsPtr,TDOUBLE,keyname,&val,NULL,&sta)) 252 printerror(sta); 253 return val; 254 } 246 255 247 256 ////////////////////////////////////////////////////////////// -
trunk/SophyaExt/FitsIOServer/fabtcolread.h
r1673 r1814 29 29 30 30 void ChangeBuffer(long blen=100,long bsens=1); 31 32 double ReadKey(char *keyname); 31 33 32 34 double Read(long n,bool usebuffer=true); -
trunk/SophyaExt/FitsIOServer/fabtwriter.cc
r1677 r1814 111 111 { 112 112 int sta = 0; 113 writekeys(); 113 114 if(fits_close_file(FitsPtr,&sta)) printerror(sta); 114 115 FitsPtr = NULL; 116 } 117 118 /*! Flush the FitsIO buffer to set good Fits file in case of problems */ 119 void FitsABTWriter::Flush(void) 120 { 121 if(FitsPtr==NULL) return; 122 int sta = 0; 123 if(fits_flush_file(FitsPtr,&sta)) printerror(sta); 124 } 125 126 /*! Write a double value into Fits Header */ 127 void FitsABTWriter::WriteKey(const char *keyname,double val,char* comment) 128 { 129 if(keyname==NULL || strlen(keyname)<=0) return; 130 KeyDouble k; 131 k.keyname=keyname; 132 k.val=val; 133 if(comment) k.comment=comment; else k.comment=""; 134 DoubleKey.push_back(k); 135 } 136 137 /*! Write a long value into Fits Header */ 138 void FitsABTWriter::WriteKey(const char *keyname,long val,char* comment) 139 { 140 if(keyname==NULL || strlen(keyname)<=0) return; 141 KeyLong k; 142 k.keyname=keyname; 143 k.val=val; 144 if(comment) k.comment=comment; else k.comment=""; 145 LongKey.push_back(k); 146 } 147 148 void FitsABTWriter::writekeys(void) 149 // Ecriture effective des clefs 150 { 151 int sta=0; 152 if(DoubleKey.size()>0) 153 for(unsigned int i=0;i<DoubleKey.size();i++) { 154 char* key = const_cast<char*>(DoubleKey[i].keyname.c_str()); 155 char* com = const_cast<char*>(DoubleKey[i].comment.c_str()); 156 double val = DoubleKey[i].val; 157 if(fits_update_key(FitsPtr,TDOUBLE,key,&val,com,&sta)) 158 printerror(sta); 159 } 160 if(LongKey.size()>0) 161 for(unsigned int i=0;i<LongKey.size();i++) { 162 char* key = const_cast<char*>(LongKey[i].keyname.c_str()); 163 char* com = const_cast<char*>(LongKey[i].comment.c_str()); 164 long val = LongKey[i].val; 165 if(fits_update_key(FitsPtr,TLONG,key,&val,com,&sta)) 166 printerror(sta); 167 } 168 DoubleKey.resize(0); 169 LongKey.resize(0); 115 170 } 116 171 … … 208 263 throw NullPtrError("FitsABTWriter::createtbl: Error creating Table extension\n"); 209 264 } 265 266 // Append Fits key 267 writekeys(); 210 268 211 269 // menage -
trunk/SophyaExt/FitsIOServer/fabtwriter.h
r1673 r1814 22 22 FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0); 23 23 virtual ~FitsABTWriter(); 24 25 void Flush(void); 26 27 //! Write a double value in Fits header. 28 void WriteKey(const char *keyname,double val,char* comment=NULL); 29 //! Write a long value in Fits header. 30 void WriteKey(const char *keyname,long val,char* comment=NULL); 24 31 25 32 //! Add a new column to the FITS table and return its number (see addcol). … … 58 65 59 66 protected: 67 struct KeyDouble {string keyname; double val; string comment;}; 68 struct KeyLong {string keyname; long val; string comment;}; 69 60 70 void createfits(const char *cfname,int hdutype,int lp); 61 71 int addcol(const char* label,const char* tform 62 72 ,const char* tunit,int datatype); 63 73 void createtbl(void); 74 void writekeys(void); 64 75 void printerrorwrite(const char* type,int col,long row,int sta); 65 76 void printerror(int sta) const; … … 74 85 vector<string> TUnit; 75 86 unsigned long NOverFlow; 87 88 vector<struct KeyDouble> DoubleKey; 89 vector<struct KeyLong> LongKey; 76 90 }; 77 91
Note:
See TracChangeset
for help on using the changeset viewer.