source: Sophya/trunk/SophyaExt/FitsIOServer/fitsfile.cc@ 2844

Last change on this file since 2844 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

File size: 68.3 KB
RevLine 
[2615]1#include "sopnamsp.h"
[949]2#include "machdefs.h"
3#include <stdlib.h>
[839]4#include "fitsfile.h"
5#include "pexceptions.h"
6#include "strutil.h"
[903]7#include "anydataobj.h"
8#include "fitsspherehealpix.h"
[1136]9
[1371]10/*!
11 \defgroup FitsIOServer FitsIOServer module
12 This module contains classes which handle FITS format I/O for
13 SOPHYA objects. This module uses cfitsio library.
14*/
[1136]15
[1359]16void BnTblLine::setFormat(int dc, int fc, int ic, int lc, int bc,int cc, vector<string> names)
[1218]17 {
[1359]18 int nbcols = dc + fc + ic + cc + lc + bc;
[1218]19 int maxName = names.size();
20 if (nbcols != maxName)
21 {
22 cout << " WARNING: BnTblLine:: length of vector of column names not equal to total number of columns" << endl;
23 maxName = nbcols < maxName ? nbcols : maxName;
24 }
25 ColName_ = vector<string>(nbcols);
[2209]26 int k;
27 for (k=0; k < maxName; k++) ColName_[k] = names[k];
[1218]28 if (dc >0) ddata_ = vector<double>(dc);
29 if (fc >0) fdata_ = vector<float>(fc);
[2197]30 if (ic >0) idata_ = vector<int>(ic);
[1359]31 if (lc >0) ldata_ = vector<long>(lc);
32 if (bc >0) bdata_ = vector<unsigned char>(bc);
[2197]33 if (cc >0) cdata_ = vector<string>(cc);
[1218]34 }
35
36bool BnTblLine::sameFormat(const BnTblLine& btl) const
37 {
[1359]38 if (btl.ddata_.size() == ddata_.size() && btl.fdata_.size() == fdata_.size() && btl.idata_.size() == idata_.size() && btl.cdata_.size() == cdata_.size() && btl.ldata_.size() == ldata_.size() && btl.bdata_.size() == bdata_.size()) return true;
[1218]39 else return false;
40 }
41
42void BnTblLine::Print()
43 {
44 int k;
45 cout << " ********* ligne ************* " << endl;
46 cout << " *** noms de variables " << endl;
47 for (k=0; k < ColName_.size(); k++) cout << ColName_[k] << " ";
48 cout << endl;
49 cout << " *** variables doubles " << endl;
50 for (k=0; k < ddata_.size(); k++) cout << ddata_[k] << " ";
51 cout << endl;
52 cout << " *** variables float " << endl;
53 for (k=0; k < fdata_.size(); k++) cout << fdata_[k] << " ";
54 cout << endl;
55 cout << " *** variables int " << endl;
56 for (k=0; k < idata_.size(); k++) cout << idata_[k] << " ";
57 cout << endl;
58 cout << " *** variables string " << endl;
59 for (k=0; k < cdata_.size(); k++) cout << cdata_[k] << " ";
60 cout << endl;
[1359]61 cout << " *** variables long " << endl;
62 for (k=0; k < ldata_.size(); k++) cout << ldata_[k] << " ";
63 cout << endl;
64 cout << " *** variables byte " << endl;
65 for (k=0; k < bdata_.size(); k++) cout << (int)bdata_[k] << " ";
66 cout << endl;
[1218]67 cout << " ***************************** " << endl;
68 }
69
[2197]70FitsFile::BufferLine::BufferLine(const vector<FitsFile::FitsDataType>& types)
71{
[1218]72
73
[2197]74 int dc=0;
75 int fc=0;
76 int shc=0;
77 int ic=0;
78 int lc=0;
79 int cc=0;
80 int bc=0;
81 id_ = vector< pair<FitsFile::FitsDataType, int> >(types.size());
[2209]82 int k;
83 for (k= 0; k < types.size(); k++)
[2197]84 {
85 switch( types[k] )
86 {
87 case FitsFile::FitsDataType_double :
88 {
89 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_double, dc);
90 dc++;
91 break;
92 }
93 case FitsFile::FitsDataType_float :
94 {
95 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_float, fc);
96 fc++;
97 break;
98 }
99 case FitsFile::FitsDataType_short :
100 {
101 id_[k] = pair<FitsFile::FitsDataType, int>(FitsDataType_short, shc);
102 shc++;
103 break;
104 }
105 case FitsFile::FitsDataType_int :
106 {
107 id_[k] = pair<FitsFile::FitsDataType, int>(FitsDataType_int, ic);
108 ic++;
109 break;
110 }
111 case FitsFile::FitsDataType_long :
112 {
113 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_long, lc);
114 lc++;
115 break;
116 }
117 case FitsFile::FitsDataType_byte :
118 {
119 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_byte, bc);
120 bc++;
121 break;
122 }
123 case FitsDataType_char :
124 {
125 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_char, cc);
126 cc++;
127 break;
128 }
129 default:
130 {
131 throw PException(" FitsFile::getHeaderWithSophyaObject() : unsupported FITS data type");
132 }
133 }
134 }
135
136 if (dc >0) ddata_ = vector<r_8>(dc);
137 if (fc >0) fdata_ = vector<r_4>(fc);
138 if (shc >0) shdata_ = vector<int_2>(shc);
139 if (ic >0) idata_ = vector<int_4>(ic);
140 if (lc >0) ldata_ = vector<int_8>(lc);
141 if (cc >0) cdata_ = vector<string>(cc);
142 if (bc >0) bdata_ = vector<unsigned char>(bc);
143}
144
145
146void FitsFile::BufferLine::Print() const
147{
148 cout << " impression de la ligne: " << endl;
149
150 cout << " doubles : " << endl;
[2209]151 int k;
152 for (k=0; k< ddata_.size(); k++)
[2197]153 {
154 cout << ddata_[k] << " " ;
155 }
156 cout << endl;
157
158 cout << " floats : " << endl;
[2209]159 for (k=0; k< fdata_.size(); k++)
[2197]160 {
161 cout << fdata_[k] << " " ;
162 }
163 cout << endl;
164
165 cout << " entiers courts: " << endl;
[2209]166 for (k=0; k< shdata_.size(); k++)
[2197]167 {
168 cout << shdata_[k] << " " ;
169 }
170 cout << endl;
171 cout << " entiers : " << endl;
[2209]172 for (k=0; k< idata_.size(); k++)
[2197]173 {
174 cout << idata_[k] << " " ;
175 }
176 cout << endl;
177
178 cout << " entiers longs : " << endl;
[2209]179 for (k=0; k< ldata_.size(); k++)
[2197]180 {
181 cout << ldata_[k] << " " ;
182 }
183 cout << endl;
184
185 cout << " chaines carac. : " << endl;
[2209]186 for (k=0; k< cdata_.size(); k++)
[2197]187 {
188 cout << cdata_[k] << " " ;
189 }
190 cout << endl;
191
192 cout << " bytes : " << endl;
[2209]193 for (k=0; k< bdata_.size(); k++)
[2197]194 {
195 cout << (char)bdata_[k] << " " ;
196 }
197 cout << endl;
198
199
200}
201
[1218]202/*!
203 \class SOPHYA::FitsIOHandler
[1371]204 \ingroup FitsIOServer
[1218]205The class structure is analogous to Sophya-PPersist system :
206Each SOPHYA object XXX is associated with a object of class FITS_XXX
207 (inheriting from FitsFileHandler), to which input/output operations with FITS
208 files are delegated (through a class Hierarchy : FitsFile (virtual),
209 FitsInFile, FitsOutFile) . A typical example of use is the following :
210
211\verbatim
212 int m=... ;
213 SphereHEALPix<r_8> sphere1(m); // definition of the SOPHYA object
214 .... fill the sphere ....
215
216 FITS_SphereHEALPix<r_8> fits_sph1(sphere1);
217 // delegated object
218 fits_sph.Write("myfile.fits"); // writing on FITS file
219
220 FITS_SphereHEALPix<r_8> fits_sph2("myfile.fits");
221 // load a delegated object
222 // from FITS file
223 SphereHEALPix<r_8> sphere2=(SphereHEALPix<r_8>)fits_sph2;
224 // casting the delegated object
225 // into a SOPHYA object
226\endverbatim
227
228
229*/
230
231/*! \fn void SOPHYA::FitsIOHandler::Read(char flnm[],int hdunum)
232
233this method is called from inherited objects :
234
235opens a file 'flnm'
236
237gets parameters in extension-header (hdunum)
238
239calls the method 'ReadFromFits' from the inherited object
240*/
[1136]241void FitsIOHandler::Read(char flnm[],int hdunum)
[839]242{
[1136]243 FitsInFile ifts(flnm);
244 Read(ifts, hdunum);
[839]245}
[1218]246
247 /*! \fn void SOPHYA::FitsIOHandler::Read(FitsInFile& is, int hdunum)
248Read the data on extension hdunum (or primary header, if hdunum=1) from FitsInFIle. If hdunum is not addressed, , one reads the next extension, with respect to the current position.
249 */
[1136]250void FitsIOHandler::Read(FitsInFile& is, int hdunum)
251{
[1300]252 is.ReadHeader(hdunum);
[1136]253 ReadFromFits(is);
254}
255
256
[1218]257/*! \fn void SOPHYA::FitsIOHandler::Write(char flnm[])
258this method is called from inherited objects.
259
260for writing a new object in a new fits-extension :
261
[1234]262\warning By convention, primary header may contain fits-image data.
263For switching off this convention (i.e. to make sure that all data will be on fits-extensions) use the method :
[1218]264
265firstImageOnPrimaryHeader() (see below)
266
267calls the method 'WriteToFits' from the inherited object
268
269*/
[1193]270void FitsIOHandler::Write(char flnm[])
[1136]271
272{
[1231]273 FitsOutFile of(flnm, FitsFile::unknown);
[1136]274 Write(of);
275}
276
277void FitsIOHandler::Write(FitsOutFile& os)
278{
279 WriteToFits(os);
280}
281
282
283
[839]284
285FitsFile::~FitsFile()
286{
287 int status = 0;
[1175]288 if( fptr_ != NULL)
[903]289 {
290 fits_close_file(fptr_,&status);
[1175]291 // je ne fais pas delete fptr_, c'est la lib. fitsio qui a fait
292 // new...
[903]293 }
[1175]294 if( status ) printerror( status );
[839]295}
[903]296
[1136]297
298void FitsFile::printerror(int &status)
299 //*****************************************************/
300 //* Print out cfitsio error messages and exit program */
301 //*****************************************************/
[1045]302{
[1136]303 if( status )
304 {
305 fits_report_error(stderr,status);
306 throw IOExc("FitsFile:: error FITSIO status");
307 }
308 return;
309}
[903]310
[1136]311void FitsFile::printerror(int& status, char* texte)
312 //*****************************************************/
313 //* Print out cfitsio error messages and exit program */
314 //*****************************************************/
315{
316 // print out cfitsio error messages and exit program
317 // print error report
[1235]318 fits_report_error(stderr, status);
[1136]319 cout << " erreur:: " << texte << endl;
320 throw IOExc("FitsFile:: error FITSIO status");
321}
[1703]322void FitsFile::printerrorAndContinue(int& status, char* texte)
323 //*****************************************************/
324 //* Print out cfitsio error messages and exit program */
325 //*****************************************************/
326{
327 // print out cfitsio error messages and exit program
328 // print error report
329 fits_report_error(stderr, status);
330 cout << " erreur:: " << texte << endl;
331 // throw IOExc("FitsFile:: error FITSIO status");
332}
[1136]333
334void FitsFile::ResetStatus(int& status)
335{
336 fits_status_ = status;
337 status = 0;
[1235]338 fits_clear_errmsg();
[1136]339}
340
[1209]341string FitsFile::GetErrStatus(int status)
[1136]342{
343 char text[31];
344 fits_get_errstatus(status, text);
345 return string(text);
346}
347
[1218]348/*!
349 \class SOPHYA::FitsInFile
[1371]350 \ingroup FitsIOServer
[1246]351class for reading SOPHYA objects from FITS Format Files (uses cfitsio lib)
[1218]352*/
353
[1136]354FitsInFile::FitsInFile()
355{
356 InitNull();
357}
[1218]358
[1231]359FitsInFile::FitsInFile(string const & flnm)
[1136]360{
[1175]361 InitNull();
362 int status = 0;
[1231]363 fits_open_file(&fptr_,flnm.c_str(),READONLY,&status);
364 if( status ) printerror( status );
365}
366
367FitsInFile::FitsInFile(const char * flnm)
368{
369 InitNull();
370 int status = 0;
[1175]371 fits_open_file(&fptr_,flnm,READONLY,&status);
372 if( status ) printerror( status );
[1136]373}
374
375
376void FitsInFile::InitNull()
377{
[1300]378 imageDataType_ = FitsDataType_NULL;
[1045]379 naxis_ = 0;
380 nbData_ = 0;
381 nrows_ = 0;
382 nbcols_ = 0;
383 naxisn_.clear();
384 repeat_.clear();
385 noms_.clear();
386 taille_des_chaines_.clear();
387 dvl_.Clear();
[1978]388
389 dnull_ = 1.e-300;
390 fnull_ = 1.e-33;
391 inull_= 99999;
392 cnull_= string("xxx");
[1175]393
[1978]394
[1045]395}
396
[1218]397//////////////////////////////////////////////////////////
398// methods with general purpose
399/////////////////////////////////////////////////////////
[1045]400
[1136]401int FitsInFile::NbBlocks(char flnm[])
[903]402{
403 int status = 0;
404 int nbhdu = 0;
405 fitsfile* fileptr;
406 fits_open_file(&fileptr,flnm,READONLY,&status);
407 if( status ) printerror( status, "NbBlocks: erreur ouverture fichier" );
408 fits_get_num_hdus(fileptr, &nbhdu, &status);
409 fits_close_file(fileptr,&status);
410 return nbhdu;
411}
[1334]412int FitsInFile::NbBlocks()
413{
414 int status = 0;
415 int nbhdu = 0;
416 fits_get_num_hdus(fptr_, &nbhdu, &status);
417 return nbhdu;
418}
[903]419
[1231]420void FitsInFile::GetBlockType(char flnm[], int hdunum, FitsExtensionType& typeOfExtension, int& naxis, vector<int>& naxisn, FitsDataType& dataType, DVList& dvl )
[903]421{
422 int status = 0;
423 fitsfile* fileptr;
424 fits_open_file(&fileptr,flnm,READONLY,&status);
[1209]425 if( status ) printerror( status, "GetBlockType: erreur ouverture fichier" );
[903]426 // move to the specified HDU number
427 int hdutype = 0;
428 fits_movabs_hdu(fileptr,hdunum,&hdutype,&status);
[1209]429 if( status ) printerror( status,"GetBlockType: erreur movabs");
[903]430 if(hdutype == IMAGE_HDU)
431 {
[1231]432 typeOfExtension = FitsExtensionType_IMAGE;
[1300]433 GetImageParameters (fileptr, dataType, naxis, naxisn);
[903]434 }
435 else
436 if(hdutype == ASCII_TBL || hdutype == BINARY_TBL)
437 {
438 int nrows = 0;
439 vector<string> noms;
[1300]440 vector<FitsDataType> types;
[903]441 vector<int> taille_des_chaines;
[971]442 GetBinTabParameters(fileptr, naxis, nrows, naxisn, noms, types, taille_des_chaines);
443 int k;
444 for (k=0; k< naxisn.size(); k++) naxisn[k] *= nrows;
[903]445 if(hdutype == ASCII_TBL)
446 {
[1231]447 typeOfExtension = FitsExtensionType_ASCII_TBL;
448 dataType = FitsDataType_ASCII;
[903]449 }
450 else
451 {
[1231]452 typeOfExtension = FitsExtensionType_BINARY_TBL;
[1300]453 dataType = types[0];
[903]454 }
455 }
456 else
457 {
458 cout << " hdutype= " << hdutype << endl;
[1209]459 throw IOExc("FitsFile::GetBlockType: this HDU type is unknown");
[903]460 }
461
[971]462 KeywordsIntoDVList(fileptr, dvl, hdunum);
[903]463 fits_close_file(fileptr,&status);
464}
465
[1136]466
[1300]467void FitsInFile::ReadHeader(int hdunum)
[1045]468{
[1300]469 // InitNull();
[1045]470 int status = 0;
[1334]471 if (hdunum<0)
472 {
[1703]473 throw PException(" FitsInFile::ReadHeader : hdu number must be not negative");
[1334]474 }
[1234]475 if (hdunum != 0 ) hdunum_ = hdunum;
476
477 // si le numero de header non precise
478 else
[1045]479 {
[1234]480 // si c'est le premier objet a lire
481 if (hdunum_ == 0)
[1045]482 {
[1234]483 // on calcule le numero de header a lire
[1246]484 if (imageOnPrimary_ == true ) hdunum_ = 1;
[1234]485 else hdunum_ = 2;
[1045]486 }
[1234]487 // sinon objet suivant
488 else hdunum_++;
[1045]489 }
[1771]490 getHeaderWithSophyaObject();
[1334]491 if ( hdutype_ == FitsExtensionType_NULL )
492 {
493 if (hdunum == 0 && hdunum_ == 1)
494 {
495 hdunum_++;
[1771]496 getHeaderWithSophyaObject();
[1334]497 }
498 else
499 {
500 cout << " WARNING (FitsInFile::ReadHeader) : no SOPHYA object on HDU number : " << hdunum_ << endl;
501 }
502 }
[1418]503 if ( hdutype_ == FitsExtensionType_EOF )
504 {
505 throw PException("FitsFile::ReadHeader, attempt to read through EOF");
506 }
[1045]507}
508
[1354]509string FitsInFile::getStringKeyword(int hdunum, string keyw, int& retStatus)
510{
511 string s;
512 retStatus = 0;
513 int status = 0;
514 if (hdunum != hdunum_ )
515 {
516 int hdutype;
517 fits_movabs_hdu(fptr_,hdunum,&hdutype,&status);
518 }
519
520 char value[FLEN_VALUE];
521 char* keyname= const_cast<char*>(keyw.c_str());
522 fits_read_key_str(fptr_,keyname,value,NULL,&status);
523 if (status == 0)
524 s = string(value);
525 else retStatus = status;
526 if (hdunum != hdunum_ )
527 {
528 int hdutype;
529 if (hdunum_ != 0)
530 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
531 else fits_movabs_hdu(fptr_,1,&hdutype,&status);
532
533 }
534 return s;
535}
536bool FitsInFile::hasKeyword(int hdunum, string keyw)
[1353]537 {
538 bool has=false;
539 int status = 0;
540 if (hdunum != hdunum_ )
541 {
542 int hdutype;
543 fits_movabs_hdu(fptr_,hdunum,&hdutype,&status);
544 }
[1218]545
[1353]546 char value[FLEN_VALUE];
547 char* keyname= const_cast<char*>(keyw.c_str());
548 fits_read_keyword(fptr_,keyname,value,NULL,&status);
549 if (status == 0)
550 has = true;
551 else
552 if (status == KEY_NO_EXIST ) status =0;
553 else fits_report_error(stderr,status);
554 if (hdunum != hdunum_ )
555 {
556 int hdutype;
557 if (hdunum_ != 0)
558 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
559 else fits_movabs_hdu(fptr_,1,&hdutype,&status);
560
561 }
562 return has;
563 }
564
[1771]565void FitsInFile::GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const
566{
567 int status = 0;
568 int hdutype;
569 fits_movabs_hdu(fptr_,hdunum,&hdutype,&status);
570 if( status ) fits_report_error(stderr,status);
571
572 // get number of keywords
573 int nkeys,keypos;
574 fits_get_hdrpos(fptr_, &nkeys, &keypos,&status);
575 if( status ) fits_report_error(stderr,status);
576 // shift with the number of mandatory keywords
577 int num= 0;
578 // if primary header
579 if (hdunum == 1)
580 {
581 // read NAXIS
582 int naxis=0;
583 fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
584 // number of mandatory keywords
585 num = naxis+3;
586 }
587 // extensions
588 else
589 {
590 if (hdutype == IMAGE_HDU)
591 {
592 // read NAXIS
593 int naxis=0;
594 fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
595 // number of mandatory keywords
596 num = naxis+5;
597 }
598 else
599 if(hdutype == ASCII_TBL || hdutype == BINARY_TBL)
600 {
601 // number of mandatory keywords
602 num = 8;
603 }
604 }
605 int j;
606 char keyname[LEN_KEYWORD];
607 char value[FLEN_VALUE];
608 char comment[FLEN_COMMENT];
609 for(j = num+1; j <= nkeys; j++)
610 {
611 char dtype;
612 fits_read_keyn(fptr_,j,keyname,value,comment,&status);
613 if(status)
614 {
615 fits_report_error(stderr,status);
616 status=0;
617 }
618 string kn(keyname);
619 string cm(comment);
620 string val(value);
621 FitsKeyword kw(kn, val, cm);
622 mots_cles.push_back(kw);
623 }
624 if (hdunum_ > 0) fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
625
626}
[1300]627void FitsInFile::GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn)
[1218]628{
629 int hdunum=0;
[1334]630 // cout << " Reading a FITS image in HDU : " << fits_get_hdu_num(fileptr,&hdunum) << endl;
[1218]631 int status= 0;
632
633 // bits per pixels
[1300]634 int bitpix=0;
[1218]635 fits_read_key(fileptr,TINT,"BITPIX",&bitpix,NULL,&status);
636 if( status ) printerror( status );
[1300]637 if(bitpix == DOUBLE_IMG) dataType = FitsDataType_double;
638 else if(bitpix == FLOAT_IMG) dataType = FitsDataType_float;
639 else if(bitpix == LONG_IMG || bitpix == SHORT_IMG ) dataType = FitsDataType_int;
640 else if (bitpix == BYTE_IMG) dataType = FitsDataType_char;
641 else
642 {
643 cout << " bitpix= " << bitpix << endl;
644 throw PException(" FitsFile::GetImageParameters : unsupported FITS data type");
645 }
[1218]646
647 // number of dimensions in the FITS array
648 naxis= 0;
649 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status);
650 if( status ) printerror( status );
651 // read the NAXISn keywords to get image size
652 long* naxes = new long[naxis] ;
653 int nfound;
654 fits_read_keys_lng(fileptr,"NAXIS",1,naxis,naxes,&nfound,&status);
655 if( status ) printerror( status );
656 if (nfound != naxis )
657 cout << " WARNING : " << nfound << " axes found, expected naxis= " << naxis << endl;
658 int k;
659 for (k=0; k<naxis; k++)
660 {
661 naxisn.push_back( (int)naxes[k] );
662 }
663 delete [] naxes;
664}
665
666
667
668
669 /*! \fn DVList SOPHYA::FitsInFile::DVListFromPrimaryHeader() const
670
671 \return the keywords of primary header in a DVList
672
673*/
[1143]674DVList FitsInFile::DVListFromPrimaryHeader() const
675 {
676 int status;
677 DVList dvl;
678 KeywordsIntoDVList(fptr_, dvl, 1);
679 int hdutype = 0;
680 if (hdunum_ > 0) fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
681 return dvl;
682 }
[1136]683
[1771]684void FitsInFile::getHeaderWithSophyaObject()
[971]685{
[1300]686 // si hdunum_ > 1 lit le header correspondant
687 // si hdunum_ = 1 se positionne au (et lit le) premier header qui
688 // contient reellement un objet
[1234]689 int status=0;
690 if (hdunum_ < 1) throw PException(" attempt to read hdunum < 1");
[1300]691 InitNull();
[1234]692 if (hdunum_ == 1)
[839]693 {
[1234]694 // presence of image ?
695 int naxis= 0;
696 fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
697 if( status ) printerror( status );
698 if (naxis > 0 ) // there is an image
699 {
[1334]700 hdutype_ = FitsExtensionType_IMAGE;
[1300]701 GetImageParameters (fptr_, imageDataType_, naxis_, naxisn_);
[1234]702 nbData_ = 1;
703 int k;
704 for (k=0; k<naxis_; k++) if (naxisn_[k] > 0) nbData_ *= naxisn_[k];
705 KeywordsIntoDVList(fptr_, dvl_,hdunum_);
706 }
707 else
708 {
[1334]709 hdutype_ = FitsExtensionType_NULL;
710 KeywordsIntoDVList(fptr_, dvl_,hdunum_);
[1234]711 }
[839]712 }
[1234]713 else
[839]714 {
[1234]715 int hdutype;
716 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
[1334]717
718 if( status )
[1234]719 {
[1334]720 if (status == END_OF_FILE)
721 {
722 hdutype_= FitsExtensionType_EOF;
723 status =0;
724 return;
725 }
726 else
727 {
[1771]728 cout << "WARNING (FitsInFile::getHeaderWithSophyaObject) : error during movabs" << endl;
[1334]729 hdutype_= FitsExtensionType_ERROR;
730 status =0;
731 return;
732 }
733 // printerror( status,":FitsInFile::getHeader : erreur movabs");
734 }
[2197]735
736
[1334]737 if(hdutype == IMAGE_HDU)
738 {
739 hdutype_= FitsExtensionType_IMAGE;
[1300]740 GetImageParameters (fptr_, imageDataType_, naxis_, naxisn_);
[1234]741 nbData_ = 1;
742 int k;
743 for (k=0; k<naxis_; k++) if (naxisn_[k] > 0) nbData_ *= naxisn_[k];
744 KeywordsIntoDVList(fptr_, dvl_,hdunum_);
745 }
[1334]746 else if(hdutype == ASCII_TBL)
[1234]747 {
[1334]748 hdutype_= FitsExtensionType_ASCII_TBL;
[1234]749 GetBinTabParameters(fptr_,nbcols_, nrows_,repeat_, noms_, types_, taille_des_chaines_);
750 KeywordsIntoDVList(fptr_, dvl_, hdunum_);
751 }
[1334]752 else if(hdutype == BINARY_TBL)
753 {
754 hdutype_= FitsExtensionType_BINARY_TBL;
755 GetBinTabParameters(fptr_,nbcols_, nrows_,repeat_, noms_, types_, taille_des_chaines_);
756 KeywordsIntoDVList(fptr_, dvl_, hdunum_);
757 }
758 else
759 {
760 hdutype_= FitsExtensionType_NULL;
761 KeywordsIntoDVList(fptr_, dvl_, hdunum_);
762 }
[2197]763
[839]764 }
[2197]765 if (hdutype_ == FitsExtensionType_BINARY_TBL || hdutype_ == FitsExtensionType_ASCII_TBL)
766 {
767 bfl_ = BufferLine(types_);
768 }
[971]769}
[839]770
[1136]771
[1234]772void FitsInFile::moveToFollowingHeader()
773{
774 int status = 0;
775 hdunum_++;
[1771]776 getHeaderWithSophyaObject();
[1334]777 if ( hdutype_ == FitsExtensionType_NULL )
778 {
779 cout << " WARNING (FitsInFile::ReadHeader) : no SOPHYA object on HDU number : " << hdunum_ << endl;
780
781 }
[1234]782}
[1218]783
784
785
[1234]786
787
[1218]788/*! \fn int SOPHYA::FitsInFile::NbColsFromFits() const
789\return number of columns (return 1 if IMAGE)
790*/
[1136]791int FitsInFile::NbColsFromFits() const
[839]792{
[1334]793 if(hdutype_ == FitsExtensionType_BINARY_TBL) return nbcols_;
[971]794 else
[1334]795 if(hdutype_ == FitsExtensionType_ASCII_TBL || hdutype_ == FitsExtensionType_IMAGE) return 1;
[839]796 else
797 {
[1379]798 cout << " hdutype= " << (int) hdutype_ << endl;
[1334]799 throw PException("FitsFile::NbColsFromFits, HDU not supported");
[839]800 }
801}
802
[1218]803/*! \fn int SOPHYA::FitsInFile::NentriesFromFits(int nocol) const
804\return number of data in the current IMAGE extension on FITS file, or number
805 of data of column number 'nocol' of the current BINTABLE extension
806*/
[1136]807int FitsInFile::NentriesFromFits(int nocol) const
[839]808{
[1334]809 if(hdutype_ == FitsExtensionType_BINARY_TBL) return nrows_*repeat_[nocol];
[1136]810 else
[1334]811 if(hdutype_ == FitsExtensionType_ASCII_TBL) return nrows_;
[1136]812 else
[1334]813 if(hdutype_ == FitsExtensionType_IMAGE) return nbData_;
[1136]814 else
[839]815 {
[1379]816 cout << "hdutype= " << (int) hdutype_ << endl;
[1334]817 throw PException("FitsFile::NentriesFromFits, this HDU is not supported");
[839]818 }
819}
820
[1218]821/*! \fn char SOPHYA::FitsInFile::ColTypeFromFits(int nocol) const
822
823return a character denoting data type of column number 'nocol' in a BINTABLE :
824
825D : double
826
827E : float
828
829I : integer
830
831S : character string
832
833 */
834
[1300]835FitsFile::FitsDataType FitsInFile::ColTypeFromFits(int nocol) const
[839]836{
[1334]837 if(hdutype_ != FitsExtensionType_ASCII_TBL && hdutype_ != FitsExtensionType_BINARY_TBL)
[839]838 {
[1136]839 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table");
[839]840 }
[1136]841 return types_[nocol];
[839]842}
[1218]843
844
845/*! \fn string SOPHYA::FitsInFile::ColNameFromFits(int nocol) const
846
847\return name of the column number 'nocol' of the current BINTABLE extension
848 */
849
[1136]850string FitsInFile::ColNameFromFits(int nocol) const
[839]851{
[1334]852 if(hdutype_ != FitsExtensionType_ASCII_TBL && hdutype_ != FitsExtensionType_BINARY_TBL)
[1045]853 {
[1136]854 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table");
[1045]855 }
[1136]856 return noms_[nocol];
[839]857}
858
[1218]859/*! \fn int DSOPHYA::FitsInFile::ColStringLengthFromFits(int nocol) const
860
861 \return number of characters of each data for the column number 'nocol' (if char* typed) of the current BINTABLE extension
862*/
863
[1136]864int FitsInFile::ColStringLengthFromFits(int nocol) const
[839]865{
[1334]866 if(hdutype_ != FitsExtensionType_ASCII_TBL && hdutype_ != FitsExtensionType_BINARY_TBL)
[1136]867 {
868 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table");
869 }
870 int index=-1;
871 int k;
872 for (k=0; k<=nocol; k++)
873 {
[1300]874 if (types_[k] == FitsDataType_char) index++;
[1136]875 }
876 return taille_des_chaines_[index];
[839]877}
[1218]878
[2197]879const FitsFile::BufferLine& FitsInFile::GetBufferLine(long NoLine)
880{
881 int status= 0;
882 int anynul;
883 double dnull= dnull_;
884 float fnull= fnull_;
885 int inull= inull_;
886 char* cnull= const_cast<char*>(cnull_.c_str());
887 int ncol;
888 long nels=1;
889 double dval;
890 float fval;
891 int ival;
[1218]892
[2197]893 // pas d'entier de longueur superieure a 32 bits, pour cfitsio
894 int lval;
[1218]895
[2197]896 unsigned char usval;
897 int rang = 0;
898 int ccount = 0;
899 for (ncol=0; ncol<nbcols_; ncol++)
900 {
901 rang = bfl_.identificateur()[ncol].second;
902 // cout << " fitsfile : relecture col " << ncol << " type " << bfl_.identificateur()[ncol].first << " rang " << rang << endl;
903 switch (bfl_.identificateur()[ncol].first)
904 {
905 case FitsDataType_double :
906 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull, &dval,&anynul,&status);
907 bfl_.r_8Array(rang) = (r_8)dval;
908 break;
909 case FitsDataType_float :
910 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fval,&anynul,&status);
911 bfl_.r_4Array(rang) = (r_4)fval;
912 break;
913 case FitsDataType_short :
914 fits_read_col(fptr_,TSHORT,ncol+1,NoLine+1,1,1,&inull,&ival, &anynul,&status);
915 bfl_.int_2Array(rang) = (int_2)ival;
916 break;
917 case FitsDataType_int :
918 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ival, &anynul,&status);
919 bfl_.int_4Array(rang) = (int_4)ival;
920 break;
921 case FitsDataType_long :
922 fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&lval, &anynul,&status);
923 bfl_.int_8Array(rang) = (int_8)lval;
924 break;
925 case FitsDataType_byte :
926 fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull, &usval, &anynul,&status);
927 bfl_.u_charArray(rang) = usval;
928 break;
929 case FitsDataType_char :
930 char* chaine = new char[taille_des_chaines_[ccount++]];
931 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status);
932 bfl_.stringArray(rang) = string(chaine);
933 break;
934 }
935 if (status)
936 {
937 ResetStatus(status);
938 break;
939 }
940 }
941 // cout << " fitsfile : ligne relue " << endl;
942 // bfl_.Print();
943 return bfl_;
944}
945
946
947
[1218]948/*! \fn void SOPHYA::FitsInFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata)
949
950Get the NoLine-th 'line' from the current BINTABLE extension on FITS file,
951 */
952
[1193]953void FitsInFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata)
[839]954{
955 int status= 0;
[1978]956 int anynul;
957 double dnull= dnull_;
958 float fnull= fnull_;
959 int inull= inull_;
960 char* cnull= const_cast<char*>(cnull_.c_str());
[1136]961 int dcount = 0.;
962 int fcount = 0.;
963 int icount = 0;
964 int ccount =0;
965 int ncol;
966 long nels=1;
[1499]967 int ligneAsolue = NoLine+1;
[1136]968 for (ncol=0; ncol<nbcols_; ncol++)
[861]969 {
[1499]970 int repetition =repeat_[ncol];
971 int ligneALire = ligneAsolue/repetition;
972 int premierElement = ligneAsolue-ligneALire*repetition;
973 if (premierElement != 0 )
974 {
975 ligneALire++;
976 }
977 else premierElement = repetition;
978
[1136]979 switch (types_[ncol])
980 {
[1300]981 case FitsDataType_double :
[1499]982 {
[1978]983 fits_read_col(fptr_,TDOUBLE,ncol+1,ligneALire,premierElement,1,&dnull,&ddata[dcount++],&anynul,&status);
[1136]984 break;
[1499]985 }
[2197]986 case FitsDataType_float :
987 {
988 fits_read_col(fptr_,TFLOAT,ncol+1,ligneALire,premierElement,1,&fnull,&fdata[fcount++],&anynul,&status);
989 break;
990 }
[1300]991 case FitsDataType_int :
[2197]992 {
993 fits_read_col(fptr_,TINT,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++],
[1978]994 &anynul,&status);
[2197]995 break;
996 }
[1499]997 case FitsDataType_long :
[2197]998 {
999 fits_read_col(fptr_,TLONG,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], &anynul,&status);
1000 break;
1001 }
[1499]1002 case FitsDataType_byte :
1003 {
1004 unsigned char uschar = 0;
[1978]1005 fits_read_col(fptr_,TBYTE,ncol+1,ligneALire,premierElement,1,&inull,&uschar, &anynul,&status);
[1499]1006 idata[icount++] = (int)uschar;
[2197]1007 break;
[1499]1008 }
[1300]1009 case FitsDataType_char :
[2197]1010 {
1011 fits_read_col(fptr_,TSTRING,ncol+1,ligneALire,premierElement,1,cnull,&cdata[ccount++],&anynul,&status);
1012 break;
1013 }
1014 default:
1015 {
1016 throw PException(" FitsInFile::GetBinTabLine : unsupported FITS data type");
1017 }
[1136]1018 }
1019 if (status)
1020 {
1021 ResetStatus(status);
1022 break;
1023 }
[861]1024 }
[903]1025}
[839]1026
[1218]1027/*! \fn void SOPHYA::FitsInFile::GetBinTabLine(long NoLine, BnTblLine& ligne)
1028Get the NoLine-th 'line' from the current BINTABLE extension on FITS file,
1029*/
[1193]1030void FitsInFile::GetBinTabLine(long NoLine, BnTblLine& ligne)
1031{
1032 int status= 0;
[1978]1033 int anynul;
1034 double dnull= dnull_;
1035 float fnull= fnull_;
1036 int inull= inull_;
1037 char* cnull= const_cast<char*>(cnull_.c_str());
[1193]1038 int dcount = 0.;
1039 int fcount = 0.;
1040 int icount = 0;
[2233]1041 int lcount = 0;
1042 int bcount = 0;
[1193]1043 int ccount =0;
1044 int ncol;
1045 long nels=1;
1046 for (ncol=0; ncol<nbcols_; ncol++)
1047 {
1048 switch (types_[ncol])
1049 {
[1300]1050 case FitsDataType_double :
[2197]1051 {
1052 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ligne.ddata_[dcount++],&anynul,&status);
1053 break;
1054 }
[1300]1055 case FitsDataType_float :
[2197]1056 {
1057 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&ligne.fdata_[fcount++],&anynul,&status);
1058 break;
1059 }
[1300]1060 case FitsDataType_int :
[2197]1061 {
1062 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ligne.idata_[icount++], &anynul,&status);
1063 break;
1064 }
[1359]1065 case FitsDataType_long :
[2197]1066 {
[2233]1067 fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&ligne.ldata_[lcount++], &anynul,&status);
[2197]1068 break;
1069 }
[1359]1070 case FitsDataType_byte :
[2197]1071 {
[2233]1072 fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull,&ligne.bdata_[bcount++], &anynul,&status);
[2197]1073 break;
1074 }
[1300]1075 case FitsDataType_char :
[2197]1076 {
1077 char* chaine = new char[taille_des_chaines_[ccount]];
1078 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status);
1079 ligne.cdata_[ccount++] = string(chaine);
1080 break;
1081 }
1082 default:
1083 {
1084 throw PException(" FitsInFile::GetBinTabLine : unsupported FITS data type");
1085 }
[1193]1086 }
1087 if (status)
1088 {
1089 ResetStatus(status);
1090 break;
1091 }
1092 }
1093}
1094
[2197]1095
1096
[1218]1097/*! \fn void SOPHYA::FitsInFile::GetBinTabLine(int NoLine, float* fdata)
1098
1099Get the NoLine-th float 'line' from the current BINTABLE extension on FITS file,
1100*/
[1136]1101void FitsInFile::GetBinTabLine(int NoLine, float* fdata)
[903]1102{
[1136]1103 int status= 0;
[1978]1104 int anynul;
1105 float fnull= fnull_;
[1136]1106 long nels=1;
1107 int ncol;
1108 for (ncol=0; ncol<nbcols_; ncol++)
[861]1109 {
[1978]1110 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[ncol],&anynul,&status);
[1136]1111 if (status)
[903]1112 {
[1136]1113 ResetStatus(status);
1114 break;
[903]1115 }
[1136]1116 }
1117}
[839]1118
[903]1119
[1218]1120/*! \fn void SPOPHYA::FitsInFile::GetBinTabFCol(double* valeurs,int nentries, int NoCol) const
1121
1122fill the array 'valeurs' with double data from the current BINTABLE extension on FITS file, from column number 'NoCol'
1123
1124\param <nentries> number of data to be read
1125*/
[1379]1126void FitsInFile::GetBinTabFCol(r_8* valeurs,int nentries, int NoCol) const
[839]1127 {
1128 int status= 0;
1129 int DTYPE;
1130 long repeat,width;
1131 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status);
1132 if( DTYPE != TDOUBLE)
1133 {
[1045]1134 if (DTYPE == TFLOAT) cout << " WARNING: reading double from float : conversion will be made by fitsio library" << endl;
1135 else
1136 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non double");
[839]1137 }
1138 long nels=nentries;
[1978]1139 int anynul;
1140 double dnull= dnull_;
1141
[839]1142 fits_read_col(fptr_,TDOUBLE,NoCol+1,1,1,nels,&dnull,valeurs,
[1978]1143 &anynul,&status);
[1703]1144 if( status )
1145 {
1146 printerrorAndContinue( status,"erreur lecture de colonne" );
1147 }
[839]1148 }
1149
[1218]1150/*! \fn void SOPHYA::FitsInFile::GetBinTabFCol(float* valeurs,int nentries, int NoCol) const
1151
1152 same as previous method with float data
1153*/
[1379]1154void FitsInFile::GetBinTabFCol(r_4* valeurs,int nentries, int NoCol) const
[839]1155 {
1156 int status= 0;
1157 int DTYPE;
1158 long repeat,width;
1159 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status);
1160 if( DTYPE != TFLOAT)
1161 {
[1045]1162 if (DTYPE == TDOUBLE) cout << " WARNING: reading float from double : conversion will be made by fitsio library" << endl;
1163 else
1164 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non float");
[839]1165 }
1166 long nels=nentries;
[1978]1167 int anynul;
1168 float fnull= fnull_;
[839]1169 fits_read_col(fptr_,TFLOAT,NoCol+1,1,1,nels,&fnull,valeurs,
[1978]1170 &anynul,&status);
[1703]1171 if( status ) printerrorAndContinue( status,"erreur lecture de colonne" );
[839]1172 }
[1136]1173
[1218]1174/*! \fn void SOPHYA::FitsInFile::GetBinTabFCol(int* valeurs,int nentries, int NoCol) const
1175
1176 same as previous method with int data
1177*/
1178
[1379]1179void FitsInFile::GetBinTabFCol(int_4* valeurs,int nentries, int NoCol) const
[839]1180 {
1181 int status= 0;
1182 int DTYPE;
1183 long repeat,width;
1184 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status);
[1752]1185 if( DTYPE != TLONG && DTYPE != TINT)
[839]1186 {
[1752]1187 throw IOExc("FitsFile::GetBinTabFCol, probleme de lecture d'entiers");
[839]1188 }
1189 long nels=nentries;
[1978]1190 int anynul;
1191 int inull= inull_;
[1752]1192
1193
1194
1195 // voir commentaire dans putColToFits()
[839]1196 fits_read_col(fptr_,TINT,NoCol+1,1,1,nels,&inull,valeurs,
[1978]1197 &anynul,&status);
[1703]1198 if( status ) printerrorAndContinue( status,"erreur lecture de colonne" );
[839]1199 }
[1136]1200
[1218]1201/*! \fn void SOPHYA::FitsInFile::GetBinTabFCol(char** valeurs, int nentries, int NoCol) const
1202
1203 same as previous method with char* data
1204*/
1205
[1136]1206void FitsInFile::GetBinTabFCol(char** valeurs, int nentries, int NoCol) const
[839]1207 {
1208 int status= 0;
1209 int DTYPE;
1210 long repeat,width;
1211 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status);
[1300]1212 if( DTYPE != TSTRING && DTYPE != TBYTE)
[839]1213 {
[1300]1214 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non string");
[839]1215 }
1216 long nels=nentries;
[1978]1217 int anynul;
1218 char* cnull= const_cast<char*>(cnull_.c_str());
[839]1219 long frow=1;
1220 long felem=1;
1221 fits_read_col(fptr_,TSTRING,NoCol+1,frow,felem,nels,cnull,valeurs,
[1978]1222 &anynul,&status);
[1703]1223 if( status ) printerrorAndContinue( status,"erreur lecture de colonne" );
[839]1224 }
[1045]1225
[1218]1226/*! \fn void SOPHYA::FitsInFile::GetSingleColumn(double* map, int nentries) const
1227fill the array 'map' with double data from the current extension on FITS file.
1228If the extension is BINTABLE, the first column is provided.
1229
1230\param <nentries> number of data to be read
1231*/
[1379]1232void FitsInFile::GetSingleColumn(r_8* map, int nentries) const
[1136]1233{
1234 int status = 0;
[1334]1235 if(hdutype_ == FitsExtensionType_IMAGE)
[1045]1236 {
[1136]1237
[1300]1238 if(imageDataType_ != FitsDataType_double)
[1047]1239 {
[1136]1240 cout << " The data type on fits file is not double...";
1241 cout << " Conversion to double achieved by cfitsio lib" << endl;
[1047]1242 }
[1136]1243
[1978]1244 int anynul;
1245 double dnull= dnull_;
[1136]1246
1247 long nels= nentries;
[1978]1248 fits_read_img(fptr_,TDOUBLE,1,nels,&dnull,map,&anynul,&status);
[1136]1249 if( status ) printerror( status );
[1045]1250 }
[1136]1251 else
[1334]1252 if(hdutype_ == FitsExtensionType_ASCII_TBL || hdutype_ == FitsExtensionType_BINARY_TBL)
[1136]1253 {
1254 GetBinTabFCol(map,nentries, 0);
1255 }
1256 else
1257 {
[1379]1258 cout << " hdutype= " << (int) hdutype_ << endl;
[1334]1259 throw IOExc("FitsFile::GetSingleColumn, this HDU is unknown");
[1136]1260 }
[1045]1261}
1262
[1218]1263/*! \fn void SOPHYA::FitsInFile::GetSingleColumn(float* map, int nentries) const
1264same as above with float data
1265*/
[1379]1266void FitsInFile::GetSingleColumn(r_4* map, int nentries) const
[1045]1267{
[1136]1268 int status = 0;
[1334]1269 if(hdutype_ == FitsExtensionType_IMAGE)
[1045]1270 {
[1300]1271 if(imageDataType_ != FitsDataType_float)
[1047]1272 {
[1136]1273 cout << " The data type on fits file is not float ";
1274 cout << " Conversion to float achieved by cfitsio lib" << endl;
[1047]1275 }
[1978]1276 int anynul;
1277 float fnull= fnull_;
[1136]1278
1279 long nels= nentries;
[1978]1280 fits_read_img(fptr_,TFLOAT,1,nels,&fnull, map,&anynul,&status);
[1136]1281 if( status ) printerror( status );
[1045]1282 }
[839]1283 else
[1334]1284 if(hdutype_ == FitsExtensionType_ASCII_TBL || hdutype_ == FitsExtensionType_BINARY_TBL)
[1136]1285 {
1286 GetBinTabFCol(map,nentries, 0);
1287 }
[839]1288 else
1289 {
[1379]1290 cout << " hdutype= " << (int) hdutype_ << endl;
[1136]1291 throw IOExc("FitsFile::GetSingleColumn this HDU is unknown");
[839]1292 }
1293}
1294
[1218]1295/*! \fn void SOPHYA::FitsInFile::GetSingleColumn( int* map, int nentries) const
1296 same as above with int data
1297*/
[1379]1298void FitsInFile::GetSingleColumn( int_4* map, int nentries) const
[839]1299{
[1136]1300 int status = 0;
[1334]1301 if(hdutype_ == FitsExtensionType_IMAGE)
[839]1302 {
[1300]1303 if(imageDataType_ != FitsDataType_int)
[1136]1304 {
1305 cout << " The data type on fits file is not int ";
1306 cout << " Conversion to float achieved by cfitsio lib" << endl;
1307 }
[1978]1308 int anynul;
1309 float fnull= fnull_;
[1136]1310
1311 long nels= nentries;
[1978]1312 fits_read_img(fptr_,TINT,1,nels,&fnull,map,&anynul,&status);
[1136]1313 if( status ) printerror( status );
[839]1314 }
1315 else
[1334]1316 if(hdutype_ == FitsExtensionType_ASCII_TBL || hdutype_ == FitsExtensionType_BINARY_TBL)
[1136]1317 {
1318 GetBinTabFCol(map,nentries, 0);
1319 }
[839]1320 else
[1136]1321 {
[1379]1322 cout << " hdutype= " << (int) hdutype_ << endl;
[1136]1323 throw IOExc("FitsFile::GetSingleColumn this HDU is unknown");
1324 }
[839]1325}
1326
[1136]1327void FitsInFile::GetBinTabParameters(fitsfile* fileptr, int& nbcols, int& nrows,
[903]1328 vector<int>& repeat,
1329 vector<string>& noms,
[1300]1330 vector<FitsDataType>& types,
[903]1331 vector<int>& taille_des_chaines)
[839]1332{
1333 int status= 0;
[903]1334 int hdunum=0;
1335 int hdutype=0;
1336 fits_get_hdu_num(fileptr,&hdunum);
1337 fits_get_hdu_type(fileptr, &hdutype, &status);
1338
1339 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
[839]1340 {
[903]1341 throw IOExc("FitsFile::GetBinTabParameters this HDU is not an ASCII table nor a binary table");
[839]1342 }
[1334]1343 // if(hdutype == ASCII_TBL)
1344 // cout << " Reading a FITS ascii table in HDU : " << hdunum << endl;
1345 // if(hdutype == BINARY_TBL)
1346 // cout << " Reading a FITS binary table in HDU : " << hdunum << endl;
[839]1347
1348 // get the number of columns
[903]1349 fits_get_num_cols(fileptr, &nbcols,&status);
[839]1350 if( status ) printerror( status );
1351
1352 // get the number of rows
1353 long naxis2= 0;
[903]1354 fits_get_num_rows(fileptr,&naxis2,&status);
[839]1355 if( status ) printerror( status );
[903]1356 nrows = (int)naxis2;
[839]1357
1358 // get the datatype, names and the repeat count
[903]1359 noms.clear();
1360 noms.reserve(nbcols);
1361 types.clear();
1362 types.reserve(nbcols);
1363 repeat.clear();
1364 repeat.reserve(nbcols);
1365 taille_des_chaines.clear();
[839]1366 char **ttype = new char*[nbcols];
[923]1367 int ii;
[1175]1368 //
1369 //
[923]1370 for (ii=0; ii < nbcols; ii++) ttype[ii]=new char[FLEN_VALUE];
[839]1371 int nfound;
[903]1372 fits_read_keys_str(fileptr, "TTYPE",1,nbcols,ttype,&nfound, &status);
[839]1373 if( status ) printerror( status,"erreur lecture des noms de colonne");
1374 int rept=0;
[1300]1375 if(hdutype == ASCII_TBL)
[839]1376 {
[1300]1377 for(ii = 0; ii < nbcols; ii++)
[839]1378 {
[1300]1379 int DTYPE;
1380 long width;
1381 long repete = 0;
1382 fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status);
1383 if( status ) printerror( status,"erreur lecture type de colonne");
1384 rept = repete;
1385 noms.push_back(string(ttype[ii]));
1386 switch (DTYPE)
1387 {
1388 case TDOUBLE :
1389 types.push_back(FitsDataType_double);
1390 break;
1391 case TFLOAT :
1392 types.push_back(FitsDataType_float);
1393 break;
1394 case TLONG :
[1359]1395 types.push_back(FitsDataType_long);
[1300]1396 break;
[2197]1397 case TINT :
[1300]1398 types.push_back(FitsDataType_int);
1399 break;
[2197]1400 case TSHORT :
1401 types.push_back(FitsDataType_short);
1402 break;
[1300]1403 case TSTRING :
1404 types.push_back(FitsDataType_char);
1405 taille_des_chaines.push_back(width);
1406 rept/=width;
1407 break;
1408 default :
1409 cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl;
1410 throw IOExc("FitsFile::GetBinTabParameters, unsupported data type of field, for ASCII table");
1411 }
1412 repeat.push_back(rept);
[839]1413 }
[1136]1414 }
[1300]1415 else
1416 {
1417 for(ii = 0; ii < nbcols; ii++)
1418 {
1419 int DTYPE;
1420 long width;
1421 long repete = 0;
1422 fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status);
1423 if( status ) printerror( status,"erreur lecture type de colonne");
1424 rept = repete;
1425 noms.push_back(string(ttype[ii]));
1426 switch (DTYPE)
1427 {
1428 case TDOUBLE :
1429 types.push_back(FitsDataType_double);
1430 break;
1431 case TFLOAT :
1432 types.push_back(FitsDataType_float);
1433 break;
1434 case TLONG :
[1359]1435 types.push_back(FitsDataType_long);
[1300]1436 break;
1437 case TINT :
1438 types.push_back(FitsDataType_int);
1439 break;
1440 case TSHORT :
[2197]1441 types.push_back(FitsDataType_short);
[1300]1442 break;
1443 case TSTRING :
1444 types.push_back(FitsDataType_char);
1445 taille_des_chaines.push_back(width);
1446 rept/=width;
1447 break;
1448 case TBYTE :
[1359]1449 types.push_back(FitsDataType_byte);
[1300]1450 break;
1451 default :
1452 cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl;
1453 throw IOExc("FitsFile::GetBinTabParameters, unsupported data type of field, for BINTABLE");
1454 }
1455 repeat.push_back(rept);
1456 }
1457 }
[1136]1458 for (ii=0; ii < nbcols; ii++) delete [] ttype[ii];
1459 delete [] ttype;
1460}
1461
1462void FitsInFile::KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum)
1463{
1464 int status = 0;
1465 int hdutype;
1466 fits_movabs_hdu(fileptr,hdunum,&hdutype,&status);
1467 if( status ) printerror( status,":KeywordsIntoDVList : erreur movabs");
1468 // get number of keywords
1469 int nkeys,keypos;
1470 fits_get_hdrpos(fileptr,&nkeys,&keypos,&status);
1471 if( status ) printerror( status );
1472
1473 // put keywords in a DVList object
1474 char keyname[LEN_KEYWORD]= "";
1475 char strval[FLEN_VALUE]= "";
1476 char dtype;
1477 char card[FLEN_CARD];
1478 char *comkey = "COMMENT";
[1143]1479 char comment[FLEN_COMMENT];
[1136]1480
1481 // shift with the number of mandatory keywords
[1143]1482 // int num= 8;
1483 int num= 0;
1484 // primary header
1485 if (hdunum == 1)
1486 {
1487 // read NAXIS
1488 int naxis=0;
1489 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status);
1490 // number of mandatory keywords
1491 num = naxis+3;
1492 }
1493 // extensions
1494 else
1495 {
1496 if (hdutype == IMAGE_HDU)
1497 {
1498 // read NAXIS
1499 int naxis=0;
1500 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status);
1501 // number of mandatory keywords
1502 num = naxis+5;
1503 }
1504 else
1505 if(hdutype == ASCII_TBL || hdutype == BINARY_TBL)
1506 {
1507 // number of mandatory keywords
1508 num = 8;
1509 }
1510 }
[1136]1511 int j;
1512 for(j = num+1; j <= nkeys; j++)
1513 {
1514 fits_read_keyn(fileptr,j,card,strval,NULL,&status);
1515 if(status) printerror(status);
1516
1517 strncpy(keyname,card,LEN_KEYWORD-1);
1518 if(strncmp(keyname,comkey,LEN_KEYWORD-1) != 0 && strlen(keyname) != 0
1519 && strlen(strval) != 0)
1520 {
1521 fits_get_keytype(strval,&dtype,&status);
1522 if(status) printerror(status);
1523
1524 strip(keyname, 'B',' ');
1525 strip(strval, 'B',' ');
1526 strip(strval, 'B','\'');
1527
1528 switch( dtype )
1529 {
1530 case 'C':
[1143]1531 fits_read_key(fileptr,TSTRING,keyname,strval,comment,&status);
[1978]1532 if ( strncmp(keyname,"TTYPE",5) == 0 ||
1533 strncmp(keyname,"TFORM",5) == 0 ||
1534 strncmp(keyname,"TBCOL",5) == 0 ) break;
[1143]1535 dvl[keyname]= strval;
1536 dvl.SetComment(keyname, comment);
[1136]1537 break;
1538 case 'I':
1539 int ival;
[1143]1540 fits_read_key(fileptr,TINT,keyname,&ival,comment,&status);
[1136]1541 dvl[keyname]= (int_4) ival; // Portage mac DY
[1143]1542 dvl.SetComment(keyname, comment);
[1136]1543 break;
1544 case 'L':
1545 int ilog;
[1143]1546 fits_read_key(fileptr,TLOGICAL,keyname,&ilog,comment,&status);
[1136]1547 dvl[keyname]= (int_4) ilog;
[1143]1548 dvl.SetComment(keyname, comment);
[1136]1549 break;
1550 case 'F':
1551 double dval;
[1143]1552 fits_read_key(fileptr,TDOUBLE,keyname,&dval,comment,&status);
[1136]1553 dvl[keyname]= dval;
[1143]1554 dvl.SetComment(keyname, comment);
[1136]1555 break;
1556 }
1557
1558 }
[839]1559 }
[1978]1560 // dvl.Print();
[1136]1561}
1562
[1218]1563
1564/*!
1565 \class SOPHYA::FitsOutFile
[1371]1566 \ingroup FitsIOServer
[1218]1567 Class for loading SOPHYA objects from FITS Format Files (uses cfitsio lib)
1568*/
1569
[1136]1570FitsOutFile::FitsOutFile()
1571{
[1193]1572 InitNull();
[903]1573}
[839]1574
[1218]1575 /*! \fn SOPHYA::FitsOutFile::FitsOutFile(char flnm[], WriteMode wrm)
1576
1577\param <WriteMode> enum , WriteMode = clear -> if alreadyy exists, the file will be overwritten (else created) ; WriteMode = append -> further objects will be appended to the file if it exists (else : file created). WriteMode = unknown -> file created if does not exist, else : exception. (the last situation is the default)
1578
1579 */
[1231]1580
1581FitsOutFile::FitsOutFile(string const & flnm, WriteMode wrm)
[1136]1582{
[1231]1583 InitNull();
1584 openoutputfitsfile(flnm.c_str(), wrm);
1585}
[839]1586
[1231]1587FitsOutFile::FitsOutFile(const char * flnm, WriteMode wrm)
1588{
[1136]1589 InitNull();
[1231]1590 openoutputfitsfile(flnm, wrm);
1591}
1592
1593void FitsOutFile::openoutputfitsfile(const char * flnm, WriteMode wrm)
1594{
[1136]1595 int status = 0;
[839]1596
[1136]1597 // create new FITS file
[1183]1598 fits_create_file(&fptr_,flnm,&status);
1599 if( status )
[1136]1600 {
[1193]1601
1602 switch (wrm)
1603 {
[1183]1604 // si on veut ecrire a la fin de ce fichier
[1193]1605 case append :
[1183]1606 status = 0;
[1235]1607 fits_clear_errmsg();
[1183]1608 fits_open_file(&fptr_,flnm,READWRITE,&status);
1609 if( status )
1610 {
1611 cout << " error opening file: " << flnm << endl;
1612 printerror(status, "failure opening a file supposed to exist");
1613 }
1614 else cout << " file " << flnm << " opened, new objects will be appended " << endl;
1615 fits_get_num_hdus(fptr_, &hdunum_, &status);
1616 int hdutype;
1617 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
1618 if( status ) printerror( status,":FitsFile::WriteF : erreur movabs");
[1193]1619 break;
1620
1621 case clear :
[1183]1622 {
1623 status = 0;
[1235]1624 fits_clear_errmsg();
[2200]1625 char* newname = new char[strlen(flnm)+2];
[1183]1626 //
1627 newname[0] = '!';
1628 newname[1] = '\0';
1629 strcat(newname, flnm);
1630 fits_create_file(&fptr_,newname,&status);
[1193]1631 delete [] newname;
[1183]1632 if (status)
1633 {
1634 cout << " error opening file: " << flnm << endl;
1635 printerror(status, "unable to open file, supposed to exist");
1636 }
[1193]1637 else cout << " WARNING : file " << flnm << " is overwritten " << endl;
1638 break;
[1183]1639 }
[1193]1640 case unknown :
1641 printerror(status, " file seems already to exist");
1642 break;
[1183]1643
[1193]1644 }
[1136]1645 }
1646}
1647
1648
1649
[1218]1650/*! \fn void SOPHYA::FitsOutFile::makeHeaderImageOnFits(char type, int nbdim, int* naxisn, DVList &dvl)
1651
1652create an IMAGE header on FITS file.
1653\param <type> type of data (see method ColTypeFromFits)
1654\param <nbdim> number of dimensions : 1D, 2D, 3D etc. = NAXIS
1655\param <naxisn> array containind sizes of the different dimensions
1656*/
[1221]1657void FitsOutFile::makeHeaderImageOnFits(char type, int nbdim, int* naxisn, DVList* ptr_dvl)
[1136]1658{
1659 int status = 0;
1660 long naxis = nbdim;
1661 long* naxes = new long[nbdim];
[1246]1662 bool hdunfirst= (hdunum_ == 0);
1663 if (hdunfirst)
[1136]1664 {
[1143]1665 if (imageOnPrimary_ == false)
1666 {
[1234]1667 hdunum_ = 1;
[1143]1668 fits_create_img(fptr_,FLOAT_IMG,0,naxes,&status);
[1246]1669 }
[1136]1670 }
1671 int k;
1672 for (k=0; k< nbdim; k++) naxes[k] = (long)naxisn[k];
1673 if (type == 'D')
1674 fits_create_img(fptr_,DOUBLE_IMG,naxis,naxes,&status);
1675 else
1676 if (type == 'E')
1677 fits_create_img(fptr_,FLOAT_IMG,naxis,naxes,&status);
1678 else
1679 if (type == 'I')
1680 fits_create_img(fptr_,LONG_IMG,naxis,naxes,&status);
1681 else
1682 {
1683 cout << " type of data: " << type << endl;
1684 throw PException("FitsFile:::makeHeaderImageOnFits:unprogrammed type of data ");
1685 }
[1353]1686
[1246]1687 // on ajoute eventuellement un dvlist prepare et la doc SOPHYA
[1136]1688 hdunum_++;
[1246]1689 if (hdunfirst)
1690 {
1691 addDVListOnPrimary();
1692 writeSignatureOnFits(1);
1693 }
[1143]1694
[1353]1695 // header format FITS
1696
1697 writeAppendedHeaderOnFits();
1698
1699 // write supplementary keywords (from SOPHYA)
[1143]1700 // dvl.Print();
[1221]1701 if (ptr_dvl != NULL) addKeywordsOfDVList(*ptr_dvl);
[1143]1702
[1136]1703 delete [] naxes;
1704 if( status ) printerror( status, "erreur creation HDU IMAGE" );
1705
1706}
[1218]1707
1708
1709/*! \fn void SOPHYA::FitsOutFile::PutImageToFits(int nbData, double* map) const
1710
1711write double data from array 'map'on an IMAGE extension
1712\param <nbData> number of data to be written
1713*/
[1379]1714void FitsOutFile::PutImageToFits(int nbData, r_8* map) const
[1136]1715{
1716 int status = 0;
1717 long npix= nbData;
1718 fits_write_img(fptr_,TDOUBLE,1,npix,map,&status);
[1209]1719 if( status ) printerror( status, "erreur ecriture PutImageToFits" );
[1136]1720}
1721
[1218]1722/*! \fn void SOPHYA::FitsOutFile::PutImageToFits(int nbData, float* map) const
1723
1724same as previous method with float data
1725*/
[1379]1726void FitsOutFile::PutImageToFits(int nbData, r_4* map) const
[1136]1727{
1728 int status = 0;
1729 long npix= nbData;
1730 fits_write_img(fptr_,TFLOAT,1,npix, map,&status);
[1209]1731 if( status ) printerror( status, "erreur ecriture PutImageToFits" );
[1136]1732
1733}
[1218]1734
1735 /*! \fn void SOPHYA::FitsOutFile::PutImageToFits( int nbData, int* map) const
1736
1737 same as previous method with int data */
[1379]1738void FitsOutFile::PutImageToFits( int nbData, int_4* map) const
[1136]1739{
1740 int status = 0;
1741
1742 long npix= nbData;
1743 fits_write_img(fptr_,TINT,1,npix,map,&status);
[1209]1744 if( status ) printerror( status, "erreur ecriture PutImageToFits" );
[1136]1745}
1746
1747
1748
[1218]1749/*! \fn void SOPHYA::FitsOutFile::makeHeaderBntblOnFits( string fieldType, vector<string> Noms, int nentries, int tfields, DVList &dvl, string extname, vector<int> taille_des_chaines)
1750
1751create an BINTABLE header on FITS file.
1752\param <fieldType> array conta
1753ining characters denoting types of the different column (see method ColTypeFromFits)
1754\param <Noms> array of the names of columns
1755\param <nentries> number of data of each column
1756\param <tfields> number of columns
1757\param <dvl> a SOPHYA DVList containing keywords to be appended
1758\param <extname> keyword EXTNAME for FITS file
1759\param <taille_des_chaines> vector containing the number of characters of data for each char* typed column, with order of appearance in 'fieldType'
1760*/
[1300]1761void FitsOutFile::makeHeaderBntblOnFits(string fieldType, vector<string> Noms, int nentries, int tfields, DVList* ptr_dvl, string extname, vector<int> taille_des_chaines)
[839]1762{
[1209]1763 int k;
[839]1764 int status = 0;
1765 long nrows;
[1300]1766 // verifications de coherences
[1209]1767
[1193]1768 if (fieldType.length() != tfields)
[839]1769 {
[1193]1770 cout << " nombre de champs :" << tfields << "nombre de types: " << fieldType.length() << endl;
[1136]1771 throw ParmError("FitsFile:: fields and types don't match");
[839]1772
1773 }
[1209]1774 if (tfields > Noms.size())
1775 {
1776 cout << " WARNING: FitsOutFile::makeHeaderBntblOnFits, length of vector of column names not equal to total number of columns" << endl;
1777 for (k=0; k<(tfields-Noms.size()); k++) Noms.push_back( string(" "));
1778 }
1779
1780 // nombre de variables "chaines de caracteres"
1781 int nbString = 0;
1782 for (k=0; k<tfields;k++) if (fieldType[k] == 'A') nbString++;
1783 // coherence de la longueur du vecteur des tailles
1784 if (nbString > taille_des_chaines.size())
1785 {
1786 cout << " WARNING: FitsOutFile::makeHeaderBntblOnFits, length of vector of string lengths not equal to total number of columns" << endl;
1787 int strSz=0;
1788 for (k=0; k<taille_des_chaines.size(); k++) if ( taille_des_chaines[k] > strSz) strSz = taille_des_chaines[k];
1789 for (k=0; k<(nbString-taille_des_chaines.size()); k++) taille_des_chaines.push_back(strSz);
1790 }
[839]1791 char ** ttype= new char*[tfields];
1792 char ** tform= new char*[tfields];
1793 char largeur[FLEN_VALUE];
1794 int noColString=0;
[971]1795 for (k=0; k<tfields;k++)
[839]1796 {
1797 char format[FLEN_VALUE];
1798
1799 if(nentries < 1024)
1800 {
1801 nrows= nentries;
1802 if (fieldType[k] == 'A')
1803 {
1804 sprintf(largeur,"%d",taille_des_chaines[noColString++]);
1805 strcpy(format,largeur);
1806 }
1807 else strcpy(format,"1");
1808 }
1809 else
1810 {
1811 nrows = nentries/1024;
1812 if(nentries%1024 != 0) nrows++;
1813 if (fieldType[k] == 'A')
1814 {
[1136]1815 char largaux[FLEN_VALUE];
1816 sprintf(largeur,"%d",taille_des_chaines[noColString]);
1817 sprintf(largaux,"%d",1024*taille_des_chaines[noColString]);
1818 noColString++;
1819 strcpy(format, largaux);
[839]1820 }
1821 else strcpy(format,"1024");
1822 }
1823 strncat(format,&fieldType[k],1);
1824 if (fieldType[k] == 'A')
1825 {
1826 strcat(format,largeur);
1827 }
[1193]1828 ttype[k] = const_cast<char*>(Noms[k].c_str());
[839]1829 tform[k]= new char[FLEN_VALUE];
1830 strcpy(tform[k],format);
1831 }
[1193]1832 char* extn = const_cast<char*>(extname.c_str());
[839]1833
1834 // create a new empty binary table onto the FITS file
1835 // physical units if they exist, are defined in the DVList object
1836 // so the NULL pointer is given for the tunit parameters.
1837 nrows=0;
1838 fits_create_tbl(fptr_,BINARY_TBL,nrows,tfields,ttype,tform,
1839 NULL,extn,&status);
1840 if( status ) printerror( status );
[1353]1841
1842 int ii;
1843 for(ii = 0; ii < tfields; ii++)
1844 {
1845 delete [] tform[ii];
1846 }
1847 delete [] ttype;
1848 delete [] tform;
1849
1850 // on ajoute eventuellement des mots-cles
1851
[1246]1852 if ( hdunum_ == 0 )
1853 {
1854 hdunum_ = 2;
1855 addDVListOnPrimary();
1856 writeSignatureOnFits(1);
1857 }
[1026]1858 else hdunum_++;
[1353]1859
1860 // header format FITS
1861
1862 writeAppendedHeaderOnFits();
1863
1864 // write SOPHYA keywords
[1221]1865 if (ptr_dvl != NULL) addKeywordsOfDVList(*ptr_dvl);
[839]1866}
1867
[1353]1868
1869
[1218]1870/*! \fn void SOPHYA::FitsOutFile::PutColToFits(int nocol, int nentries, double* donnees) const
1871
1872write double data from array 'donnees ' on column number 'nocol' of a BINTABLE extension.
1873\param <nentries> number of data to be written
1874*/
[1353]1875
[1379]1876void FitsOutFile::PutColToFits(int nocol, int nentries, r_8* donnees) const
[839]1877{
1878 int status = 0;
[971]1879 int hdutype;
[839]1880 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
[1209]1881 if( status ) printerror(status,"PutColToFits: le movabs a foire");
[839]1882 fits_get_hdu_type(fptr_, &hdutype, &status);
[867]1883 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
1884 {
1885 cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
[1209]1886 throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
[867]1887 }
[839]1888 int code;
1889 long repeat, width;
1890 fits_get_coltype(fptr_, nocol+1, &code, &repeat,&width, &status);
1891 if( code != TDOUBLE)
1892 {
[1209]1893 cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " to be written= DOUBLE " << endl;
[839]1894 }
[1499]1895 // cout << " 10 elements de colonne " << endl;
1896 // for (int toto=0; toto < 10; toto++) cout << donnees[toto] << endl;
[839]1897 fits_write_col(fptr_,TDOUBLE,nocol+1,1,1,nentries, donnees ,&status);
[1752]1898 if( status ) printerror( status,"erreur ecriture col. double, dans fichier fits" );
[839]1899}
[1218]1900
1901
1902
1903 /*! \fn void SOPHYA::FitsOutFile::PutColToFits(int nocol, int nentries, float* donnees) const
1904
1905same as previous method with float data
1906*/
[1379]1907void FitsOutFile::PutColToFits(int nocol, int nentries, r_4* donnees) const
[839]1908{
1909 int status = 0;
1910 int hdutype;
1911 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
[1209]1912 if( status ) printerror(status,"PutColToFits: le movabs a foire");
[839]1913 fits_get_hdu_type(fptr_, &hdutype, &status);
1914 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
1915 {
1916 cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
[1209]1917 throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
[839]1918 }
1919 if(hdutype == ASCII_TBL && nocol>0)
1920 {
[1209]1921 throw IOExc("FitsFile::PutColToFits, this HDU is an ASCII table, nocol>0 forbidden");
[839]1922 }
1923 int code;
1924 long repeat, width;
1925 fits_get_coltype(fptr_, nocol+1, &code, &repeat,&width, &status);
1926 if( code != TFLOAT)
1927 {
[1209]1928 cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " (FITS code), to be written= FLOAT " << endl;
[839]1929 }
1930 fits_write_col(fptr_,TFLOAT,nocol+1,1,1,nentries, donnees ,&status);
[1752]1931 if( status ) printerror( status,"erreur ecriture col. floats, dans fichier fits" );
[839]1932}
[1218]1933
1934
1935/*! \fn void FitsOutFile::PutColToFits(int nocol, int nentries, int* donnees) const
1936
1937same as previous method with int data
1938*/
[1379]1939void FitsOutFile::PutColToFits(int nocol, int nentries, int_4* donnees) const
[839]1940{
1941 int status = 0;
1942 int hdutype;
1943 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
[1209]1944 if( status ) printerror(status,"PutColToFits: le movabs a foire");
[839]1945 fits_get_hdu_type(fptr_, &hdutype, &status);
1946 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
1947 {
1948 cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
[1209]1949 throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
[839]1950 }
1951 if(hdutype == ASCII_TBL && nocol>0)
1952 {
[1209]1953 throw IOExc("FitsFile::PutColToFits, this HDU is an ASCII table, nocol>0 forbidden");
[839]1954 }
1955 int code;
1956 long repeat, width;
1957 fits_get_coltype(fptr_, nocol+1, &code, &repeat,&width, &status);
[1752]1958
1959
[2197]1960
1961 if (code == TINT || code == TLONG)
[839]1962 {
[2197]1963 // cfitsio n'a que des entiers de longueur inferieure a 32 bits.
1964 // ici, a l'ecriture TLONG impliquerait que le tableau de donnees
1965 // soit un tableau int_8. Donc c'est toujours TINT qu;il faut mettre
1966 // De plus, j'ai l'impression que TINT va devenir obsolete dans cfitsio
1967 // (GLM)
[1752]1968 fits_write_col(fptr_,TINT,nocol+1,1,1,nentries, donnees ,&status);
1969 }
1970 else
1971 {
1972 cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " (FITS code), to be written= integers " << endl;
[839]1973 }
[1752]1974 if( status ) printerror( status,"erreur ecriture col. entiers, dans fichier fits" );
[839]1975}
[1218]1976
1977
1978/*! \fn void SOPHYA::FitsOutFile::PutColToFits(int nocol, int nentries, char** donnees) const
1979same as previous method with char* data
1980*/
[1209]1981void FitsOutFile::PutColToFits(int nocol, int nentries, char** donnees) const
[839]1982{
1983 int status = 0;
1984 int hdutype;
1985 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
[1209]1986 if( status ) printerror(status,"PutColToFits: le movabs a foire");
[839]1987 fits_get_hdu_type(fptr_, &hdutype, &status);
1988 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
1989 {
1990 cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
[1209]1991 throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
[839]1992 }
1993 if(hdutype == ASCII_TBL && nocol>0)
1994 {
[1209]1995 throw IOExc("FitsFile::PutColToFits, this HDU is an ASCII table, nocol>0 forbidden");
[839]1996 }
1997 int code;
1998 long repeat, width;
1999 fits_get_coltype(fptr_, nocol+1, &code, &repeat,&width, &status);
2000 if( code != TSTRING)
2001 {
[1209]2002 cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " (FITS code), to be written= char** " << endl;
[839]2003 }
2004 fits_write_col(fptr_,TSTRING,nocol+1,1,1,nentries, donnees ,&status);
[1752]2005 if( status ) printerror( status,"erreur ecriture col. chars, dans fichier fits" );
[839]2006}
2007
[1209]2008void FitsOutFile::PutBinTabLine(long NoLine, BnTblLine& ligne) const
[1193]2009{
[1209]2010 // on ne fait pas de verification de type, ni de dimension ici, pour
2011 // des raisons de performances
2012 int k;
[1193]2013 int status= 0;
[1978]2014 int anynul;
[1209]2015 int ncol=0;
[1193]2016 long nels=1;
[1209]2017 // int nbcols;
2018 // fits_get_num_cols(fptr_, &nbcols,&status);
2019 for (k=0; k<ligne.ddata_.size(); k++, ncol++)
[1193]2020 {
[1209]2021 fits_write_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1, &ligne.ddata_[k] ,&status);
2022 if( status ) printerror( status, "PutBinTabLine : erreur ecriture double" );
[1193]2023 }
[1209]2024 for (k=0; k<ligne.fdata_.size(); k++, ncol++)
2025 {
2026 fits_write_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1, &ligne.fdata_[k] ,&status);
2027 if( status ) printerror( status, "PutBinTabLine : erreur ecriture float" );
2028 }
2029 for (k=0; k<ligne.idata_.size(); k++, ncol++)
2030 {
2031 fits_write_col(fptr_,TINT,ncol+1,NoLine+1,1,1, &ligne.idata_[k] ,&status);
2032 if( status ) printerror( status, "PutBinTabLine : erreur ecriture entier" );
2033 }
[1359]2034 for (k=0; k<ligne.ldata_.size(); k++, ncol++)
2035 {
2036 fits_write_col(fptr_,TLONG,ncol+1,NoLine+1,1,1, &ligne.ldata_[k] ,&status);
2037 if( status ) printerror( status, "PutBinTabLine : erreur ecriture entier long" );
2038 }
2039 for (k=0; k<ligne.bdata_.size(); k++, ncol++)
2040 {
2041 fits_write_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1, &ligne.bdata_[k] ,&status);
2042 if( status ) printerror( status, "PutBinTabLine : erreur ecriture byte" );
2043 }
[1209]2044
2045 for (k=0; k<ligne.cdata_.size(); k++, ncol++)
2046 {
[1220]2047 fits_write_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1, (void*)ligne.cdata_[k].c_str() ,&status);
[1209]2048 if( status ) printerror( status, "PutBinTabLine : erreur ecriture caracteres" );
2049 }
[1193]2050}
2051
2052
[1218]2053/* \fn void SOPHYA::FitsOutFile::DVListIntoPrimaryHeader(DVList& dvl) const
2054
2055Put keywords from a DVList into the primary header of the fits-file
2056*/
[1246]2057void FitsOutFile::DVListIntoPrimaryHeader(DVList& dvl)
[1143]2058{
2059 int status = 0;
2060 int hdutype;
[1246]2061 if (hdunum_ == 0)
2062 {
2063 if (dvlToPrimary_ == NULL) dvlToPrimary_ = new DVList(dvl);
2064 else dvlToPrimary_->Merge(dvl);
2065 }
2066 else
2067 {
2068 fits_movabs_hdu(fptr_,1,&hdutype,&status);
2069 addKeywordsOfDVList(dvl);
2070 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
2071 }
[1143]2072}
[839]2073
[1143]2074
[1246]2075void FitsOutFile::writeSignatureOnFits(int hdunum) const
[839]2076{
2077 int status = 0;
[1246]2078 int hdutype;
[839]2079 char keyname[LEN_KEYWORD];
2080 char strval[FLEN_VALUE];
2081 char comment[FLEN_COMMENT];
[1246]2082 if (hdunum_ == 0)
2083 {
2084 cerr << " WARNING : can't write keywords on non existing primary header" << endl;
2085 return;
2086 }
2087 fits_movabs_hdu(fptr_,1,&hdutype,&status);
2088 //
[971]2089 strncpy(keyname, "CREATOR", LEN_KEYWORD);
[1418]2090 keyname[7] = '\0';
[971]2091 strcpy(strval, "SOPHYA");
2092 strcpy(comment," SOPHYA Package - FITSIOServer ");
2093 fits_write_key(fptr_, TSTRING, keyname, &strval, comment, &status);
2094 if( status ) printerror( status );
[1143]2095 fits_write_date(fptr_, &status);
[971]2096 fits_write_comment(fptr_,"..............................................", &status);
2097 fits_write_comment(fptr_, " SOPHYA package - FITSIOSever ", &status);
2098 fits_write_comment(fptr_, " (C) LAL/IN2P3-CNRS Orsay, FRANCE 2000", &status);
2099 fits_write_comment(fptr_, " (C) DAPNIA/CEA Saclay, FRANCE 2000", &status);
2100 fits_write_comment(fptr_,"..............................................", &status);
[1045]2101 if( status ) printerror( status, "erreur writeSignatureOnFits" );
[1246]2102 //
2103 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
[839]2104}
2105
[903]2106
[1246]2107void FitsOutFile::addKeywordsOfDVList( DVList& dvl) const
[1143]2108{
2109 int status = 0;
2110 fits_write_comment(fptr_,"---------- keywords from SOPHYA ---------", &status);
2111 DVList::ValList::const_iterator it;
2112 for(it = dvl.Begin(); it != dvl.End(); it++)
2113 {
[1311]2114 MuTyV::MTVType keytype= (*it).second.elval.Type();
[1418]2115 char keyname[LEN_KEYWORD];
2116 strncpy(keyname,(*it).first.substr(0,64).c_str(),LEN_KEYWORD);
2117 int bout = ((*it).first.substr(0,64).length() < LEN_KEYWORD) ? (*it).first.substr(0,64).length() : LEN_KEYWORD-1;
2118 keyname[bout] = '\0';
2119 string key((*it).first.substr(0,64));
2120 // string key(keyname);
[1143]2121 char comment[FLEN_COMMENT];
2122 char strval[FLEN_VALUE]= "";
2123 char *comkey = "COMMENT";
[1353]2124 // fits_read_keyword(fptr_, keyname, strval, NULL, &status);
2125 // if (status != 0 || strncmp(keyname,comkey,LEN_KEYWORD-1) == 0 )
[1143]2126 {
[1183]2127 string coco = dvl.GetComment(key);
2128 coco.copy( comment, FLEN_COMMENT-1);
2129 int bout = (coco.length() < FLEN_COMMENT) ? coco.length() : FLEN_COMMENT-1;
2130 comment[bout]= '\0';
[1143]2131 status = 0;
2132 switch (keytype)
2133 {
[1311]2134 case MuTyV::MTVInteger :
[1143]2135 {
[1183]2136 int ival = (int)dvl.GetI(key);
2137 fits_write_key(fptr_,TINT,keyname,&ival, comment,&status);
[1143]2138 break;
2139 }
[1311]2140 case MuTyV::MTVFloat :
[1143]2141 {
[1183]2142 double dval= (double)dvl.GetD(key);
[1143]2143 fits_write_key(fptr_,TDOUBLE,keyname,&dval,comment,&status);
2144 break;
2145 }
[1311]2146 case MuTyV::MTVString :
[1143]2147 {
[1183]2148 char strvaleur[FLEN_VALUE]= "";
2149 string valChaine = dvl.GetS(key);
2150 valChaine.copy(strvaleur, FLEN_VALUE-1);
2151 int fin = (valChaine.length() < FLEN_VALUE) ? valChaine.length() : FLEN_VALUE-1;
2152 strvaleur[fin]= '\0';
2153
2154 fits_write_key(fptr_,TSTRING,keyname,&strvaleur,comment,&status);
[1143]2155 break;
2156 }
2157 }
2158 }
2159 if( status ) printerror( status,"fitsfile: probleme ecriture mot-cle du dvlist" );
2160 }
2161 fits_write_comment(fptr_,"--------------------------------------", &status);
2162}
[903]2163
2164
[1246]2165void FitsOutFile::addDVListOnPrimary()
2166 {
2167 int status = 0;
2168 int hdutype;
2169 if (hdunum_ == 0)
2170 {
2171 cerr << " WARNING : can't write keywords on non existing primary header" << endl;
2172 return;
2173 }
2174 if (dvlToPrimary_ != NULL)
2175 {
2176 fits_movabs_hdu(fptr_,1,&hdutype,&status);
2177 addKeywordsOfDVList(*dvlToPrimary_);
2178 delete dvlToPrimary_;
2179 dvlToPrimary_ = NULL;
2180 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
2181 }
2182 }
[839]2183
[1353]2184
2185/*! \fn void FitsOutFile::appendInHeader(FitsInFile& infits, int hdunum)
2186
2187get a header from FitsInFile and append to the header beeing built
2188(shifting mandatory keywords)
2189*/
2190
2191void FitsOutFile::appendInputHeader(FitsInFile& infits, int hdunum)
2192{
[1771]2193
2194 infits.GetKeywordsFromHeader(hdunum, mots_cles_);
2195 /*
[1353]2196 int status = 0;
2197 int hdutype;
2198 fitsfile* fptr=infits.fitsfilePtr();
2199 fits_movabs_hdu(fptr,hdunum,&hdutype,&status);
2200 if( status ) fits_report_error(stderr,status);
2201
2202 // get number of keywords
2203 int nkeys,keypos;
2204 fits_get_hdrpos(fptr,&nkeys,&keypos,&status);
2205 if( status ) fits_report_error(stderr,status);
2206 // shift with the number of mandatory keywords
2207 int num= 0;
2208 // if primary header
2209 if (hdunum == 1)
2210 {
2211 // read NAXIS
2212 int naxis=0;
2213 fits_read_key(fptr,TINT,"NAXIS",&naxis,NULL,&status);
2214 // number of mandatory keywords
2215 num = naxis+3;
2216 }
2217 // extensions
2218 else
2219 {
2220 if (hdutype == IMAGE_HDU)
2221 {
2222 // read NAXIS
2223 int naxis=0;
2224 fits_read_key(fptr,TINT,"NAXIS",&naxis,NULL,&status);
2225 // number of mandatory keywords
2226 num = naxis+5;
2227 }
2228 else
2229 if(hdutype == ASCII_TBL || hdutype == BINARY_TBL)
2230 {
2231 // number of mandatory keywords
2232 num = 8;
2233 }
2234 }
2235 int j;
2236 char keyname[LEN_KEYWORD];
2237 char value[FLEN_VALUE];
2238 char comment[FLEN_COMMENT];
2239 for(j = num+1; j <= nkeys; j++)
2240 {
2241 char dtype;
2242 fits_read_keyn(fptr,j,keyname,value,comment,&status);
2243 if(status)
2244 {
2245 fits_report_error(stderr,status);
2246 status=0;
2247 }
2248 string kn(keyname);
2249 string cm(comment);
2250 string val(value);
2251 FitsKeyword kw(kn, val, cm);
2252 mots_cles_.push_back(kw);
2253 }
[1771]2254 */
[1353]2255}
2256void FitsOutFile::writeAppendedHeaderOnFits()
2257{
2258 for (list<FitsKeyword>::iterator it=mots_cles_.begin(); it !=mots_cles_.end(); it++)
2259 {
2260 (*it).writeOnFits(fptr_);
2261 }
2262 mots_cles_.clear();
2263}
2264
2265void FitsOutFile::insertKeywordOnHeader(string keyname, double value, string comment)
2266{
[1418]2267 char cvalue[16];
[1353]2268 sprintf(cvalue,"%e",value);
[1418]2269 FitsKeyword kw(keyname, string(cvalue), comment, 'F');
[1353]2270 mots_cles_.push_back(kw);
2271}
[1418]2272void FitsOutFile::insertKeywordOnHeader(string keyname, int value, string comment)
2273{
2274 char cvalue[16];
2275 sprintf(cvalue,"%d",value);
2276 FitsKeyword kw(keyname, string(cvalue), comment, 'I');
2277 mots_cles_.push_back(kw);
2278}
2279void FitsOutFile::insertKeywordOnHeader(string keyname, string value, string comment)
2280{
2281 FitsKeyword kw(keyname, value , comment, 'C');
2282 mots_cles_.push_back(kw);
2283}
[1353]2284
2285void FitsOutFile::insertCommentLineOnHeader(string comment)
2286{
2287 FitsKeyword kw(comment);
2288 mots_cles_.push_back(kw);
2289}
2290
2291void FitsOutFile::PrintHeaderToBeAppended()
2292{
2293 cout << " contenu du header en cours de fabrication " << endl;
2294 for (list<FitsKeyword>::iterator it=mots_cles_.begin(); it !=mots_cles_.end(); it++)
2295 {
2296 (*it).Print();
2297 }
2298}
2299
2300
2301FitsKeyword::FitsKeyword()
2302 {
2303 datatype_=' ';
2304 keyname_ = string("");
2305 dvalue_=0.;
2306 ivalue_=1;
2307 svalue_=string("");
2308 comment_=string("");
2309 }
2310
2311FitsKeyword::FitsKeyword(string comment)
2312 {
2313 datatype_=' ';
2314 keyname_=string("COMMENT");
2315 comment_=comment;
[1418]2316 }
[1353]2317
2318FitsKeyword::FitsKeyword(string keyname, string value, string comment) : keyname_(keyname), comment_(comment)
2319 {
2320 int status=0;
2321 char dtype;
2322 const char* val= value.c_str();
2323 char* valk = const_cast<char*>(val);
2324 fits_get_keytype(valk,&dtype,&status);
2325 if(status)
2326 {
2327 status=0;
[1354]2328 if (status == VALUE_UNDEFINED) cout << "WARNING (FitsKeyword) : undefined keyword value " << endl;
[1353]2329 datatype_=' ';
2330 }
2331 else datatype_=dtype;
2332
2333 switch( datatype_ )
2334 {
2335 case 'C':
2336 {
[1354]2337 strip(valk, 'B','\'');
2338 svalue_ = string(valk);
[1353]2339 break;
2340 }
2341 case 'I':
2342 {
2343 ivalue_ = atoi(val);
2344 break;
2345 }
2346 case 'L':
2347 {
[1354]2348 bool bb = value.c_str();
2349 ivalue_ = (int)bb;
[1353]2350 break;
2351 }
2352 case 'F':
2353 {
2354 dvalue_ = atof(val);
2355 break;
2356 }
2357 case 'X':
2358 {
2359 throw IOExc("FitsKeyword , complex keyword value not supported");
2360 }
2361 }
2362 }
2363
[1418]2364// constructeur pour les mots-cles maison (ne prvenant pas de la lecture d'un fichier fits)
2365FitsKeyword::FitsKeyword(string keyname, string value, string comment, char type) : keyname_(keyname), comment_(comment), datatype_(type)
2366 {
2367 char dtype;
2368 const char* val= value.c_str();
2369 char* valk = const_cast<char*>(val);
2370 switch( datatype_ )
2371 {
2372 case 'C':
2373 {
2374 strip(valk, 'B','\'');
2375 svalue_ = string(valk);
2376 break;
2377 }
2378 case 'I':
2379 {
2380 ivalue_ = atoi(val);
2381 break;
2382 }
2383 case 'L':
2384 {
2385 bool bb = value.c_str();
2386 ivalue_ = (int)bb;
2387 break;
2388 }
2389 case 'F':
2390 {
2391 dvalue_ = atof(val);
2392 break;
2393 }
2394 case 'X':
2395 {
2396 throw IOExc("FitsKeyword , complex keyword value not supported");
2397 }
2398 }
2399 }
2400
[1353]2401void FitsKeyword::writeOnFits(fitsfile* ptr)
2402 {
2403 int status=0;
[1418]2404 char keyname[LEN_KEYWORD];
2405 char comment[FLEN_COMMENT];
2406 keyname_.copy(keyname, LEN_KEYWORD);
2407 int bout = (keyname_.length() < LEN_KEYWORD) ? keyname_.length() : LEN_KEYWORD-1;
2408 keyname[bout] = '\0';
2409 comment_.copy( comment, FLEN_COMMENT);
2410 bout = (comment_.length() < FLEN_COMMENT) ? comment_.length() : FLEN_COMMENT-1;
2411 comment[bout]= '\0';
2412
[1353]2413 int nkeys,keypos;
2414 fits_get_hdrpos(ptr,&nkeys,&keypos,&status);
2415 switch( datatype_ )
2416 {
2417 case 'C':
2418 {
[1418]2419 char value[FLEN_VALUE]="";
2420 svalue_.copy(value, FLEN_VALUE-1);
2421 int fin = (svalue_.length() < FLEN_VALUE) ? svalue_.length() : FLEN_VALUE-1;
2422 value[fin]= '\0';
[1353]2423 fits_write_key(ptr,TSTRING,keyname,&value, comment,&status);
2424 fits_report_error(stderr,status);
2425 break;
2426 }
2427 case 'I':
2428 {
2429 fits_write_key(ptr,TINT,keyname,&ivalue_, comment,&status);
2430 fits_report_error(stderr,status);
2431 break;
2432 }
2433 case 'L':
2434 {
2435 fits_write_key(ptr,TLOGICAL,keyname,&ivalue_, comment,&status);
2436 fits_report_error(stderr,status);
2437 break;
2438 }
2439 case 'F':
2440 {
2441 fits_write_key(ptr,TDOUBLE,keyname,&dvalue_, comment,&status);
2442 fits_report_error(stderr,status);
2443 break;
2444 }
2445 case 'X':
2446 {
2447 cout << "FitsKeyword : complex keyword value not supported" << endl;;
[2197]2448 break;
[1353]2449 }
2450 default :
2451 {
2452 char *comkey = "COMMENT";
2453 if(strncmp(keyname,comkey,LEN_KEYWORD-1) == 0)
2454 {
2455 fits_write_comment(ptr,comment,&status);
2456 fits_report_error(stderr,status);
2457 }
2458 else
2459 {
2460 cout << " WARNING (FitsKeyword::writeOnFits) : unrecognized keyword : " << keyname_ << endl;
2461 }
2462 }
2463 }
2464 }
2465
2466void FitsKeyword::Print()
2467 {
2468 switch( datatype_ )
2469 {
2470 case 'C':
2471 {
2472 cout << " mot cle : " << keyname_ << " valeur : " << svalue_ << " commentaire : " << comment_ <<endl;
2473 break;
2474 }
2475 case 'I':
2476 {
2477 cout << " mot cle : " << keyname_ << " valeur : " << ivalue_ << " commentaire : " << comment_ <<endl;
2478 break;
2479 }
2480 case 'L':
2481 {
2482 cout << " mot cle : " << keyname_ << " valeur : " << ivalue_ << " commentaire : " << comment_ <<endl;
2483 break;
2484 }
2485 case 'F':
2486 {
2487 cout << " mot cle : " << keyname_ << " valeur : " << dvalue_ << " commentaire : " << comment_ <<endl;
2488 break;
2489 }
2490 case 'X':
2491 {
2492 cout << "FitsKeyword : complex keyword value not supported" << endl;;
2493 }
2494 default :
2495 {
2496 cout << " mot cle : " << keyname_ << " commentaire : " << comment_ <<endl;
2497 }
2498 }
2499 }
Note: See TracBrowser for help on using the repository browser.