Changeset 1815 in Sophya for trunk/SophyaExt/FitsIOServer
- Timestamp:
- Dec 14, 2001, 7:36:25 PM (24 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/datacirclefits.cc
r1770 r1815 11 11 , _ICircle(0) 12 12 , _mesures(NULL) 13 , _stored_data(false)13 , _stored_data(false) 14 14 {;} 15 15 16 DataCircleFits::DataCircleFits( FitsInFile&is,int hdunum,bool sdata) :16 DataCircleFits::DataCircleFits(fitsfile *is,int hdunum,bool sdata) : 17 17 _fptr(NULL) 18 18 , _NMeasurements(0) 19 19 , _ICircle(hdunum) 20 20 , _mesures(NULL) 21 , _stored_data(sdata)21 , _stored_data(sdata) 22 22 { 23 23 24 24 // pointer to the FITS file 25 _fptr= &is; 25 _fptr= is; 26 int status = 0; 26 27 27 28 // move to the HDU containing a circle 28 _fptr->ReadHeader(hdunum); 29 30 // reference on a DVList containing the keywords 31 DVList dvl= _fptr->DVListFromFits(); 29 fits_movabs_hdu(_fptr,hdunum,NULL,&status); 32 30 33 31 // angles of the circle 34 double theta= dvl.GetD("CIRTHETA"); 35 double phi = dvl.GetD("CIRPHI"); 36 double aperture= dvl.GetD("CIRAPER"); 32 double theta; 33 fits_read_key(_fptr,TDOUBLE,"CIRTHETA",&theta,NULL,&status); 34 35 double phi; 36 fits_read_key(_fptr,TDOUBLE,"CIRPHI",&phi,NULL,&status); 37 38 double aperture; 39 fits_read_key(_fptr,TDOUBLE,"CIRAPER",&aperture,NULL,&status); 37 40 38 41 UnitVector temp(theta,phi); 39 42 SetCircle(temp,aperture); 40 43 41 _NMeasurements= dvl.GetI("NSAMPLES");44 fits_read_key(_fptr,TINT,"NSAMPLES",&_NMeasurements,NULL,&status); 42 45 43 if(_stored_data) { 44 _mesures= new double[_NMeasurements]; 46 if(_stored_data) { 47 // vector repeat value for the column (there is only 1 column) 48 long repeat; 49 fits_get_coltype(_fptr,1,NULL,&repeat,NULL,&status); 50 51 double dnull= 0.; 52 int anull; 53 _mesures= new double[_NMeasurements]; 45 54 int i; 46 55 for(i = 0; i < _NMeasurements; i++) { 47 _fptr->GetBinTabLine(i,&_mesures[i],NULL,NULL,NULL); 56 // row index: range 1 to NAXIS2 57 int index= i+1; 58 59 // starting line index 60 int stline= index/repeat; 61 int stelem= index-stline*repeat; 62 if(stelem != 0) { 63 stline++; 64 } else { 65 stelem= repeat; 66 } 67 fits_read_col(_fptr,TDOUBLE,1,stline,stelem,1,&dnull,&_mesures[i],&anull,&status); 48 68 } 49 }69 } 50 70 } 51 71 52 72 DataCircleFits::~DataCircleFits() { 53 73 … … 63 83 64 84 double dtab; 65 int ibin= (int)floor(psi*_NMeasurements/2./M_PI); 85 int ibin= nint(psi*_NMeasurements/(2.*M_PI)); 86 //cout << " ibin= " << ibin << ", " << psi << endl; 66 87 67 88 if(_stored_data) { 68 89 dtab= _mesures[ibin]; 69 90 } else { 70 _fptr->ReadHeader(_ICircle); 71 _fptr->GetBinTabLine(ibin,&dtab,NULL,NULL,NULL); 91 int status= 0; 92 fits_movabs_hdu(_fptr,_ICircle,NULL,&status); 93 94 // vector repeat value for the column (there is only 1 column) 95 long repeat; 96 fits_get_coltype(_fptr,1,NULL,&repeat,NULL,&status); 97 98 double dnull= 0.; 99 int anull; 100 101 int index= ibin+1; 102 // starting line index 103 int stline= index/repeat; 104 int stelem= index-stline*repeat; 105 if(stelem != 0) { 106 stline++; 107 } else { 108 stelem= repeat; 109 } 110 fits_read_col(_fptr,TDOUBLE,1,stline,stelem,1,&dnull,&dtab,&anull,&status); 72 111 } 73 112 //cout << "DataCircleFits:: bin= " << ibin << ", " << dtab << endl; … … 81 120 << NMeasurements() << endl; 82 121 } 122 123 double DataCircleFits::getTMeasure(double psi) const { 124 125 if(_mesures == NULL) { 126 cout << " DataCircleFits::getTMeasure data must be stored" 127 << " in an array... verify the option" << endl; 128 exit(0); 129 } 130 int ibin= nint(psi*_NMeasurements/(2.*M_PI)); 131 return _mesures[ibin]; 132 } 133 double DataCircleFits::getTOffset() { 134 135 int status= 0; 136 fits_movabs_hdu(_fptr,_ICircle,NULL,&status); 137 138 double omes= 0.0; 139 fits_read_key_dbl(_fptr,"OFFSET",&omes,NULL,&status); 140 return omes; 141 } -
trunk/SophyaExt/FitsIOServer/datacirclefits.h
r1770 r1815 3 3 4 4 #include "datacirclebase.h" 5 #include " fitsfile.h"5 #include "FitsIO/fitsio.h" 6 6 7 7 class DataCircleFits : public DataCircleBase { … … 10 10 11 11 DataCircleFits(); 12 DataCircleFits( FitsInFile&,int,bool);12 DataCircleFits(fitsfile*,int,bool); 13 13 virtual ~DataCircleFits(); 14 14 … … 17 17 virtual void print(ostream&) const; 18 18 19 double getTMeasure(double) const; 20 double getTOffset(); 21 19 22 private: 20 23 21 FitsInFile* _fptr;24 fitsfile* _fptr; 22 25 int _ICircle; 23 26 int _NMeasurements;
Note:
See TracChangeset
for help on using the changeset viewer.