1 | #include <Detection/columns.hh> |
---|
2 | #include <param.hh> |
---|
3 | #include <Cubes/cubes.hh> |
---|
4 | #include <vector> |
---|
5 | #include <string> |
---|
6 | |
---|
7 | using std::string; |
---|
8 | using std::vector; |
---|
9 | using namespace Column; |
---|
10 | |
---|
11 | Col getDefaultCol(int i){ |
---|
12 | ColSet columnSet; |
---|
13 | switch(i){ |
---|
14 | case 0: |
---|
15 | return Col(5, "Obj#", ""); //[0] -- in briefCol |
---|
16 | break; |
---|
17 | case 1: |
---|
18 | return Col(8,"Name", ""); //[1] -- in briefCol |
---|
19 | break; |
---|
20 | case 2: |
---|
21 | return Col(6, "X", ""); //[2] -- in briefCol |
---|
22 | break; |
---|
23 | case 3: |
---|
24 | return Col(6, "Y", ""); //[3] -- in briefCol |
---|
25 | break; |
---|
26 | case 4: |
---|
27 | return Col(6, "Z", ""); //[4] -- in briefCol |
---|
28 | break; |
---|
29 | case 5: |
---|
30 | return Col(13,"", ""); //[5] (RA) |
---|
31 | break; |
---|
32 | case 6: |
---|
33 | return Col(13,"", ""); //[6] (Dec) |
---|
34 | break; |
---|
35 | case 7: |
---|
36 | return Col(7, "VEL", ""); //[7] |
---|
37 | break; |
---|
38 | case 8: |
---|
39 | return Col(9, "", "[arcmin]"); //[8] (wRA) |
---|
40 | break; |
---|
41 | case 9: |
---|
42 | return Col(9, "", "[arcmin]"); //[9] (wDEC) |
---|
43 | break; |
---|
44 | case 10: |
---|
45 | return Col(7, "w_VEL", ""); //[10] |
---|
46 | break; |
---|
47 | case 12: |
---|
48 | return Col(9, "F_peak", ""); //[12] -- in briefCol |
---|
49 | break; |
---|
50 | case 13: |
---|
51 | return Col(4, "X1", ""); //[13] -- in briefCol |
---|
52 | break; |
---|
53 | case 14: |
---|
54 | return Col(4, "X2", ""); //[14] -- in briefCol |
---|
55 | break; |
---|
56 | case 15: |
---|
57 | return Col(4, "Y1", ""); //[15] -- in briefCol |
---|
58 | break; |
---|
59 | case 16: |
---|
60 | return Col(4, "Y2", ""); //[16] -- in briefCol |
---|
61 | break; |
---|
62 | case 17: |
---|
63 | return Col(4, "Z1", ""); //[17] -- in briefCol |
---|
64 | break; |
---|
65 | case 18: |
---|
66 | return Col(4, "Z2", ""); //[18] -- in briefCol |
---|
67 | break; |
---|
68 | case 19: |
---|
69 | return Col(6, "Npix", "[pix]"); //[19] -- in briefCol |
---|
70 | break; |
---|
71 | case 20: |
---|
72 | return Col(5, "Flag", ""); //[20] |
---|
73 | break; |
---|
74 | case 11: |
---|
75 | default: |
---|
76 | std::cerr << "ERROR <getDefaultCol> : bad value of argument : " << i << "\n"; |
---|
77 | break; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | void Cube::setupColumns(){ |
---|
82 | |
---|
83 | this->fullColSet.vec.clear(); |
---|
84 | this->logColSet.vec.clear(); |
---|
85 | |
---|
86 | // initialise |
---|
87 | |
---|
88 | Col fint(10,"F_int", ""); |
---|
89 | Col ftot(10,"F_tot", ""); |
---|
90 | |
---|
91 | Col tempC; |
---|
92 | string tempstr; |
---|
93 | int size; |
---|
94 | |
---|
95 | // Obj# and Name |
---|
96 | this->fullColSet.vec.push_back(getDefaultCol(0)); |
---|
97 | tempC = getDefaultCol(1); |
---|
98 | for(int o=0;o<this->objectList.size();o++){ |
---|
99 | int tempsize = this->objectList[o].getName().size() + 1; |
---|
100 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
101 | } |
---|
102 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
103 | this->fullColSet.vec.push_back(tempC); |
---|
104 | |
---|
105 | // X, Y, Z -- check for widened columns |
---|
106 | tempC = getDefaultCol(2); |
---|
107 | for(int o=0;o<this->objectList.size();o++){ |
---|
108 | int tempsize = int( log10(this->objectList[o].getXcentre()) + 1) + xyzPrec + 2; |
---|
109 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
110 | } |
---|
111 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
112 | this->fullColSet.vec.push_back(tempC); |
---|
113 | tempC = getDefaultCol(3); |
---|
114 | for(int o=0;o<this->objectList.size();o++){ |
---|
115 | int tempsize = int( log10(this->objectList[o].getYcentre()) + 1) + xyzPrec + 2; |
---|
116 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
117 | } |
---|
118 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
119 | this->fullColSet.vec.push_back(tempC); |
---|
120 | tempC = getDefaultCol(4); |
---|
121 | for(int o=0;o<this->objectList.size();o++){ |
---|
122 | int tempsize = int( log10(this->objectList[o].getZcentre()) + 1) + xyzPrec + 2; |
---|
123 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
124 | } |
---|
125 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
126 | this->fullColSet.vec.push_back(tempC); |
---|
127 | |
---|
128 | // RA & Dec -- should be fine, need to assign correct column title |
---|
129 | tempstr = this->head.getWCS()->lngtyp; |
---|
130 | tempC = getDefaultCol(5); |
---|
131 | tempC.setName(tempstr); |
---|
132 | this->fullColSet.vec.push_back(tempC); |
---|
133 | tempC = getDefaultCol(6); |
---|
134 | tempstr = this->head.getWCS()->lattyp; |
---|
135 | tempC.setName(tempstr); |
---|
136 | this->fullColSet.vec.push_back(tempC); |
---|
137 | |
---|
138 | // VEL -- title & width to be checked |
---|
139 | tempC = getDefaultCol(7); |
---|
140 | tempC.setUnit("[" + this->head.getSpectralUnits() + "]"); |
---|
141 | size = this->head.getSpectralUnits().size() + 3; |
---|
142 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
143 | for(int o=0;o<this->objectList.size();o++){ |
---|
144 | int tempsize = int( log10(fabsf(this->objectList[o].getVel())) + 1) + velPrec + 2; |
---|
145 | if(this->objectList[o].getVel()<0) tempsize++; // for - sign |
---|
146 | if((o==0)||(tempsize > size)) size = tempsize; |
---|
147 | } |
---|
148 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
149 | this->fullColSet.vec.push_back(tempC); |
---|
150 | |
---|
151 | // w_RA & w_DEC -- titles and widths to be checked. |
---|
152 | tempstr = "w_" + this->fullColSet.vec[5].getName(); |
---|
153 | tempC = getDefaultCol(8); |
---|
154 | tempC.setName(tempstr); |
---|
155 | for(int o=0;o<this->objectList.size();o++){ |
---|
156 | int tempsize = int( log10(this->objectList[o].getRAWidth()) + 1) + wposPrec + 2; |
---|
157 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
158 | } |
---|
159 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
160 | this->fullColSet.vec.push_back(tempC); |
---|
161 | |
---|
162 | tempstr = "w_" + this->fullColSet.vec[6].name; |
---|
163 | tempC = getDefaultCol(9); |
---|
164 | tempC.setName(tempstr); |
---|
165 | for(int o=0;o<this->objectList.size();o++){ |
---|
166 | int tempsize = int( log10(this->objectList[o].getDecWidth()) + 1) + wposPrec + 2; |
---|
167 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
168 | } |
---|
169 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
170 | this->fullColSet.vec.push_back(tempC); |
---|
171 | |
---|
172 | // w_VEL -- title & width to be checked |
---|
173 | tempC = getDefaultCol(10); |
---|
174 | tempC.setUnit("[" + this->head.getSpectralUnits() + "]"); |
---|
175 | size = this->head.getSpectralUnits().size() + 3; |
---|
176 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
177 | for(int o=0;o<this->objectList.size();o++){ |
---|
178 | int tempsize = int( log10(this->objectList[o].getVelWidth()) + 1) + velPrec + 2; |
---|
179 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
180 | } |
---|
181 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
182 | this->fullColSet.vec.push_back(tempC); |
---|
183 | |
---|
184 | // F_int |
---|
185 | fint.setUnit("[" + this->head.getIntFluxUnits() + "]"); |
---|
186 | size = this->head.getIntFluxUnits().size(); |
---|
187 | for(int i=fint.width-3;i<size;i++) fint.widen(); |
---|
188 | for(int o=0;o<this->objectList.size();o++){ |
---|
189 | int tempsize = int( log10(fabsf(this->objectList[o].getIntegFlux())) + 1) + fluxPrec + 2; |
---|
190 | if(this->objectList[o].getIntegFlux()<0) tempsize++; |
---|
191 | if((o==0)||(size < tempsize )) size = tempsize; |
---|
192 | } |
---|
193 | for(int i=fint.width;i<size;i++) fint.widen(); |
---|
194 | |
---|
195 | // F_tot |
---|
196 | ftot.setUnit("[" + this->head.getFluxUnits() + "]"); |
---|
197 | size = this->head.getFluxUnits().size(); |
---|
198 | for(int i=ftot.width-3;i<size;i++) ftot.widen(); |
---|
199 | for(int o=0;o<this->objectList.size();o++){ |
---|
200 | int tempsize = int( log10(fabsf(this->objectList[o].getTotalFlux())) + 1) + fluxPrec + 2; |
---|
201 | if(this->objectList[o].getTotalFlux()<0) tempsize++; |
---|
202 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
203 | } |
---|
204 | for(int i=ftot.width;i<size;i++) ftot.widen(); |
---|
205 | |
---|
206 | // Add F_int or F_tot depending on WCS status |
---|
207 | if(this->head.isWCS()) this->fullColSet.vec.push_back(fint); |
---|
208 | else this->fullColSet.vec.push_back(ftot); |
---|
209 | |
---|
210 | // F_peak |
---|
211 | tempC = getDefaultCol(12); |
---|
212 | tempC.setUnit("[" + this->head.getFluxUnits() + "]"); |
---|
213 | size = this->head.getFluxUnits().size(); |
---|
214 | for(int i=tempC.width-3;i<size;i++) tempC.widen(); |
---|
215 | for(int o=0;o<this->objectList.size();o++){ |
---|
216 | int tempsize = int( log10(fabsf(this->objectList[o].getPeakFlux())) + 1); |
---|
217 | if(this->objectList[o].getPeakFlux()<0) tempsize++; |
---|
218 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
219 | } |
---|
220 | for(int i=tempC.width;i<size+fluxPrec+2;i++) tempC.widen(); |
---|
221 | this->fullColSet.vec.push_back(tempC); |
---|
222 | |
---|
223 | // X1,X2,Y1,Y2,Z1,Z2 -- just check widths |
---|
224 | tempC = getDefaultCol(13); |
---|
225 | for(int o=0;o<this->objectList.size();o++){ |
---|
226 | int tempsize = int( log10(this->objectList[o].getXmin()) + 1 + 1); |
---|
227 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
228 | } |
---|
229 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
230 | this->fullColSet.vec.push_back(tempC); |
---|
231 | tempC = getDefaultCol(14); |
---|
232 | for(int o=0;o<this->objectList.size();o++){ |
---|
233 | int tempsize = int( log10(this->objectList[o].getXmax()) + 1 + 1); |
---|
234 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
235 | } |
---|
236 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
237 | this->fullColSet.vec.push_back(tempC); |
---|
238 | |
---|
239 | tempC = getDefaultCol(15); |
---|
240 | for(int o=0;o<this->objectList.size();o++){ |
---|
241 | int tempsize = int( log10(this->objectList[o].getYmin()) + 1) + 1; |
---|
242 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
243 | } |
---|
244 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
245 | this->fullColSet.vec.push_back(tempC); |
---|
246 | tempC = getDefaultCol(16); |
---|
247 | for(int o=0;o<this->objectList.size();o++){ |
---|
248 | int tempsize = int( log10(this->objectList[o].getYmax()) + 1) + 1; |
---|
249 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
250 | } |
---|
251 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
252 | this->fullColSet.vec.push_back(tempC); |
---|
253 | |
---|
254 | tempC = getDefaultCol(17); |
---|
255 | for(int o=0;o<this->objectList.size();o++){ |
---|
256 | int tempsize = int( log10(this->objectList[o].getZmin()) + 1) + 1; |
---|
257 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
258 | } |
---|
259 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
260 | this->fullColSet.vec.push_back(tempC); |
---|
261 | tempC = getDefaultCol(18); |
---|
262 | for(int o=0;o<this->objectList.size();o++){ |
---|
263 | int tempsize = int( log10(this->objectList[o].getZmax()) + 1) + 1; |
---|
264 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
265 | } |
---|
266 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
267 | this->fullColSet.vec.push_back(tempC); |
---|
268 | |
---|
269 | // Npix -- check for width. |
---|
270 | tempC = getDefaultCol(19); |
---|
271 | for(int o=0;o<this->objectList.size();o++){ |
---|
272 | size = int( log10(this->objectList[o].getSize()) ) + 2; |
---|
273 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
274 | } |
---|
275 | this->fullColSet.vec.push_back(tempC); |
---|
276 | |
---|
277 | // Flags. |
---|
278 | this->fullColSet.vec.push_back(getDefaultCol(20)); |
---|
279 | |
---|
280 | // Now copy the correct columns to the log columnset |
---|
281 | this->logColSet.vec.push_back(this->fullColSet.vec[0]); |
---|
282 | for(int i=1;i<4;i++) this->logColSet.vec.push_back(this->fullColSet.vec[i+1]); |
---|
283 | this->logColSet.vec.push_back(ftot); |
---|
284 | for(int i=5;i<13;i++) this->logColSet.vec.push_back(this->fullColSet.vec[i+7]); |
---|
285 | this->logColSet.defined= true; |
---|
286 | |
---|
287 | } |
---|