Ignore:
Timestamp:
Sep 30, 2001, 7:03:59 PM (24 years ago)
Author:
cmv
Message:
  • plus d'options et de possibilites + doc

cmv 30/9/01

File:
1 edited

Legend:

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

    r1659 r1660  
    1515  FitsABTWriter fbtw(fitswrit,BINARY_TBL);
    1616  fbtw.SetExtName("MY_OWN_EXTENSION");
    17   fbtw.AddCol("vars",TSHORT,"","km");       // col=0
    18   fbtw.AddCol("vars2",TSHORT,"","km");      // col=1
    19   fbtw.AddCol("varl",TINT32BIT,"","Degre"); // col=2
    20   fbtw.AddCol("varf",TFLOAT,"","");         // col=3
    21   fbtw.AddCol("vard",TDOUBLE,"","arcmin");  // col=4
     17  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
    2222  fbtw.SetDebug(3);
    2323  for(long i=0;i<1000;i++) {
     
    119119  Add a new column to the FITS table
    120120  \param label : column label
    121   \param datatype : TSHORT TINT32BIT TFLOAT or TDOUBLE
    122   \param tform : fits tform definition
    123          (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)
    124124  \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).
    125128  \return The number of the new added column in the table.
    126129  \warning col = [0,ncol-1]
    127130*/
    128 int FitsABTWriter::addcol(const char* label,int datatype
    129                          ,const char* tform,const char* tunit)
     131int FitsABTWriter::addcol(const char* label,const char* tform
     132                         ,const char* tunit,int datatype)
    130133{
    131134  if(!FirstTime)
    132135    throw AllocationError("FitsABTWriter::addcol: table already created\n");
    133 
    134  if(  datatype!=TSHORT && datatype!=TINT32BIT
    135    && datatype!=TFLOAT && datatype!=TDOUBLE )
    136    throw ParmError("FitsABTWriter::addcol: datatype not allowed\n");
    137136 
    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");
    144147   else if(datatype==TINT32BIT) strcpy(str,"1J");
     148   else if(datatype==TLONG)     strcpy(str,"1J");
    145149   else if(datatype==TFLOAT)    strcpy(str,"1E");
    146150   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");
    147155   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("");
    150162
    151163 int n = (int) Label.size() -1;
     
    153165 if(DbgLevel)
    154166   cout<<"FitsABTWriter::addcol["<<n<<"] Label="<<Label[n]
    155        <<" datatype="<<datatype
    156167       <<" TForm="<<TForm[n]
    157        <<" TUnit="<<TUnit[n]<<endl;
     168       <<" TUnit="<<TUnit[n]
     169       <<" datatype="<<datatype<<endl;
    158170
    159171 return n;
     
    220232  \verbatim
    221233  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) routine and
     234           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
    225237       the cast is performed by the C++ language.
    226238   - If you write dummy.Write(col,row,val) where val is double
    227        you call theWrite(int,long,double) routine and
     239       the Write(int,long,double) routine is called and
    228240       the cast is performed by the cfistio package.
    229241  \endverbatim
     
    311323
    312324//////////////////////////////////////////////////////////////
    313 void FitsABTWriter::printerrorwrite(char* type,int col,long row,int sta)
     325void FitsABTWriter::printerrorwrite(const char* type,int col,long row,int sta)
    314326{
    315327 if(sta==NUM_OVERFLOW) {NOverFlow++; return;}
Note: See TracChangeset for help on using the changeset viewer.