source: Sophya/trunk/ArchTOIPipe/Kernel/fitsringrdr.cc@ 2354

Last change on this file since 2354 was 2353, checked in by cecile, 23 years ago

* empty log message *

File size: 4.2 KB
Line 
1// Eric Aubourg
2// Christophe Magneville
3// Reza Ansari
4// $Id: fitsringrdr.cc,v 1.2 2003-03-26 09:18:44 cecile Exp $
5
6#include "fitsringrdr.h"
7#include "toimanager.h"
8#include <sched.h>
9
10extern void fits_lock();
11extern void fits_unlock();
12
13FITSRingReader::FITSRingReader(string fn,int buff_sz) {
14 fname = fn;
15 allfn.push_back(fn);
16 cout<<"FITSRingReader::FITSRingReader"<<endl;
17 cout<<"FITSTOIReader::inited "<<inited<<" bsz="<<Buff_Sz<<endl;
18 name = "rdr";
19 fptr = NULL;
20 totnscount = 0;
21}
22
23FITSRingReader::~FITSRingReader() {
24}
25
26
27void FITSRingReader::setBufferSize(int buffsz)
28{
29 Buff_Sz = (buffsz>0) ? buffsz: 1024;
30 return;
31}
32
33void FITSRingReader::openFile(string fn) {
34 cout << "(((((((((((((((((((((((((((((((((((((((((((" << endl;
35
36 fits_lock();
37 if (fptr) {
38 fits_close_file(fptr,&fstatus);
39 fptr = NULL;
40 }
41 fname = fn;
42 cout << "FITSRingReader::open FileName=" << fname << endl;
43 fstatus = 0;
44 // Open file
45 fits_open_file(&fptr,fname.c_str(),READONLY,&fstatus);
46 if (fstatus != 0) {
47 fits_report_error(stderr, fstatus);
48 fits_unlock();
49 throw IOExc("FITSRingReader::openFile() fitsio error");
50 }
51
52 // Go to first extension, which should be a BINTABLE
53
54 int simple, bitpix, naxis;
55 long naxes;
56 long pcount, gcount;
57 int extend;
58 fits_read_imghdr(fptr, 1, &simple, &bitpix,
59 &naxis, &naxes, &pcount, &gcount, &extend, &fstatus);
60
61 fits_movabs_hdu(fptr, 2, NULL, &fstatus);
62
63 fits_get_num_cols(fptr,&nSamples,&fstatus);
64
65 cout << "FITSRingReader nSamples = " << nSamples << endl;
66
67 fits_unlock();
68}
69
70void FITSRingReader::init() {
71
72 declareOutput("CircTheta");
73 declareOutput("CircPhi");
74 declareOutput("signal");
75
76}
77
78int FITSRingReader::calcMinOut() {
79 chkinit();
80 TOIManager* mgr = TOIManager::getManager();
81 int firstReq = mgr->getRequestedBegin();
82 return snBegin > firstReq ? snBegin : firstReq;
83}
84
85int FITSRingReader::calcMaxOut() {
86 chkinit();
87 TOIManager* mgr = TOIManager::getManager();
88 int lastReq = mgr->getRequestedEnd();
89 return snEnd < lastReq ? snEnd : lastReq;
90}
91
92
93// ajout vf 31/07/2002
94bool FITSRingReader::checkSampleLimits(long& min, long& max, int pass)
95{
96 bool sample_ok=true;
97 chkinit();
98 return TOIProcessor::checkSampleLimits(min, max, pass);
99}
100
101void FITSRingReader::calcSampleLimits(long& min, long& max)
102{
103 chkinit();
104 cout << "calc " << name << " in " << min << " - " << max << " ; " << snBegin << " - " << snEnd << endl;
105
106 min=min<snMin?snMin:min;
107 max=max>snMax?snMax:max;
108 snBegin=snMin;
109 snEnd=snMax;
110 cout << "calc " << name << " out " << min << " - " << max << " ; " << snBegin << " - " << snEnd << endl;
111 //cout << "fitstoirdr : limites temporaires calculees : " << snBegin << " , " << snEnd << endl;
112
113}
114// fin ajout vf
115
116
117
118void FITSRingReader::run() {
119
120 fits_lock();
121
122 fits_read_key(fptr, TLONG, "NCIRCLES", &nRings, "Number of rings", &fstatus);
123 fits_unlock();
124
125 char xname[100],buf[100];
126 double theta,phi;
127 int anyNul;
128
129 for (int ring = 0; ring<nRings; ring++) {
130 sprintf(xname, "CRing_%d", ring);
131
132
133 fits_lock();
134 fits_movabs_hdu(fptr, ring+2, NULL, &fstatus);
135 strcpy(buf, "RINGDATA");
136 fits_read_key(fptr, TSTRING, "PDMTYPE", &buf, "Planck Data Model Type", &fstatus);
137 fits_read_key(fptr, TDOUBLE, "CIRTHETA", &theta, "Theta angle in radians", &fstatus);
138 fits_read_key(fptr, TDOUBLE, "CIRPHI", &phi, "Phi angle in radians", &fstatus);
139 fits_read_key(fptr, TDOUBLE, "CIRAPER", &aperture, "Aperture angle in radians", &fstatus);
140 fits_read_key(fptr, TLONG, "NSAMPLES", &nSamples, "Number of samples on the circle", &fstatus);
141 fits_unlock();
142
143 for (int i=0; i<nSamples; i++) {
144 double data;
145 fits_lock();
146 fits_read_col_dbl(fptr,1,i+1,1,1,0,&data,&anyNul,&fstatus);
147 putData(0, ring*nSamples+i,theta);
148 putData(1, ring*nSamples+i,phi);
149 putData(2, ring*nSamples+i,data);
150 fits_unlock();
151 }
152 }
153
154 fits_lock();
155 if (fptr) {
156 fits_close_file(fptr,&fstatus);
157 fptr = NULL;
158 }
159 fits_unlock();
160}
161
162
163// affichage des limites
164void FITSRingReader::printLimits()
165{
166 cout << "fitsringrdr " << name <<" : limites calculees : " << snBegin << " , " << snEnd << endl;
167}
168
Note: See TracBrowser for help on using the repository browser.