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