Changeset 1657 in Sophya for trunk/SophyaExt/FitsIOServer/fabtwriter.cc
- Timestamp:
- Sep 27, 2001, 7:45:52 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtwriter.cc
r1654 r1657 14 14 FitsABTWriter fbtw("myfits.fits",BINARY_TBL,3); 15 15 fbtw.SetExtName("MY_OWN_EXTENSION"); 16 fbtw.AddCol("vars",TSHORT,"","km"); // col=017 fbtw.AddCol("vars2",TSHORT,"","km"); // col=118 fbtw.AddCol("varl",T LONG,"","Degre");// col=219 fbtw.AddCol("varf",TFLOAT,"",""); // col=320 fbtw.AddCol("vard",TDOUBLE,"","arcmin"); // col=416 fbtw.AddCol("vars",TSHORT,"","km"); // col=0 17 fbtw.AddCol("vars2",TSHORT,"","km"); // col=1 18 fbtw.AddCol("varl",TINT32BIT,"","Degre"); // col=2 19 fbtw.AddCol("varf",TFLOAT,"",""); // col=3 20 fbtw.AddCol("vard",TDOUBLE,"","arcmin"); // col=4 21 21 fbtw.SetDebug(3); 22 22 for(long i=0;i<1000;i++) { … … 83 83 } 84 84 85 // create d'un Primary HDU */85 // create d'un Primary HDU 86 86 //long naxes[1] = {0}; 87 87 //if(fits_create_img(FitsPtr,BYTE_IMG,0,naxes,&sta)) { … … 105 105 \verbatim 106 106 label : column label 107 datatype : TSHORT T LONGTFLOAT or TDOUBLE107 datatype : TSHORT TINT32BIT TFLOAT or TDOUBLE 108 108 tform : fits tform definition 109 109 (can be automatically set if BINARY_TBL and tform="") … … 117 117 throw AllocationError("FitsABTWriter::addcol: table already created\n"); 118 118 119 if( datatype!=TSHORT && datatype!=T LONG119 if( datatype!=TSHORT && datatype!=TINT32BIT 120 120 && datatype!=TFLOAT && datatype!=TDOUBLE ) 121 121 throw ParmError("FitsABTWriter::addcol: datatype not allowed\n"); … … 126 126 if(HduType==BINARY_TBL && strlen(tform)<=0) { 127 127 char str[16]; 128 if(datatype==TSHORT) strcpy(str,"1I");129 else if(datatype==T LONG)strcpy(str,"1J");130 else if(datatype==TFLOAT) strcpy(str,"1E");131 else if(datatype==TDOUBLE) strcpy(str,"1D");128 if(datatype==TSHORT) strcpy(str,"1I"); 129 else if(datatype==TINT32BIT) strcpy(str,"1J"); 130 else if(datatype==TFLOAT) strcpy(str,"1E"); 131 else if(datatype==TDOUBLE) strcpy(str,"1D"); 132 132 TForm.push_back(str); 133 133 } else TForm.push_back(tform); … … 217 217 { 218 218 if(FirstTime) createtbl(); 219 short x[1] = {val}; 220 int sta=0; 221 if(fits_write_col(FitsPtr,TSHORT,col+1,row+1,1,1,x,&sta)) 219 int sta=0; 220 if(fits_write_col(FitsPtr,TSHORT,col+1,row+1,1,1,&val,&sta)) 222 221 printerrorwrite("short",col,row,sta); 223 222 } 224 223 225 224 /*! Write long data to FITS file (see below) */ 226 void FitsABTWriter::Write(int col,long row,long val) 227 { 228 if(FirstTime) createtbl(); 229 long x[1] = {val}; 230 int sta=0; 231 if(fits_write_col(FitsPtr,TLONG,col+1,row+1,1,1,x,&sta)) 225 void FitsABTWriter::Write(int col,long row,int_4 val) 226 { 227 if(FirstTime) createtbl(); 228 int sta=0; 229 // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ? 230 int T = (sizeof(long)==4) ? TLONG: TINT; 231 if(fits_write_col(FitsPtr,T,col+1,row+1,1,1,&val,&sta)) 232 232 printerrorwrite("long",col,row,sta); 233 233 } … … 237 237 { 238 238 if(FirstTime) createtbl(); 239 float x[1] = {val}; 240 int sta=0; 241 if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,1,x,&sta)) 239 int sta=0; 240 if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,1,&val,&sta)) 242 241 printerrorwrite("float",col,row,sta); 243 242 } … … 247 246 { 248 247 if(FirstTime) createtbl(); 249 double x[1] = {val}; 250 int sta=0; 251 if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,1,x,&sta)) 248 int sta=0; 249 if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,1,&val,&sta)) 252 250 printerrorwrite("double",col,row,sta); 253 251 } 254 252 253 ////////////////////////////////////////////////////////////// 254 /*! 255 Write a vector of long data to FITS file. 256 \verbatim 257 col : column number [0,ncol[ 258 row : starting row number [0,nrow[ 259 val : vector to be written 260 Return: number of the last written row (remember row=[0,nrow[) 261 \endverbatim 262 */ 263 /*! Write a vector of long data to FITS file (see below) */ 264 long FitsABTWriter::Write(int col,long row,TVector<int_4>& val) 265 { 266 if(FirstTime) createtbl(); 267 long nel = val.Size(); 268 int sta=0; 269 // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ? 270 int T = (sizeof(long)==4) ? TLONG: TINT; 271 if(fits_write_col(FitsPtr,T,col+1,row+1,1,nel,val.Data(),&sta)) 272 printerrorwrite("long",col,row,sta); 273 return row+nel; 274 } 275 276 /*! Write a vector of float data to FITS file (see below) */ 277 long FitsABTWriter::Write(int col,long row,TVector<float>& val) 278 { 279 if(FirstTime) createtbl(); 280 long nel = val.Size(); 281 int sta=0; 282 if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,nel,val.Data(),&sta)) 283 printerrorwrite("float",col,row,sta); 284 return row+nel; 285 } 286 287 /*! Write a vector of double data to FITS file (see below) */ 288 long FitsABTWriter::Write(int col,long row,TVector<double>& val) 289 { 290 if(FirstTime) createtbl(); 291 long nel = val.Size(); 292 int sta=0; 293 if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,nel,val.Data(),&sta)) 294 printerrorwrite("double",col,row,sta); 295 return row+nel; 296 } 297 298 ////////////////////////////////////////////////////////////// 255 299 void FitsABTWriter::printerrorwrite(char* type,int col,long row,int sta) 256 300 {
Note:
See TracChangeset
for help on using the changeset viewer.