[1654] | 1 | /* Lecteur de colonne de table Fits (binaire ou ASCII) avec buffer */
|
---|
| 2 | #include "machdefs.h"
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 | #include <stdio.h>
|
---|
| 5 | #include "pexceptions.h"
|
---|
| 6 | #include "fabtcolread.h"
|
---|
[2449] | 7 |
|
---|
| 8 | ///////////////////////////////////////////////////////////////////
|
---|
| 9 | ///////////////////////////////////////////////////////////////////
|
---|
| 10 | ///////////////////////////////////////////////////////////////////
|
---|
| 11 | ///////////////////////////////////////////////////////////////////
|
---|
| 12 |
|
---|
| 13 | //! Class for opening a FITS file for reading
|
---|
| 14 |
|
---|
| 15 | /*!
|
---|
| 16 | \class SOPHYA::FitsOpenFile
|
---|
| 17 | \ingroup FitsIOServer
|
---|
| 18 | Class for opening a FITS file for reading
|
---|
| 19 | */
|
---|
| 20 |
|
---|
| 21 | /*!
|
---|
| 22 | Constructor.
|
---|
| 23 | \param fname : FITS file name to be opened for reading
|
---|
| 24 | */
|
---|
| 25 | FitsOpenFile::FitsOpenFile(string fname)
|
---|
| 26 | {
|
---|
| 27 | Init(fname.c_str());
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | /*!
|
---|
| 31 | Constructor.
|
---|
| 32 | \param cfname : FITS file name to be opened for reading
|
---|
| 33 | */
|
---|
| 34 | FitsOpenFile::FitsOpenFile(const char *cfname)
|
---|
| 35 | {
|
---|
| 36 | Init(cfname);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | /*!
|
---|
| 40 | Constructor by default.
|
---|
| 41 | */
|
---|
| 42 | FitsOpenFile::FitsOpenFile()
|
---|
| 43 | {
|
---|
| 44 | FitsFN = "";
|
---|
| 45 | NHdu = -1;
|
---|
| 46 | FitsPtr = NULL;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | /*!
|
---|
| 50 | Constructor by copy.
|
---|
| 51 | */
|
---|
| 52 | FitsOpenFile::FitsOpenFile(FitsOpenFile& fof)
|
---|
| 53 | {
|
---|
| 54 | Init(fof.GetFileName().c_str());
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | /*!
|
---|
| 58 | Destructor.
|
---|
| 59 | */
|
---|
| 60 | FitsOpenFile::~FitsOpenFile()
|
---|
| 61 | {
|
---|
| 62 | Delete();
|
---|
| 63 | FitsFN = "";
|
---|
| 64 | NHdu = 0;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /*!
|
---|
| 68 | Delete routine called by the destructor.
|
---|
| 69 | */
|
---|
| 70 | void FitsOpenFile::Delete(void)
|
---|
| 71 | {
|
---|
| 72 | if(FitsPtr != NULL) {
|
---|
| 73 | int sta = 0;
|
---|
| 74 | if(fits_close_file(FitsPtr,&sta)) printerror(sta);
|
---|
| 75 | FitsPtr = NULL;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | /*! Init routine called by the constructor */
|
---|
| 80 | void FitsOpenFile::Init(const char* fname)
|
---|
| 81 | {
|
---|
| 82 | // Parametres Generaux
|
---|
| 83 | FitsFN = fname;
|
---|
| 84 | NHdu = 0;
|
---|
| 85 | FitsPtr = NULL;
|
---|
| 86 |
|
---|
| 87 | // Ouverture du fichier
|
---|
| 88 | if(FitsFN.size() <= 0 )
|
---|
| 89 | throw ParmError("FitsOpenFile::Init: Fits file name error\n");
|
---|
| 90 |
|
---|
| 91 | int sta = 0;
|
---|
| 92 | if(fits_open_file(&FitsPtr,FitsFN.c_str(),READONLY,&sta)) {
|
---|
| 93 | printerror(sta);
|
---|
| 94 | FitsPtr = NULL;
|
---|
| 95 | throw NullPtrError("FitsOpenFile::Init: Error opening Fits file\n");
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | // Get number of hdu
|
---|
| 99 | if(fits_get_num_hdus(FitsPtr,&NHdu,&sta)) {
|
---|
| 100 | printerror(sta);
|
---|
| 101 | NHdu = 0;
|
---|
| 102 | Delete();
|
---|
| 103 | throw NotAvailableOperation("FitsOpenFile::Init: Error getting NHdu\n");
|
---|
| 104 | }
|
---|
| 105 | if(NHdu<=0) {
|
---|
| 106 | Delete();
|
---|
| 107 | throw SzMismatchError("FitsOpenFile::Init: Bad NHdu\n");
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | void FitsOpenFile::printerror(int sta) const
|
---|
| 113 | {
|
---|
| 114 | int stat = sta;
|
---|
| 115 | fits_report_error(stdout,stat);
|
---|
| 116 | fflush(stdout);
|
---|
| 117 | return;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | ///////////////////////////////////////////////////////////////////
|
---|
| 121 | ///////////////////////////////////////////////////////////////////
|
---|
| 122 | ///////////////////////////////////////////////////////////////////
|
---|
| 123 | ///////////////////////////////////////////////////////////////////
|
---|
| 124 |
|
---|
| 125 | ///////////////////////////////////////////////////////////////////
|
---|
[1654] | 126 | //! Class for reading a column in a FITS ASCII or BINARY table
|
---|
| 127 |
|
---|
| 128 | /*!
|
---|
[2449] | 129 | \class SOPHYA::FitsABTColRd
|
---|
[1654] | 130 | \ingroup FitsIOServer
|
---|
| 131 | Class for reading a column in a FITS ASCII or BINARY table
|
---|
| 132 | \verbatim
|
---|
[1659] | 133 | -- Exemple:
|
---|
[2449] | 134 | // Open the fits file with FitsOpenFile
|
---|
| 135 | FitsOpenFile fof = new FitsOpenFile("myfits.fits");
|
---|
| 136 | // Select the column to be read
|
---|
| 137 | FitsABTColRd fbt(fof,"BoloMuv_28",0,1000,1,3);
|
---|
[1654] | 138 | fbt.SetDebug(3);
|
---|
| 139 | fbt.Print(3);
|
---|
[1659] | 140 | // Read element by element
|
---|
[1654] | 141 | for(long i=0;i<fbt.GetNbLine();i++) {
|
---|
| 142 | double x = fbt.Read(i);
|
---|
| 143 | if(i%lpmod==0) cout<<i<<": "<<x<<endl;
|
---|
| 144 | }
|
---|
[1659] | 145 | // Read into a vector
|
---|
| 146 | TVector<double> data;
|
---|
| 147 | long n = fbt.Read(32,50,data);
|
---|
| 148 | cout<<"Number of values read: "<<n<<endl;
|
---|
| 149 | data.ReSize(100);
|
---|
| 150 | n = fbt.Read(10,-1,data);
|
---|
| 151 | cout<<"Number of values read: "<<n<<endl;
|
---|
[2449] | 152 | // Close the fits file
|
---|
| 153 | delete fof;
|
---|
[1654] | 154 | \endverbatim
|
---|
| 155 | */
|
---|
| 156 |
|
---|
| 157 | //////////////////////////////////////////////////////////////
|
---|
| 158 | /*!
|
---|
| 159 | Constructor.
|
---|
[2449] | 160 | \param fof : Pointer to the Class for opening the FITS file
|
---|
[1659] | 161 | \param collabel : label of the column to be read
|
---|
| 162 | \param ihdu : number of the HDU where the column is.
|
---|
| 163 | \param blen : read buffer length
|
---|
| 164 | \param bsens : buffer reading direction
|
---|
| 165 | \param lp : debug level
|
---|
[1654] | 166 | \verbatim
|
---|
[1659] | 167 | - if ihdu=0 or ihdu>nhdu first binary or ASCII table is taken
|
---|
| 168 | - bsens>0 read forward
|
---|
| 169 | bsens<0 read backward
|
---|
| 170 | bsens==0 read centered
|
---|
[1654] | 171 | \endverbatim
|
---|
[1659] | 172 | \warning ihdu = [1,nhdu]
|
---|
[1654] | 173 | */
|
---|
[2449] | 174 | FitsABTColRd::FitsABTColRd(FitsOpenFile* fof,string collabel
|
---|
| 175 | ,int ihdu,long blen,long bsens,int lp)
|
---|
[1654] | 176 | {
|
---|
[2449] | 177 | Init(fof,collabel.c_str(),-1,ihdu,blen,bsens,lp);
|
---|
[1654] | 178 | }
|
---|
| 179 |
|
---|
| 180 | /*!
|
---|
| 181 | Constructor.
|
---|
[1659] | 182 | Same as before but the column is identified by its column number
|
---|
| 183 | \param colnum : number of the column to be read
|
---|
| 184 | \warning col = [0,ncol[
|
---|
[1654] | 185 | */
|
---|
[2449] | 186 | FitsABTColRd::FitsABTColRd(FitsOpenFile* fof,int colnum
|
---|
| 187 | ,int ihdu,long blen,long bsens,int lp)
|
---|
[1654] | 188 | {
|
---|
[2449] | 189 | Init(fof,"",colnum,ihdu,blen,bsens,lp);
|
---|
[1654] | 190 | }
|
---|
| 191 |
|
---|
[2449] | 192 | /*! Constructor by copy */
|
---|
| 193 | FitsABTColRd::FitsABTColRd(FitsABTColRd& fbt)
|
---|
[1654] | 194 | {
|
---|
[2449] | 195 | Init(fbt.GetFitsOpenFile(),fbt.GetColLabel().c_str()
|
---|
| 196 | ,fbt.GetColNum(),fbt.GetHDU()
|
---|
| 197 | ,fbt.GetBLen(),fbt.GetBSens(),fbt.DbgLevel);
|
---|
[1654] | 198 | }
|
---|
| 199 |
|
---|
[2449] | 200 | /*! Constructor by default */
|
---|
| 201 | FitsABTColRd::FitsABTColRd()
|
---|
[1654] | 202 | {
|
---|
[2449] | 203 | FitsFN = "";
|
---|
| 204 | ColLabel = ""; ColTUnit = ""; ColTForm = "";
|
---|
| 205 | ColNum = -1; ColTypeCode = 0;
|
---|
| 206 | IHdu = 0; NHdu = 0; HduType = 0;
|
---|
| 207 | NBcol = 0; NBline = 0;
|
---|
| 208 | SetNulVal(); SetDebug(0);
|
---|
| 209 | NFitsRead = 0;
|
---|
| 210 | FitsOF = NULL; FitsPtr = NULL;
|
---|
| 211 | LineDeb = LineFin = -1;
|
---|
| 212 | Buffer = NULL;
|
---|
[1654] | 213 | }
|
---|
| 214 |
|
---|
| 215 | /*! Init routine called by the constructor */
|
---|
[2449] | 216 | void FitsABTColRd::Init(FitsOpenFile* fof,const char* collabel,int colnum
|
---|
[1654] | 217 | ,int ihdu,long blen,long bsens,int lp)
|
---|
| 218 | {
|
---|
[2449] | 219 | // Initialisation des Parametres Generaux
|
---|
| 220 | FitsFN = "";
|
---|
[1654] | 221 | ColLabel = collabel;
|
---|
| 222 | ColTUnit = "";
|
---|
| 223 | ColTForm = "";
|
---|
| 224 | ColNum = colnum;
|
---|
| 225 | ColTypeCode = 0;
|
---|
| 226 | IHdu = ihdu;
|
---|
| 227 | NHdu = 0;
|
---|
| 228 | HduType = 0;
|
---|
| 229 | NBcol = 0;
|
---|
| 230 | NBline = 0;
|
---|
| 231 | SetNulVal();
|
---|
| 232 | SetDebug(lp);
|
---|
| 233 | NFitsRead = 0;
|
---|
[2449] | 234 | FitsOF = NULL;
|
---|
[1654] | 235 | FitsPtr = NULL;
|
---|
| 236 | LineDeb = LineFin = -1;
|
---|
| 237 | Buffer = NULL;
|
---|
[1657] | 238 | ChangeBuffer(blen,bsens);
|
---|
[1654] | 239 |
|
---|
[2449] | 240 | // Caracteristiques du FitsOpenFile
|
---|
| 241 | FitsOF = fof;
|
---|
| 242 | if(FitsOF==NULL) {
|
---|
| 243 | Delete();
|
---|
| 244 | throw NullPtrError("FitsABTColRd::Init: FitsOpenFile pointer is NULL\n");
|
---|
[1654] | 245 | }
|
---|
[2449] | 246 | FitsPtr = FitsOF->GetFitsPtr();
|
---|
| 247 | if(FitsPtr==NULL) {
|
---|
| 248 | Delete();
|
---|
| 249 | throw NullPtrError("FitsABTColRd::Init: FitsPtr pointer is NULL\n");
|
---|
[1654] | 250 | }
|
---|
[2449] | 251 | NHdu = FitsOF->GetNHdu();
|
---|
| 252 | if(DbgLevel>1) cout<<"FitsABTColRd::Init NHdu="<<NHdu<<endl;
|
---|
[1654] | 253 | if(NHdu<=0) {
|
---|
| 254 | Delete();
|
---|
[2449] | 255 | throw SzMismatchError("FitsABTColRd::Init: Bad NHdu\n");
|
---|
[1654] | 256 | }
|
---|
[2449] | 257 | FitsFN = FitsOF->GetFileName();
|
---|
| 258 | if(FitsFN.size() <= 0 ) {
|
---|
| 259 | Delete();
|
---|
| 260 | throw ParmError("FitsABTColRd::Init: Fits file name error\n");
|
---|
| 261 | }
|
---|
[1654] | 262 |
|
---|
[2449] | 263 | int sta = 0;
|
---|
| 264 |
|
---|
[1654] | 265 | // Get HDU for bin/ascii table
|
---|
| 266 | // si IHdu <=0 || >NHdu on cherche la 1ere bin/ascii table
|
---|
| 267 | // sinon on se positionne sur IHdu
|
---|
| 268 | if(IHdu<=0 || IHdu>NHdu)
|
---|
| 269 | for(int ihdu=1;ihdu<=NHdu;ihdu++) {
|
---|
| 270 | if(fits_movabs_hdu(FitsPtr,ihdu,&HduType,&sta)) printerror(sta);
|
---|
| 271 | if(DbgLevel>1) cout<<"...Init ihdu="
|
---|
| 272 | <<ihdu<<" HduType="<<HduType<<endl;
|
---|
| 273 | if(HduType==BINARY_TBL || HduType==ASCII_TBL) {IHdu = ihdu; break;}
|
---|
| 274 | }
|
---|
| 275 | if(IHdu<=0 || IHdu>NHdu) {
|
---|
| 276 | cout<<"NO BINARY or ASCII hdu found"<<endl;
|
---|
[1657] | 277 | IHdu = 0; Delete();
|
---|
[2449] | 278 | throw TypeMismatchExc("FitsABTColRd::Init: NO BINARY or ASCII hdu found\n");
|
---|
[1654] | 279 | }
|
---|
| 280 | if(fits_movabs_hdu(FitsPtr,IHdu,&HduType,&sta)) {
|
---|
| 281 | printerror(sta); Delete();
|
---|
[2449] | 282 | throw RangeCheckError("FitsABTColRd::Init: Error moving to requested HDU\n");
|
---|
[1654] | 283 | }
|
---|
| 284 | if(HduType!=BINARY_TBL && HduType!=ASCII_TBL) {
|
---|
| 285 | Delete();
|
---|
[2449] | 286 | throw TypeMismatchExc("FitsABTColRd::Init: HDU not ASCII/BINARY table\n");
|
---|
[1654] | 287 | }
|
---|
| 288 |
|
---|
| 289 | // Get number of columns
|
---|
| 290 | if(fits_get_num_cols(FitsPtr,&NBcol,&sta)) {
|
---|
| 291 | printerror(sta); Delete();
|
---|
[2449] | 292 | throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of columns\n");
|
---|
[1654] | 293 | }
|
---|
| 294 | if(DbgLevel>1) cout<<"...Init NBcol="<<NBcol<<endl;
|
---|
| 295 | if(NBcol<1) {
|
---|
| 296 | Delete();
|
---|
[2449] | 297 | throw RangeCheckError("FitsABTColRd::Init: Bad number of colums\n");
|
---|
[1654] | 298 | }
|
---|
| 299 |
|
---|
| 300 | // Get number of rows
|
---|
| 301 | if(fits_get_num_rows(FitsPtr,&NBline,&sta)) {
|
---|
| 302 | printerror(sta); Delete();
|
---|
[2449] | 303 | throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of rows\n");
|
---|
[1654] | 304 | }
|
---|
| 305 | if(DbgLevel>1) cout<<"...Init NBline="<<NBline<<endl;
|
---|
| 306 | if(NBline<1) {
|
---|
| 307 | Delete();
|
---|
[2449] | 308 | throw RangeCheckError("FitsABTColRd::Init: Bad number of rows\n");
|
---|
[1654] | 309 | }
|
---|
| 310 |
|
---|
| 311 | // Get column number
|
---|
[1660] | 312 | char labelcol[128];
|
---|
[1654] | 313 | if(ColLabel.size() > 0) {
|
---|
| 314 | strcpy(labelcol,ColLabel.c_str());
|
---|
| 315 | if(fits_get_colnum(FitsPtr,CASESEN,labelcol,&ColNum,&sta)) {
|
---|
| 316 | printerror(sta); Delete();
|
---|
[2449] | 317 | throw NotAvailableOperation("FitsABTColRd::Init: Error getting column name\n");
|
---|
[1654] | 318 | }
|
---|
| 319 | ColNum--; // Convention [0,ncol[
|
---|
| 320 | }
|
---|
| 321 | if(DbgLevel>1) cout<<"...Init ColNum="<<ColNum<<endl;
|
---|
| 322 | if(ColNum<0 || ColNum>=NBcol) {
|
---|
| 323 | Delete();
|
---|
[2449] | 324 | throw RangeCheckError("FitsABTColRd::Init: Bad column number\n");
|
---|
[1654] | 325 | }
|
---|
| 326 |
|
---|
| 327 | // Get column type
|
---|
| 328 | if(fits_get_coltype(FitsPtr,ColNum+1,&ColTypeCode,NULL,NULL,&sta)) {
|
---|
| 329 | printerror(sta); Delete();
|
---|
[2449] | 330 | throw ParmError("FitsABTColRd::Init: Error getting column type\n");
|
---|
[1654] | 331 | }
|
---|
| 332 | if(DbgLevel>1) cout<<"...Init ColTypeCode="<<ColTypeCode<<endl;
|
---|
[1660] | 333 | if(ColTypeCode==TSTRING || ColTypeCode==TCOMPLEX || ColTypeCode==TDBLCOMPLEX
|
---|
| 334 | || ColTypeCode<0 ) {
|
---|
[1654] | 335 | Delete();
|
---|
[2449] | 336 | throw ParmError("FitsABTColRd::Init: Selected column is not Numerical\n");
|
---|
[1654] | 337 | }
|
---|
| 338 |
|
---|
| 339 | // Get column name back, tunit, tform
|
---|
[2174] | 340 | char tunit[64], tform[64], tdisp[64];
|
---|
[2173] | 341 | long repeat=0; double tscale=1., tzero=0.;
|
---|
[1654] | 342 | int rc=0;
|
---|
| 343 | if(HduType==BINARY_TBL) {
|
---|
[2173] | 344 | fits_get_bcolparms(FitsPtr,ColNum+1,labelcol,tunit,tform
|
---|
[2174] | 345 | ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);
|
---|
[1654] | 346 | } else {
|
---|
[2173] | 347 | fits_get_acolparms(FitsPtr,ColNum+1,labelcol,&repeat,tunit,tform
|
---|
[2174] | 348 | ,&tscale,&tzero,NULL,tdisp,&sta);
|
---|
[1654] | 349 | }
|
---|
| 350 | if(rc) {
|
---|
| 351 | printerror(sta); Delete();
|
---|
[2449] | 352 | throw RangeCheckError("FitsABTColRd::Init: Error getting the column caracteristics\n");
|
---|
[1654] | 353 | }
|
---|
| 354 | ColLabel = labelcol;
|
---|
| 355 | ColTUnit = tunit;
|
---|
| 356 | ColTForm = tform;
|
---|
| 357 |
|
---|
| 358 | if(DbgLevel)
|
---|
[2449] | 359 | cout<<"FitsABTColRd::Init Num="<<ColNum<<" Label="<<ColLabel
|
---|
[2173] | 360 | <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<endl;
|
---|
| 361 | if(DbgLevel>1)
|
---|
[2174] | 362 | cout<<" (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero
|
---|
| 363 | <<",tdisp="<<tdisp<<")"<<endl;
|
---|
[1654] | 364 |
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | /*! Destructor. */
|
---|
[2449] | 368 | FitsABTColRd::~FitsABTColRd()
|
---|
[1654] | 369 | {
|
---|
| 370 | Delete();
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[2449] | 373 | /*! Delete called by the destructor */
|
---|
| 374 | void FitsABTColRd::Delete(void)
|
---|
[1814] | 375 | {
|
---|
[2449] | 376 | if(Buffer!=NULL) {delete [] Buffer; Buffer=NULL;}
|
---|
| 377 | LineDeb = LineFin = -1;
|
---|
| 378 | //--- Surtout on ne "fits_close_file" pas le fichier FITS !!!
|
---|
[1814] | 379 | }
|
---|
[1654] | 380 |
|
---|
| 381 | //////////////////////////////////////////////////////////////
|
---|
[1659] | 382 | /*! Change the buffer caracteristiques (see creator) */
|
---|
[2449] | 383 | void FitsABTColRd::ChangeBuffer(long blen,long bsens)
|
---|
[1654] | 384 | {
|
---|
[1657] | 385 | long oldnbuffer = NBuffer;
|
---|
| 386 |
|
---|
| 387 | // Compute buffer caracteristics
|
---|
[1654] | 388 | BuffLen = (blen<=0)? 1: blen;
|
---|
| 389 | BuffSens = bsens;
|
---|
[1657] | 390 | NBuffer = BuffLen;
|
---|
| 391 | if(bsens==0 && NBuffer%2==0) NBuffer++;
|
---|
[1654] | 392 |
|
---|
[1657] | 393 | // De-allocate if necessary
|
---|
[1659] | 394 | if(Buffer!=NULL) {
|
---|
| 395 | // On des-alloue si pas assez de place
|
---|
| 396 | // ou si l'ancienne place est beaucoup trop grande (>25%)
|
---|
| 397 | if(oldnbuffer<NBuffer || (oldnbuffer>NBuffer+long(0.25*NBuffer)) )
|
---|
| 398 | {delete [] Buffer; Buffer=NULL;}
|
---|
| 399 | }
|
---|
[1654] | 400 |
|
---|
[1657] | 401 | // Re-allocate
|
---|
| 402 | if(Buffer==NULL) Buffer = new double[NBuffer];
|
---|
| 403 |
|
---|
[1654] | 404 | // Tell program that nothing is into buffer
|
---|
| 405 | LineDeb = LineFin = -1;
|
---|
| 406 | }
|
---|
| 407 |
|
---|
[2449] | 408 | //////////////////////////////////////////////////////////////
|
---|
| 409 | double FitsABTColRd::ReadKey(char *keyname)
|
---|
[1654] | 410 | {
|
---|
[2449] | 411 | if(keyname==NULL) return 0.;
|
---|
| 412 | int sta=0; double val=0.;
|
---|
| 413 | if(fits_read_key(FitsPtr,TDOUBLE,keyname,&val,NULL,&sta))
|
---|
| 414 | printerror(sta);
|
---|
| 415 | return val;
|
---|
[1654] | 416 | }
|
---|
| 417 |
|
---|
| 418 | /////////////////////////////////////////////////
|
---|
| 419 | /*!
|
---|
[1659] | 420 | Read row "n" and return the value into a double
|
---|
| 421 | \warning be carefull for the range: row = [0,NRows[
|
---|
| 422 | \return value in double
|
---|
| 423 | \param n : number of the row to be read.
|
---|
[1654] | 424 | \verbatim
|
---|
[1659] | 425 | usebuffer == true : use read optimisation with bufferisation
|
---|
| 426 | == false : no optimisation with bufferisation
|
---|
| 427 | just read one value
|
---|
[1654] | 428 | \endverbatim
|
---|
| 429 | */
|
---|
[2449] | 430 | double FitsABTColRd::Read(long n,bool usebuffer)
|
---|
[1654] | 431 | // Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
|
---|
| 432 | // Attention: colnum [0,NBcol[ , cfistio veut [1,NBcol]
|
---|
| 433 | {
|
---|
[1659] | 434 | int sta=0;
|
---|
[1654] | 435 | if(n<0 || n>=NBline)
|
---|
[2449] | 436 | throw RangeCheckError("FitsABTColRd::Read try to read outside line range\n");
|
---|
[1654] | 437 |
|
---|
| 438 | // Pas de bufferisation, on lit betement
|
---|
[1659] | 439 | if(NBuffer==1 || !usebuffer) {
|
---|
[1654] | 440 | NFitsRead++;
|
---|
[1659] | 441 | double val;
|
---|
| 442 | fits_read_col(FitsPtr,TDOUBLE,ColNum+1,n+1,1,1,NULL,&val,NULL,&sta);
|
---|
[1654] | 443 | if(sta) {
|
---|
| 444 | printerror(sta);
|
---|
[2449] | 445 | throw NotAvailableOperation("FitsABTColRd::Read: Error Reading Fits file\n");
|
---|
[1654] | 446 | }
|
---|
[1659] | 447 | // On ne remplit Buffer[0] que si on a choisit
|
---|
| 448 | // un mode de lecture non bufferise (n==1) DES LE DEBUT.
|
---|
| 449 | // Si on a initialement choisit un mode bufferise (avec n>1),
|
---|
| 450 | // Buffer contient les valeurs chargees auparavent.
|
---|
| 451 | // Il ne faut pas faire {Buffer[0]=val; LineDeb=LineFin=n;}
|
---|
| 452 | // car on perd l'info de ces valeurs.
|
---|
| 453 | if(NBuffer==1) {Buffer[0]=val; LineDeb=LineFin=n;}
|
---|
| 454 | return val;
|
---|
[1654] | 455 | }
|
---|
| 456 |
|
---|
| 457 | // Gestion avec bufferisation
|
---|
[1659] | 458 | if(!Buffer)
|
---|
[2449] | 459 | throw RangeCheckError("FitsABTColRd::Read: Buffer not allocated\n");
|
---|
[1654] | 460 | if(n<LineDeb || n>LineFin) {
|
---|
| 461 | NFitsRead++;
|
---|
| 462 | long row1,row2,nrow;
|
---|
| 463 | if(BuffSens>0) { // Cas remplissage forward
|
---|
| 464 | row1 = n+1;
|
---|
[1657] | 465 | row2 = row1+NBuffer-1; if(row2>NBline) row2 = NBline;
|
---|
[1654] | 466 | } else if(BuffSens<0) { // Cas remplissage backward
|
---|
| 467 | row2 = n+1;
|
---|
[1657] | 468 | row1 = row2-NBuffer+1; if(row1<1) row1 = 1;
|
---|
[1654] | 469 | } else { // Cas remplissage centre
|
---|
[1657] | 470 | row1 = n+1 - NBuffer/2; if(row1<1) row1 = 1;
|
---|
| 471 | row2 = n+1 + NBuffer/2; if(row2>NBline) row2 = NBline;
|
---|
[1654] | 472 | }
|
---|
| 473 | nrow = row2 - row1 + 1;
|
---|
| 474 | LineDeb = row1-1; LineFin = row2-1;
|
---|
| 475 | //cout<<"DBG-FitsRead: row1="<<row1<<" row2="<<row2<<" nrow="<<nrow
|
---|
| 476 | // <<" LineDeb,Fin="<<LineDeb<<","<<LineFin<<endl;
|
---|
[1659] | 477 | fits_read_col(FitsPtr,TDOUBLE,ColNum+1,row1,1,nrow,NULL,Buffer,NULL,&sta);
|
---|
[1654] | 478 | if(sta) {
|
---|
| 479 | printerror(sta);
|
---|
| 480 | LineDeb = LineFin = -1;
|
---|
[2449] | 481 | throw NotAvailableOperation("FitsABTColRd::Read: Error Reading Fits file\n");
|
---|
[1654] | 482 | }
|
---|
| 483 | }
|
---|
| 484 |
|
---|
| 485 | long ibuf = n-LineDeb;
|
---|
| 486 | return Buffer[ibuf];
|
---|
| 487 | }
|
---|
| 488 |
|
---|
| 489 | /*!
|
---|
[1659] | 490 | Read rows from "n1" to "n2" and return the values into TVector of double
|
---|
| 491 | \return NREAD the number of values read (n2-n1+1).
|
---|
| 492 | \warning row = [0,NRows[, the routine read [n1,n2]
|
---|
[1654] | 493 | \verbatim
|
---|
[1659] | 494 | - if n2<0 then read [n1,n2] where "n2=min(n1+vector_size-1,nrows-1)"
|
---|
| 495 | - Last row read is ALWAYS: "n2 = n1 + NREAD -1"
|
---|
| 496 | - The TVector is never resized if not necessary
|
---|
| 497 | -------------------------------------------------------------------------
|
---|
| 498 | - ex: suppose the column table contains 10 elements: nrows=10, rows=[0,9]
|
---|
| 499 |
|
---|
| 500 | TVector<double> V(5);
|
---|
| 501 | bt.Read(3,5,V) -> read rows=3,4,5 -> V.Size()==5 -> return 3
|
---|
| 502 | bt.Read(3,-1,V) -> read rows=3,4,5,6,7 -> V.Size()==5 -> return 5
|
---|
| 503 | bt.Read(7,-1,V) -> read rows=7,8,9 -> V.Size()==5 -> return 3
|
---|
| 504 | bt.Read(2,-1,V) -> read rows=2,3,4,5,6 -> V.Size()==5 -> return 5
|
---|
| 505 | bt.Read(-1,5,V) -> throw exception
|
---|
| 506 |
|
---|
| 507 | TVector<double> V(5);
|
---|
| 508 | bt.Read(3,99,V) -> read rows=3,4,5,6,7,8,9 -> V.Size()==7 -> return 7
|
---|
| 509 |
|
---|
| 510 | TVector<double> V(5);
|
---|
| 511 | bt.Read(2,8,V) -> read rows=2,3,4,5,6,7,8 -> V.Size()==7 -> return 7
|
---|
| 512 |
|
---|
| 513 | TVector<double> V;
|
---|
| 514 | bt.Read(3,5,V) -> read rows=3,4,5 -> V.Size()==3 -> return 3
|
---|
| 515 |
|
---|
| 516 | TVector<double> V;
|
---|
| 517 | bt.Read(3,-1,V) -> throw exception
|
---|
| 518 | -------------------------------------------------------------------------
|
---|
[1654] | 519 | \endverbatim
|
---|
| 520 | */
|
---|
[2449] | 521 | long FitsABTColRd::Read(long n1,long n2,TVector<double>& data)
|
---|
[1654] | 522 | {
|
---|
[1659] | 523 | if(n1<0 || n1>=NBline)
|
---|
[2449] | 524 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
|
---|
[1659] | 525 | if(data.Size()<=0 && n2<n1)
|
---|
[2449] | 526 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 2sd line \n");
|
---|
[1659] | 527 | if(n2<0) n2 = n1 + data.Size()-1;
|
---|
| 528 | if(n2>=NBline) n2 = NBline-1;
|
---|
[1654] | 529 |
|
---|
[1659] | 530 | sa_size_t nread = n2-n1+1;
|
---|
| 531 | if(data.Size()<nread) data.SetSize(nread);
|
---|
| 532 |
|
---|
| 533 | //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
|
---|
| 534 | int sta=0;
|
---|
| 535 | fits_read_col(FitsPtr,TDOUBLE,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
|
---|
| 536 | if(sta) {
|
---|
| 537 | printerror(sta);
|
---|
[2449] | 538 | throw NotAvailableOperation("FitsABTColRd::Read_TVector<double>: Error Reading Fits file\n");
|
---|
[1659] | 539 | }
|
---|
| 540 |
|
---|
| 541 | return nread;
|
---|
[1654] | 542 | }
|
---|
| 543 |
|
---|
[1659] | 544 | /*! idem before but for TVector of float */
|
---|
[2449] | 545 | long FitsABTColRd::Read(long n1,long n2,TVector<float>& data)
|
---|
[1659] | 546 | {
|
---|
| 547 | if(n1<0 || n1>=NBline)
|
---|
[2449] | 548 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
|
---|
[1659] | 549 | if(data.Size()<=0 && n2<n1)
|
---|
[2449] | 550 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 2sd line \n");
|
---|
[1659] | 551 | if(n2<0) n2 = n1 + data.Size()-1;
|
---|
| 552 | if(n2>=NBline) n2 = NBline-1;
|
---|
| 553 |
|
---|
| 554 | sa_size_t nread = n2-n1+1;
|
---|
| 555 | if(data.Size()<nread) data.SetSize(nread);
|
---|
| 556 |
|
---|
| 557 | //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
|
---|
| 558 | int sta=0;
|
---|
| 559 | fits_read_col(FitsPtr,TFLOAT,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
|
---|
| 560 | if(sta) {
|
---|
| 561 | printerror(sta);
|
---|
[2449] | 562 | throw NotAvailableOperation("FitsABTColRd::Read_TVector<float>: Error Reading Fits file\n");
|
---|
[1659] | 563 | }
|
---|
| 564 |
|
---|
| 565 | return nread;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
[2170] | 568 | /*! idem before but for TVector of unsigned short */
|
---|
[2449] | 569 | long FitsABTColRd::Read(long n1,long n2,TVector<uint_2>& data)
|
---|
[2170] | 570 | {
|
---|
| 571 | if(n1<0 || n1>=NBline)
|
---|
[2449] | 572 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
|
---|
[2170] | 573 | if(data.Size()<=0 && n2<n1)
|
---|
[2449] | 574 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 2sd line \n");
|
---|
[2170] | 575 | if(n2<0) n2 = n1 + data.Size()-1;
|
---|
| 576 | if(n2>=NBline) n2 = NBline-1;
|
---|
| 577 |
|
---|
| 578 | sa_size_t nread = n2-n1+1;
|
---|
| 579 | if(data.Size()<nread) data.SetSize(nread);
|
---|
| 580 |
|
---|
| 581 | int sta=0;
|
---|
| 582 | fits_read_col(FitsPtr,TUSHORT,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
|
---|
| 583 | if(sta) {
|
---|
| 584 | printerror(sta);
|
---|
[2449] | 585 | throw NotAvailableOperation("FitsABTColRd::Read_TVector<uint_2>: Error Reading Fits file\n");
|
---|
[2170] | 586 | }
|
---|
| 587 |
|
---|
| 588 | return nread;
|
---|
| 589 | }
|
---|
| 590 |
|
---|
[1659] | 591 | /*! idem before but for TVector of int_4 */
|
---|
[2449] | 592 | long FitsABTColRd::Read(long n1,long n2,TVector<int_4>& data)
|
---|
[1659] | 593 | {
|
---|
| 594 | if(n1<0 || n1>=NBline)
|
---|
[2449] | 595 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
|
---|
[1659] | 596 | if(data.Size()<=0 && n2<n1)
|
---|
[2449] | 597 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 2sd line \n");
|
---|
[1659] | 598 | if(n2<0) n2 = n1 + data.Size()-1;
|
---|
| 599 | if(n2>=NBline) n2 = NBline-1;
|
---|
| 600 |
|
---|
| 601 | sa_size_t nread = n2-n1+1;
|
---|
| 602 | if(data.Size()<nread) data.SetSize(nread);
|
---|
| 603 |
|
---|
| 604 | //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
|
---|
| 605 | int sta=0;
|
---|
| 606 | int T = (sizeof(long)==4) ? TLONG: TINT;
|
---|
| 607 | fits_read_col(FitsPtr,T,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
|
---|
| 608 | if(sta) {
|
---|
| 609 | printerror(sta);
|
---|
[2449] | 610 | throw NotAvailableOperation("FitsABTColRd::Read_TVector<int_4>: Error Reading Fits file\n");
|
---|
[1659] | 611 | }
|
---|
| 612 |
|
---|
| 613 | return nread;
|
---|
| 614 | }
|
---|
| 615 |
|
---|
[2169] | 616 | /*! idem before but for TVector of int_8 */
|
---|
[2449] | 617 | long FitsABTColRd::Read(long n1,long n2,TVector<int_8>& data)
|
---|
[2169] | 618 | {
|
---|
| 619 | #ifdef TLONGLONG
|
---|
| 620 | if(n1<0 || n1>=NBline)
|
---|
[2449] | 621 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
|
---|
[2169] | 622 | if(data.Size()<=0 && n2<n1)
|
---|
[2449] | 623 | throw RangeCheckError("FitsABTColRd::Read TVector bad requested 2sd line \n");
|
---|
[2169] | 624 | if(n2<0) n2 = n1 + data.Size()-1;
|
---|
| 625 | if(n2>=NBline) n2 = NBline-1;
|
---|
| 626 |
|
---|
| 627 | sa_size_t nread = n2-n1+1;
|
---|
| 628 | if(data.Size()<nread) data.SetSize(nread);
|
---|
| 629 |
|
---|
| 630 | int sta=0;
|
---|
| 631 | fits_read_col(FitsPtr,TLONGLONG,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
|
---|
| 632 | if(sta) {
|
---|
| 633 | printerror(sta);
|
---|
[2449] | 634 | throw NotAvailableOperation("FitsABTColRd::Read_TVector<int_8>: Error Reading Fits file\n");
|
---|
[2169] | 635 | }
|
---|
| 636 |
|
---|
| 637 | return nread;
|
---|
| 638 | #else
|
---|
[2449] | 639 | throw PException("FitsABTColRd::Read(..,TVector<int_8>&) Not in that cfitsio version");
|
---|
[2169] | 640 | #endif
|
---|
| 641 | }
|
---|
| 642 |
|
---|
[1654] | 643 | /////////////////////////////////////////////////
|
---|
[1659] | 644 | /*!
|
---|
| 645 | Return the number of the first row where "val1"<=val<="val2" starting at row "rowstart"
|
---|
| 646 | \verbatim
|
---|
| 647 | - The search is performed from "rowstart" to the end
|
---|
| 648 | in ascending order (from "rowstart" to nrows).
|
---|
| 649 | - Warning: "rowstart<0" means "rowstart==0" (search all the table column)
|
---|
| 650 | That is the default
|
---|
| 651 | \endverbatim
|
---|
| 652 | \return <0 means not found
|
---|
| 653 | */
|
---|
[2449] | 654 | long FitsABTColRd::FirstRow(double val1,double val2,long rowstart)
|
---|
[1659] | 655 | {
|
---|
| 656 | long row = -1;
|
---|
| 657 | if(NBline==0) return row;
|
---|
| 658 | // Change buffer for efficiency
|
---|
| 659 | long bsens=BuffSens; bool bchange=false;
|
---|
| 660 | if(bsens<=0) {ChangeBuffer(BuffLen,1); bchange=true;}
|
---|
| 661 | if(rowstart<0) rowstart = 0;
|
---|
| 662 | if(rowstart>=NBline) rowstart = NBline-1;
|
---|
| 663 | for(long i=rowstart;i<NBline;i++) {
|
---|
| 664 | double val = Read(i);
|
---|
| 665 | if(val<val1 || val>val2) continue;
|
---|
| 666 | row = i;
|
---|
| 667 | break;
|
---|
| 668 | }
|
---|
| 669 | if(bchange) ChangeBuffer(BuffLen,bsens);
|
---|
| 670 | return row;
|
---|
| 671 | }
|
---|
| 672 |
|
---|
| 673 | /*!
|
---|
| 674 | Return the number of the first row where val1<=val<=val2 starting at row rowstart
|
---|
| 675 | \return <0 means not found
|
---|
| 676 | \verbatim
|
---|
| 677 | - The search is performed from "rowstart" to the beginning
|
---|
| 678 | in descending order (from "rowstart" to 0).
|
---|
| 679 | - Warning: "rowstart<0" means "rowstart==nrows-1" (search all the table column)
|
---|
| 680 | That is the default
|
---|
| 681 | \endverbatim
|
---|
| 682 | */
|
---|
[2449] | 683 | long FitsABTColRd::LastRow(double val1,double val2,long rowstart)
|
---|
[1659] | 684 | {
|
---|
| 685 | long row = -1;
|
---|
| 686 | if(NBline==0) return row;
|
---|
| 687 | // Change buffer for efficiency
|
---|
| 688 | long bsens=BuffSens; bool bchange=false;
|
---|
| 689 | if(bsens>=0) {ChangeBuffer(BuffLen,-1); bchange=true;}
|
---|
| 690 | if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1;
|
---|
| 691 | for(long i=rowstart;i>=0;i--) {
|
---|
| 692 | double val = Read(i);
|
---|
| 693 | if(val<val1 || val>val2) continue;
|
---|
| 694 | row = i;
|
---|
| 695 | break;
|
---|
| 696 | }
|
---|
| 697 | if(bchange) ChangeBuffer(BuffLen,bsens);
|
---|
| 698 | return row;
|
---|
| 699 | }
|
---|
| 700 |
|
---|
| 701 | /////////////////////////////////////////////////
|
---|
[2449] | 702 | void FitsABTColRd::printerror(int sta) const
|
---|
[1654] | 703 | {
|
---|
| 704 | int stat = sta;
|
---|
| 705 | fits_report_error(stdout,stat);
|
---|
| 706 | fflush(stdout);
|
---|
| 707 | return;
|
---|
| 708 | }
|
---|
| 709 |
|
---|
| 710 | /*! Print on stream os */
|
---|
[2449] | 711 | void FitsABTColRd::Print(ostream& os,int lp) const
|
---|
[1654] | 712 | {
|
---|
[2449] | 713 | os<<"FitsABTColRd:Print ("<<BuffLen<<","<<BuffSens<<","<<NulVal<<")"
|
---|
[1654] | 714 | <<" ncols="<<NBcol<<" nrows="<<NBline;
|
---|
| 715 | if(lp>0) os<<" NRead="<<NFitsRead;
|
---|
| 716 | os<<"\n... "<<FitsFN<<"["<<IHdu<<"/"<<NHdu<<"]"
|
---|
| 717 | <<"\n... Label["<<ColNum<<"]="<<ColLabel
|
---|
| 718 | <<" TypeCode="<<ColTypeCode
|
---|
| 719 | <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm
|
---|
| 720 | <<endl;
|
---|
| 721 | }
|
---|
[2449] | 722 |
|
---|
| 723 | ///////////////////////////////////////////////////////////////////
|
---|
| 724 | ///////////////////////////////////////////////////////////////////
|
---|
| 725 | ///////////////////////////////////////////////////////////////////
|
---|
| 726 | ///////////////////////////////////////////////////////////////////
|
---|
| 727 |
|
---|
| 728 | //! Class for reading a column in a FITS ASCII or BINARY table with fits file opening
|
---|
| 729 |
|
---|
| 730 | /*!
|
---|
| 731 | \class SOPHYA::FitsABTColRead
|
---|
| 732 | \ingroup FitsIOServer
|
---|
| 733 | Class for reading a column in a FITS ASCII or BINARY table with fits file opening
|
---|
| 734 | \verbatim
|
---|
| 735 | -- Exemple:
|
---|
| 736 | FitsABTColRead fbt("myfits.fits","BoloMuv_28",0,1000,1,3);
|
---|
| 737 | fbt.SetDebug(3);
|
---|
| 738 | fbt.Print(3);
|
---|
| 739 | // Read element by element
|
---|
| 740 | for(long i=0;i<fbt.GetNbLine();i++) {
|
---|
| 741 | double x = fbt.Read(i);
|
---|
| 742 | if(i%lpmod==0) cout<<i<<": "<<x<<endl;
|
---|
| 743 | }
|
---|
| 744 | // Read into a vector
|
---|
| 745 | TVector<double> data;
|
---|
| 746 | long n = fbt.Read(32,50,data);
|
---|
| 747 | cout<<"Number of values read: "<<n<<endl;
|
---|
| 748 | data.ReSize(100);
|
---|
| 749 | n = fbt.Read(10,-1,data);
|
---|
| 750 | cout<<"Number of values read: "<<n<<endl;
|
---|
| 751 | \endverbatim
|
---|
| 752 | */
|
---|
| 753 |
|
---|
| 754 |
|
---|
| 755 | //////////////////////////////////////////////////////////////
|
---|
| 756 | /*!
|
---|
| 757 | Constructor.
|
---|
| 758 | \param fname : FITS file name to be read
|
---|
| 759 | \param collabel : label of the column to be read
|
---|
| 760 | \param ihdu : number of the HDU where the column is.
|
---|
| 761 | \param blen : read buffer length
|
---|
| 762 | \param bsens : buffer reading direction
|
---|
| 763 | \param lp : debug level
|
---|
| 764 | \verbatim
|
---|
| 765 | - if ihdu=0 or ihdu>nhdu first binary or ASCII table is taken
|
---|
| 766 | - bsens>0 read forward
|
---|
| 767 | bsens<0 read backward
|
---|
| 768 | bsens==0 read centered
|
---|
| 769 | \endverbatim
|
---|
| 770 | \warning ihdu = [1,nhdu]
|
---|
| 771 | */
|
---|
| 772 | FitsABTColRead::FitsABTColRead(string fname,string collabel
|
---|
| 773 | ,int ihdu,long blen,long bsens,int lp)
|
---|
| 774 | : FitsABTColRd(new FitsOpenFile(fname),collabel,ihdu,blen,bsens,lp)
|
---|
| 775 | {
|
---|
| 776 | }
|
---|
| 777 |
|
---|
| 778 | /*!
|
---|
| 779 | Constructor.
|
---|
| 780 | Same as before but the column is identified by its column number
|
---|
| 781 | \param colnum : number of the column to be read
|
---|
| 782 | \warning col = [0,ncol[
|
---|
| 783 | */
|
---|
| 784 | FitsABTColRead::FitsABTColRead(string fname,int colnum
|
---|
| 785 | ,int ihdu,long blen,long bsens,int lp)
|
---|
| 786 | : FitsABTColRd(new FitsOpenFile(fname),colnum,ihdu,blen,bsens,lp)
|
---|
| 787 | {
|
---|
| 788 | }
|
---|
| 789 |
|
---|
| 790 | /*! Constructor. see below */
|
---|
| 791 | FitsABTColRead::FitsABTColRead(const char * cfname,const char* collabel
|
---|
| 792 | ,int ihdu,long blen,long bsens,int lp)
|
---|
| 793 | : FitsABTColRd(new FitsOpenFile(cfname),collabel,ihdu,blen,bsens,lp)
|
---|
| 794 | {
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | /*! Constructor. see below */
|
---|
| 798 | FitsABTColRead::FitsABTColRead(const char * cfname,int colnum
|
---|
| 799 | ,int ihdu,long blen,long bsens,int lp)
|
---|
| 800 | : FitsABTColRd(new FitsOpenFile(cfname),colnum,ihdu,blen,bsens,lp)
|
---|
| 801 | {
|
---|
| 802 | }
|
---|
| 803 | /*! Constructor by default */
|
---|
| 804 | FitsABTColRead::FitsABTColRead()
|
---|
| 805 | {
|
---|
| 806 | }
|
---|
| 807 |
|
---|
| 808 | /*! Constructor by copy */
|
---|
| 809 | FitsABTColRead::FitsABTColRead(FitsABTColRead& fbt)
|
---|
| 810 | {
|
---|
| 811 | // --- ATTENTION ---
|
---|
| 812 | // FitsABTColRead ferme le fichier FITS: il faut dupliquer le FitsOpenFile
|
---|
| 813 | FitsOpenFile* fof = new FitsOpenFile(*fbt.GetFitsOpenFile());
|
---|
| 814 | Init(fof,fbt.GetColLabel().c_str()
|
---|
| 815 | ,fbt.GetColNum(),fbt.GetHDU()
|
---|
| 816 | ,fbt.GetBLen(),fbt.GetBSens(),fbt.DbgLevel);
|
---|
| 817 | }
|
---|
| 818 |
|
---|
| 819 | /*! Destructor. */
|
---|
| 820 | FitsABTColRead::~FitsABTColRead()
|
---|
| 821 | {
|
---|
| 822 | Delete();
|
---|
| 823 | if(FitsOF!=NULL) delete FitsOF;
|
---|
| 824 | }
|
---|