Ignore:
Timestamp:
Sep 27, 2001, 7:45:52 PM (24 years ago)
Author:
cmv
Message:

possibilite d'ecrire directement des TVector fabtwriter cmv 27/9/01

File:
1 edited

Legend:

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

    r1654 r1657  
    1414  FitsABTWriter fbtw("myfits.fits",BINARY_TBL,3);
    1515  fbtw.SetExtName("MY_OWN_EXTENSION");
    16   fbtw.AddCol("vars",TSHORT,"","km");      // col=0
    17   fbtw.AddCol("vars2",TSHORT,"","km");     // col=1
    18   fbtw.AddCol("varl",TLONG,"","Degre");    // col=2
    19   fbtw.AddCol("varf",TFLOAT,"","");        // col=3
    20   fbtw.AddCol("vard",TDOUBLE,"","arcmin"); // col=4
     16  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
    2121  fbtw.SetDebug(3);
    2222  for(long i=0;i<1000;i++) {
     
    8383 }
    8484
    85  // create d'un Primary HDU */
     85 // create d'un Primary HDU
    8686 //long naxes[1] = {0};
    8787 //if(fits_create_img(FitsPtr,BYTE_IMG,0,naxes,&sta)) {
     
    105105  \verbatim
    106106  label : column label
    107   datatype : TSHORT TLONG TFLOAT or TDOUBLE
     107  datatype : TSHORT TINT32BIT TFLOAT or TDOUBLE
    108108  tform : fits tform definition
    109109          (can be automatically set if BINARY_TBL and tform="")
     
    117117    throw AllocationError("FitsABTWriter::addcol: table already created\n");
    118118
    119  if(  datatype!=TSHORT && datatype!=TLONG
     119 if(  datatype!=TSHORT && datatype!=TINT32BIT
    120120   && datatype!=TFLOAT && datatype!=TDOUBLE )
    121121   throw ParmError("FitsABTWriter::addcol: datatype not allowed\n");
     
    126126 if(HduType==BINARY_TBL && strlen(tform)<=0) {
    127127   char str[16];
    128    if(datatype==TSHORT)       strcpy(str,"1I");
    129    else if(datatype==TLONG)  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");
    132132   TForm.push_back(str);
    133133 } else TForm.push_back(tform);
     
    217217{
    218218  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))
    222221    printerrorwrite("short",col,row,sta);
    223222}
    224223
    225224/*! 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))
     225void 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))
    232232    printerrorwrite("long",col,row,sta);
    233233}
     
    237237{
    238238  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))
    242241    printerrorwrite("float",col,row,sta);
    243242}
     
    247246{
    248247  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))
    252250    printerrorwrite("double",col,row,sta);
    253251}
    254252
     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) */
     264long 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) */
     277long 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) */
     288long 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//////////////////////////////////////////////////////////////
    255299void FitsABTWriter::printerrorwrite(char* type,int col,long row,int sta)
    256300{
Note: See TracChangeset for help on using the changeset viewer.