source: Sophya/trunk/SophyaExt/FitsIOServer/datacirclefits.cc@ 2233

Last change on this file since 2233 was 1824, checked in by ansari, 24 years ago

Suite modifs datacirclefits ... par Touze Reza 19/12/2001

File size: 3.5 KB
RevLine 
[1770]1#include <iostream.h>
2#include "datacirclefits.h"
3
4/*
5 Class used to recover the circles and measures involved in a mission. The parameters needful to create a circle and the number of samples on this circle are read from a FITS data array. In addition, a function returns the measurement at a given angular position psi on the circle.
6*/
7
8DataCircleFits::DataCircleFits() :
9 _fptr(NULL)
10, _NMeasurements(0)
11, _ICircle(0)
12, _mesures(NULL)
[1815]13, _stored_data(false)
[1770]14{;}
15
[1815]16DataCircleFits::DataCircleFits(fitsfile *is,int hdunum,bool sdata) :
[1770]17 _fptr(NULL)
18, _NMeasurements(0)
19, _ICircle(hdunum)
20, _mesures(NULL)
[1815]21, _stored_data(sdata)
[1770]22{
23
24 // pointer to the FITS file
[1815]25 _fptr= is;
26 int status = 0;
[1770]27
28 // move to the HDU containing a circle
[1815]29 fits_movabs_hdu(_fptr,hdunum,NULL,&status);
[1770]30
31 // angles of the circle
[1815]32 double theta;
33 fits_read_key(_fptr,TDOUBLE,"CIRTHETA",&theta,NULL,&status);
[1770]34
[1815]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);
40
[1770]41 UnitVector temp(theta,phi);
42 SetCircle(temp,aperture);
43
[1815]44 fits_read_key(_fptr,TINT,"NSAMPLES",&_NMeasurements,NULL,&status);
[1770]45
[1815]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];
[1770]54 int i;
55 for(i = 0; i < _NMeasurements; i++) {
[1815]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);
[1770]68 }
[1815]69 }
[1770]70}
[1815]71
[1770]72DataCircleFits::~DataCircleFits() {
73
74 if(_mesures != NULL) delete [] _mesures;
75}
76
77int DataCircleFits::NMeasurements() const {
78
79 return _NMeasurements;
80}
81
82double DataCircleFits::getData(double psi) const {
83
84 double dtab;
[1816]85 int ibin= l_ft_nint(psi*_NMeasurements/(2.*M_PI));
[1815]86 //cout << " ibin= " << ibin << ", " << psi << endl;
[1770]87
88 if(_stored_data) {
89 dtab= _mesures[ibin];
90 } else {
[1815]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);
[1770]111 }
112 //cout << "DataCircleFits:: bin= " << ibin << ", " << dtab << endl;
113 return dtab;
114}
115
116void DataCircleFits::print(ostream& out) const {
117
118 out << " Circle:: ApertureAngle= " << ApertureAngle() << ", Theta= "
119 << Theta() << ", Phi= " << Phi() << ", NSamples= "
120 << NMeasurements() << endl;
121}
[1815]122
123double 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 }
[1816]130 int ibin= l_ft_nint(psi*_NMeasurements/(2.*M_PI));
[1815]131 return _mesures[ibin];
132}
133
[1824]134double DataCircleFits::getTOffset() const {
135
[1815]136 int status= 0;
137 fits_movabs_hdu(_fptr,_ICircle,NULL,&status);
138
139 double omes= 0.0;
140 fits_read_key_dbl(_fptr,"OFFSET",&omes,NULL,&status);
141 return omes;
142}
Note: See TracBrowser for help on using the repository browser.