1 | // Test des classes FitsBoloRead
|
---|
2 | /*
|
---|
3 | set DIR = $PLANCK/Kiruna_2001_01_29/TOI/Full_sampling
|
---|
4 | ln -sf $DIR/PointingABv8/gLatLonAB_143k05_104000000_108465000.fits pointing.fits
|
---|
5 | ln -sf $DIR/Bolo_etc/b143k05_104000000_108465000.fits bolo.fits
|
---|
6 | cmvboloread -L 1000,1 -m 100000 \
|
---|
7 | -a gLonBolo_27 -d gLatBolo_27 -b boloMuV_27 -s sampleNum \
|
---|
8 | -A pointing.fits -1 0 -B bolo.fits -3 0
|
---|
9 | */
|
---|
10 | #include "machdefs.h"
|
---|
11 | #include <typeinfo>
|
---|
12 | #include <stdio.h>
|
---|
13 | #include <stdlib.h>
|
---|
14 | #include <iostream.h>
|
---|
15 | #include <values.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include <string>
|
---|
18 | #include <unistd.h>
|
---|
19 | #include "sophyainit.h"
|
---|
20 | #include "pexceptions.h"
|
---|
21 | #include "fboloread.h"
|
---|
22 | #include "fabtwriter.h"
|
---|
23 |
|
---|
24 | //#define NO_VECTOR
|
---|
25 | #define USE_EXCEPT
|
---|
26 |
|
---|
27 | int main(int narg,char *arg[])
|
---|
28 | {
|
---|
29 | SophyaInit();
|
---|
30 | char *label_alpha = "", *label_delta = "",
|
---|
31 | *label_bolo = "", *label_flag = "",
|
---|
32 | *label_snum = "";
|
---|
33 | char *fits_alpha = "", *fits_delta = "",
|
---|
34 | *fits_bolo = "", *fits_flag = "",
|
---|
35 | *fits_snum = "";
|
---|
36 | int hdu_alpha=0, hdu_delta=0, hdu_bolo=0, hdu_flag=0, hdu_snum=0;
|
---|
37 | long blen = 100, bsens = 1, lpmod=1;
|
---|
38 | char c;
|
---|
39 | while((c = getopt(narg,arg,"ha:d:s:b:f:A:D:S:B:F:1:2:3:4:5:L:m:")) != -1) {
|
---|
40 | switch (c) {
|
---|
41 | case 'a' :
|
---|
42 | label_alpha = optarg;
|
---|
43 | break;
|
---|
44 | case 'd' :
|
---|
45 | label_delta = optarg;
|
---|
46 | break;
|
---|
47 | case 'b' :
|
---|
48 | label_bolo = optarg;
|
---|
49 | break;
|
---|
50 | case 'f' :
|
---|
51 | label_flag = optarg;
|
---|
52 | break;
|
---|
53 | case 's' :
|
---|
54 | label_snum = optarg;
|
---|
55 | break;
|
---|
56 | case 'A' :
|
---|
57 | fits_alpha = optarg;
|
---|
58 | break;
|
---|
59 | case 'D' :
|
---|
60 | fits_delta = optarg;
|
---|
61 | break;
|
---|
62 | case 'B' :
|
---|
63 | fits_bolo = optarg;
|
---|
64 | break;
|
---|
65 | case 'F' :
|
---|
66 | fits_flag = optarg;
|
---|
67 | break;
|
---|
68 | case 'S' :
|
---|
69 | fits_snum = optarg;
|
---|
70 | break;
|
---|
71 | case '1' :
|
---|
72 | sscanf(optarg,"%d",&hdu_alpha);
|
---|
73 | break;
|
---|
74 | case '2' :
|
---|
75 | sscanf(optarg,"%d",&hdu_delta);
|
---|
76 | break;
|
---|
77 | case '3' :
|
---|
78 | sscanf(optarg,"%d",&hdu_bolo);
|
---|
79 | break;
|
---|
80 | case '4' :
|
---|
81 | sscanf(optarg,"%d",&hdu_flag);
|
---|
82 | break;
|
---|
83 | case '5' :
|
---|
84 | sscanf(optarg,"%d",&hdu_snum);
|
---|
85 | break;
|
---|
86 | case 'L' :
|
---|
87 | sscanf(optarg,"%ld,%ld",&blen,&bsens);
|
---|
88 | break;
|
---|
89 | case 'm' :
|
---|
90 | sscanf(optarg,"%ld",&lpmod);
|
---|
91 | if(lpmod<=0) lpmod = 1;
|
---|
92 | break;
|
---|
93 | case 'h' :
|
---|
94 | default :
|
---|
95 | cout<<"cmvcolread -L buflen,sens -m print_modulo"
|
---|
96 | <<"\n -a label_alpha -d label_delta"
|
---|
97 | <<"\n -b label_bolo -f label_flag"
|
---|
98 | <<"\n -s label_snum"
|
---|
99 | <<"\n -A fits_alpha -D fits_delta"
|
---|
100 | <<"\n -B fits_bolo -F fits_flag"
|
---|
101 | <<"\n -S fits_snum"
|
---|
102 | <<"\n -1 hdu_alpha -2 hdu_delta"
|
---|
103 | <<"\n -3 hdu_bolo -4 hdu_flag"
|
---|
104 | <<"\n -5 hdu_snum"
|
---|
105 | <<endl;
|
---|
106 | return -1;
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | cout<<"alpha: "<<label_alpha<<" ("<<fits_alpha<<") hdu="<<hdu_alpha<<endl;
|
---|
111 | cout<<"delta: "<<label_delta<<" ("<<fits_delta<<") hdu="<<hdu_delta<<endl;
|
---|
112 | cout<<"bolo : "<<label_bolo <<" ("<<fits_bolo<<") hdu="<<hdu_bolo<<endl;
|
---|
113 | cout<<"flag : "<<label_flag <<" ("<<fits_flag<<") hdu="<<hdu_flag<<endl;
|
---|
114 | cout<<"snum : "<<label_snum <<" ("<<fits_snum<<") hdu="<<hdu_snum<<endl;
|
---|
115 |
|
---|
116 | #ifdef USE_EXCEPT
|
---|
117 | try {
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | FitsBoloRead fbr(blen,bsens);
|
---|
121 | fbr.SetDebug(3);
|
---|
122 | fbr.Print(3);
|
---|
123 |
|
---|
124 | if(strlen(label_bolo)>0)
|
---|
125 | fbr.SetBolo(label_bolo,fits_bolo,hdu_bolo);
|
---|
126 | if(strlen(label_flag)>0)
|
---|
127 | fbr.SetFlag(label_flag,fits_flag,hdu_flag);
|
---|
128 | if(strlen(label_snum)>0)
|
---|
129 | fbr.SetSNum(label_snum,fits_snum,hdu_snum);
|
---|
130 | if(strlen(label_alpha)>0)
|
---|
131 | fbr.SetAlpha(label_alpha,fits_alpha,hdu_alpha);
|
---|
132 | if(strlen(label_delta)>0)
|
---|
133 | fbr.SetDelta(label_delta,fits_delta,hdu_delta);
|
---|
134 | int col1=-1;
|
---|
135 | if(strlen(label_snum)>0 && strlen(fits_alpha)>0)
|
---|
136 | col1 = fbr.AddCol(label_snum,fits_alpha,hdu_alpha);
|
---|
137 |
|
---|
138 | fbr.Print(3);
|
---|
139 | cout<<"NRows= "<<fbr.GetNbLine()<<endl;
|
---|
140 | if(fbr.IsSNum()) fbr.SetNbLine(FitsBoloRead::ColSNum);
|
---|
141 | cout<<"fbr.SetNbLine(ColSNum): NRows= "<<fbr.GetNbLine()<<endl;
|
---|
142 | fbr.SetNbLine(-1);
|
---|
143 | cout<<"fbr.SetNbLine(): NRows= "<<fbr.GetNbLine()<<endl;
|
---|
144 |
|
---|
145 | #ifdef NO_VECTOR
|
---|
146 | cout<<"Reading element by elements"<<endl;
|
---|
147 | for(long i=0; i<fbr.GetNbLine(); i++) {
|
---|
148 | double a=-1.,d=-1.,b=-1.,f=-1.,s=-1.,c1=-1.;
|
---|
149 | if(fbr.IsAlpha()) a = fbr.GetAlpha(i);
|
---|
150 | if(fbr.IsDelta()) d = fbr.GetDelta(i);
|
---|
151 | if(fbr.IsBolo()) b = fbr.GetBolo(i);
|
---|
152 | if(fbr.IsSNum()) s = fbr.GetSNum(i);
|
---|
153 | if(fbr.IsFlag()) f = fbr.GetFlag(i);
|
---|
154 | if(col1>=0) if(fbr.IsCol(col1)) c1 = fbr.GetCol(col1,i);
|
---|
155 | if(i%lpmod==0)
|
---|
156 | cout<<i<<" s="<<(long long)s
|
---|
157 | <<" b="<<b<<" f="<<f
|
---|
158 | <<" a="<<a<<" d="<<d<<" c1="<<(long long)c1<<endl;
|
---|
159 | }
|
---|
160 | #else
|
---|
161 | cout<<"Reading with vectors"<<endl;
|
---|
162 | long istep = lpmod;
|
---|
163 | TVector<double> s,a,d,b,f,c1;
|
---|
164 | TVector<int_4> si4,fi4;
|
---|
165 | for(long i=0; i<fbr.GetNbLine(); i+=istep) {
|
---|
166 | long i2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1;
|
---|
167 | if(fbr.IsSNum()) {fbr.GetSNum(i,i2,s); fbr.GetSNum(i,i2,si4);}
|
---|
168 | if(fbr.IsBolo()) fbr.GetBolo(i,i2,b);
|
---|
169 | if(fbr.IsFlag()) {fbr.GetFlag(i,i2,f); fbr.GetFlag(i,i2,fi4);}
|
---|
170 | if(fbr.IsAlpha()) fbr.GetAlpha(i,i2,a);
|
---|
171 | if(fbr.IsDelta()) fbr.GetDelta(i,i2,d);
|
---|
172 | if(col1>=0) if(fbr.IsCol(col1)) fbr.GetCol(col1,i,i2,c1);
|
---|
173 | for(int j=0; j<2; j++) {
|
---|
174 | int ii = 0; if(j==1) ii=i2-i;
|
---|
175 | cout<<i<<"("<<ii<<") ";
|
---|
176 | if(fbr.IsSNum()) cout<<" s=("<<s(ii)<<","<<si4(ii)<<")";
|
---|
177 | if(fbr.IsBolo()) cout<<" b="<<b(ii);
|
---|
178 | if(fbr.IsFlag()) cout<<" f=("<<f(ii)<<","<<fi4(ii)<<")";
|
---|
179 | if(fbr.IsAlpha()) cout<<" a="<<a(ii);
|
---|
180 | if(fbr.IsDelta()) cout<<" d="<<d(ii);
|
---|
181 | if(col1>=0) if(fbr.IsCol(col1)) cout<<" c1="<<c1(ii);
|
---|
182 | cout<<endl;
|
---|
183 | }
|
---|
184 | }
|
---|
185 | #endif
|
---|
186 |
|
---|
187 | #ifdef USE_EXCEPT
|
---|
188 | } catch (PThrowable & exc) {
|
---|
189 | cout<<"Exception : "<<(string)typeid(exc).name()
|
---|
190 | <<" - Msg= "<<exc.Msg()<<endl;
|
---|
191 | return -2;
|
---|
192 |
|
---|
193 | } catch (...) {
|
---|
194 | cout<<" some other exception was caught !"<<endl;
|
---|
195 | return -2;
|
---|
196 | }
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | return 0;
|
---|
200 | }
|
---|