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

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

1er essai - ca compile ...

File size: 2.7 KB
RevLine 
[2351]1// Eric Aubourg
2// Christophe Magneville
3// Reza Ansari
4// $Id: fitsringrdr.cc,v 1.1 2003-03-24 10:59:45 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 name = "rdr";
18 fptr = NULL;
19}
20
21FITSRingReader::~FITSRingReader() {
22}
23
24
25void FITSRingReader::openFile(string fn) {
26 fits_lock();
27 if (fptr) {
28 fits_close_file(fptr,&fstatus);
29 fptr = NULL;
30 }
31 fname = fn;
32 cout << "FITSRingReader::open FileName=" << fname << endl;
33 fstatus = 0;
34 // Open file
35 fits_open_file(&fptr,fname.c_str(),READONLY,&fstatus);
36 if (fstatus != 0) {
37 fits_report_error(stderr, fstatus);
38 fits_unlock();
39 throw IOExc("FITSRingReader::openFile() fitsio error");
40 }
41
42 // Go to first extension, which should be a BINTABLE
43
44 int simple, bitpix, naxis;
45 long naxes;
46 long pcount, gcount;
47 int extend;
48 fits_read_imghdr(fptr, 1, &simple, &bitpix,
49 &naxis, &naxes, &pcount, &gcount, &extend, &fstatus);
50
51 fits_movabs_hdu(fptr, 2, NULL, &fstatus);
52
53 fits_get_num_cols(fptr,&nSamples,&fstatus);
54
55 cout << "FITSRingReader nSamples = " << nSamples << endl;
56
57 fits_unlock();
58}
59
60void FITSRingReader::init() {
61
62 declareOutput("CircTheta");
63 declareOutput("CircPhi");
64 declareOutput("signal");
65
66}
67void FITSRingReader::run() {
68
69 fits_lock();
70
71 fits_read_key(fptr, TLONG, "NCIRCLES", &nRings, "Number of rings", &fstatus);
72 fits_unlock();
73
74 char xname[100],buf[100];
75 double theta,phi;
76 int anyNul;
77
78 for (int ring = 0; ring<nRings; ring++) {
79 sprintf(xname, "CRing_%d", ring);
80
81
82 fits_lock();
83 fits_movabs_hdu(fptr, ring+2, NULL, &fstatus);
84 strcpy(buf, "RINGDATA");
85 fits_read_key(fptr, TSTRING, "PDMTYPE", &buf, "Planck Data Model Type", &fstatus);
86 fits_read_key(fptr, TDOUBLE, "CIRTHETA", &theta, "Theta angle in radians", &fstatus);
87 fits_read_key(fptr, TDOUBLE, "CIRPHI", &phi, "Phi angle in radians", &fstatus);
88 fits_read_key(fptr, TDOUBLE, "CIRAPER", &aperture, "Aperture angle in radians", &fstatus);
89 fits_read_key(fptr, TLONG, "NSAMPLES", &nSamples, "Number of samples on the circle", &fstatus);
90 fits_unlock();
91
92 for (int i=0; i<nSamples; i++) {
93 double data;
94 fits_lock();
95 fits_read_col_dbl(fptr,1,i+1,1,1,0,&data,&anyNul,&fstatus);
96 putData(0, ring*nSamples+i,theta);
97 putData(1, ring*nSamples+i,phi);
98 putData(2, ring*nSamples+i,data);
99 fits_unlock();
100 }
101 }
102
103 fits_lock();
104 if (fptr) {
105 fits_close_file(fptr,&fstatus);
106 fptr = NULL;
107 }
108 fits_unlock();
109}
Note: See TracBrowser for help on using the repository browser.