Changeset 1660 in Sophya for trunk/SophyaExt/FitsIOServer/fabtwriter.cc
- Timestamp:
- Sep 30, 2001, 7:03:59 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtwriter.cc
r1659 r1660 15 15 FitsABTWriter fbtw(fitswrit,BINARY_TBL); 16 16 fbtw.SetExtName("MY_OWN_EXTENSION"); 17 fbtw.AddCol("vars", TSHORT,"","km"); // col=018 fbtw.AddCol("vars2", TSHORT,"","km"); // col=119 fbtw.AddCol("varl", TINT32BIT,"","Degre"); // col=220 fbtw.AddCol("varf", TFLOAT,"",""); // col=321 fbtw.AddCol("vard", TDOUBLE,"","arcmin");// col=417 fbtw.AddCol("vars",NULL,"km",TSHORT); // col=0 18 fbtw.AddCol("vars2",NULL,"km",TSHORT); // col=1 19 fbtw.AddCol("varl",NULL,"Degre",TINT32BIT); // col=2 20 fbtw.AddCol("varf",NULL,"",TFLOAT); // col=3 21 fbtw.AddCol("vard","","arcmin",TDOUBLE); // col=4 22 22 fbtw.SetDebug(3); 23 23 for(long i=0;i<1000;i++) { … … 119 119 Add a new column to the FITS table 120 120 \param label : column label 121 \param datatype : TSHORT TINT32BIT TFLOAT or TDOUBLE122 \param tform : fits tform definition123 (can be automatically set if BINARY_TBL and tform="")121 \param tform : fits tform definition ("1I","1J","1E","1J",...) 122 (can be automatically set as "datatype" 123 if BINARY_TBL and tform="" or tform=NULL) 124 124 \param tunit : fits tunit definition (optional) 125 \param datatype : TBYTE TSHORT TINT32BIT TLONG TFLOAT TDOUBLE 126 TUSHORT TULONG. That parameter is only use in case 127 of a BINARY_TBL table when tform is not defined). 125 128 \return The number of the new added column in the table. 126 129 \warning col = [0,ncol-1] 127 130 */ 128 int FitsABTWriter::addcol(const char* label, int datatype129 ,const char* t form,const char* tunit)131 int FitsABTWriter::addcol(const char* label,const char* tform 132 ,const char* tunit,int datatype) 130 133 { 131 134 if(!FirstTime) 132 135 throw AllocationError("FitsABTWriter::addcol: table already created\n"); 133 134 if( datatype!=TSHORT && datatype!=TINT32BIT135 && datatype!=TFLOAT && datatype!=TDOUBLE )136 throw ParmError("FitsABTWriter::addcol: datatype not allowed\n");137 136 138 Label.push_back(label); 139 DataType.push_back(datatype); 140 // Gestion auto du tform par defaut pour les tables binaires 141 if(HduType==BINARY_TBL && strlen(tform)<=0) { 142 char str[16]; 143 if(datatype==TSHORT) strcpy(str,"1I"); 137 // Gestion auto du tform pour les tables binaires avec le datatype (si non-definie) 138 bool tformauto = false; 139 if(HduType==BINARY_TBL) { 140 if(tform==NULL) tformauto = true; 141 if(strlen(tform)<=0) tformauto = true; 142 } 143 if(tformauto) { 144 char str[8]; 145 if(datatype==TBYTE) strcpy(str,"1B"); 146 else if(datatype==TSHORT) strcpy(str,"1I"); 144 147 else if(datatype==TINT32BIT) strcpy(str,"1J"); 148 else if(datatype==TLONG) strcpy(str,"1J"); 145 149 else if(datatype==TFLOAT) strcpy(str,"1E"); 146 150 else if(datatype==TDOUBLE) strcpy(str,"1D"); 151 else if(datatype==TUSHORT) strcpy(str,"1U"); 152 else if(datatype==TULONG) strcpy(str,"1V"); 153 else 154 throw ParmError("FitsABTWriter::addcol: datatype not allowed\n"); 147 155 TForm.push_back(str); 148 } else TForm.push_back(tform); 149 TUnit.push_back(tunit); 156 } else { 157 if(tform) TForm.push_back(tform); else TForm.push_back(""); 158 datatype = 0; 159 } 160 Label.push_back(label); 161 if(tunit) TUnit.push_back(tunit); else TUnit.push_back(""); 150 162 151 163 int n = (int) Label.size() -1; … … 153 165 if(DbgLevel) 154 166 cout<<"FitsABTWriter::addcol["<<n<<"] Label="<<Label[n] 155 <<" datatype="<<datatype156 167 <<" TForm="<<TForm[n] 157 <<" TUnit="<<TUnit[n]<<endl; 168 <<" TUnit="<<TUnit[n] 169 <<" datatype="<<datatype<<endl; 158 170 159 171 return n; … … 220 232 \verbatim 221 233 WARNING: suppose that the column has be defined to be TSHORT 222 and suppose that you wanted to write a double value 223 - If you write dummy.Write(col,row,(short (val))224 you call the Write(int,long,short) routineand234 and suppose that you wanted to write a double value "val" 235 - If you write dummy.Write(col,row,(short)(val)) 236 the Write(int,long,short) routine is called and 225 237 the cast is performed by the C++ language. 226 238 - If you write dummy.Write(col,row,val) where val is double 227 you call theWrite(int,long,double) routineand239 the Write(int,long,double) routine is called and 228 240 the cast is performed by the cfistio package. 229 241 \endverbatim … … 311 323 312 324 ////////////////////////////////////////////////////////////// 313 void FitsABTWriter::printerrorwrite(c har* type,int col,long row,int sta)325 void FitsABTWriter::printerrorwrite(const char* type,int col,long row,int sta) 314 326 { 315 327 if(sta==NUM_OVERFLOW) {NOverFlow++; return;}
Note:
See TracChangeset
for help on using the changeset viewer.