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