1 | // ----------------------------------------------------------------------- |
---|
2 | // columns.cc: Define a set of columns for Duchamp output. |
---|
3 | // ----------------------------------------------------------------------- |
---|
4 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
5 | // |
---|
6 | // This program is free software; you can redistribute it and/or modify it |
---|
7 | // under the terms of the GNU General Public License as published by the |
---|
8 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
9 | // option) any later version. |
---|
10 | // |
---|
11 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
12 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
13 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
14 | // for more details. |
---|
15 | // |
---|
16 | // You should have received a copy of the GNU General Public License |
---|
17 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
18 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
19 | // |
---|
20 | // Correspondence concerning Duchamp may be directed to: |
---|
21 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
22 | // Postal address: Dr. Matthew Whiting |
---|
23 | // Australia Telescope National Facility, CSIRO |
---|
24 | // PO Box 76 |
---|
25 | // Epping NSW 1710 |
---|
26 | // AUSTRALIA |
---|
27 | // ----------------------------------------------------------------------- |
---|
28 | #include <iostream> |
---|
29 | #include <sstream> |
---|
30 | |
---|
31 | #include <math.h> |
---|
32 | #include <duchamp/duchamp.hh> |
---|
33 | #include <duchamp/fitsHeader.hh> |
---|
34 | #include <vector> |
---|
35 | #include <string> |
---|
36 | #include <duchamp/Detection/detection.hh> |
---|
37 | #include <duchamp/Outputs/columns.hh> |
---|
38 | |
---|
39 | namespace duchamp |
---|
40 | { |
---|
41 | |
---|
42 | namespace Catalogues |
---|
43 | { |
---|
44 | |
---|
45 | |
---|
46 | Column::Column() |
---|
47 | { |
---|
48 | /// @brief Set the default values for the parameters. |
---|
49 | this->itsWidth=1; |
---|
50 | this->itsPrecision=0; |
---|
51 | this->itsName=" "; |
---|
52 | this->itsUnits=" "; |
---|
53 | this->itsType=""; |
---|
54 | this->itsUCD = ""; |
---|
55 | this->itsDatatype = ""; |
---|
56 | this->itsExtraInfo=""; |
---|
57 | this->itsColID=""; |
---|
58 | } |
---|
59 | |
---|
60 | Column::Column(std::string type) |
---|
61 | { |
---|
62 | operator=(defaultColumn(type)); |
---|
63 | } |
---|
64 | |
---|
65 | Column::Column(const Column& c) |
---|
66 | { |
---|
67 | operator=(c); |
---|
68 | } |
---|
69 | |
---|
70 | Column& Column::operator=(const Column& c) |
---|
71 | { |
---|
72 | if(this==&c) return *this; |
---|
73 | this->itsWidth = c.itsWidth; |
---|
74 | this->itsPrecision = c.itsPrecision; |
---|
75 | this->itsName = c.itsName; |
---|
76 | this->itsUnits = c.itsUnits; |
---|
77 | this->itsUCD = c.itsUCD; |
---|
78 | this->itsDatatype = c.itsDatatype; |
---|
79 | this->itsExtraInfo = c.itsExtraInfo; |
---|
80 | this->itsColID = c.itsColID; |
---|
81 | this->itsType = c.itsType; |
---|
82 | return *this; |
---|
83 | } |
---|
84 | |
---|
85 | Column::Column(std::string type, std::string name, std::string units, int width, int prec, std::string ucd, std::string datatype, std::string colID, std::string extraInfo): |
---|
86 | itsType(type), itsName(name), itsUnits(units), itsWidth(width), itsPrecision(prec), itsUCD(ucd), itsDatatype(datatype), itsColID(colID), itsExtraInfo(extraInfo) |
---|
87 | { |
---|
88 | /// A generic constructor designed to make a Column other than |
---|
89 | /// the predefined ones listed in the Column namespace |
---|
90 | /// \param name The title of the column |
---|
91 | /// \param units What units the column takes |
---|
92 | /// \param width The starting width |
---|
93 | /// \param prec The starting precision |
---|
94 | /// \param ucd The UCD relating to the quantity (VOTable use only) |
---|
95 | /// \param datatype The datatype (float/char/int/etc) of the quantity (VOTable) |
---|
96 | /// \param colID The column ID string used in the FIELD entry of a VOTable |
---|
97 | /// \param extraInfo Other information used in the VOTable (eg. a reference to a COOSYS) |
---|
98 | } |
---|
99 | |
---|
100 | //------------------------------------------------------------ |
---|
101 | |
---|
102 | void Column::changePrec(int p) |
---|
103 | { |
---|
104 | /// A direct way to alter the precision without having to use |
---|
105 | /// Column::upPrec(). If the precision increases, the width will |
---|
106 | /// increase by the same amount. If it decreases, no change is |
---|
107 | /// made to the width. |
---|
108 | /// \param p The new precision value. |
---|
109 | |
---|
110 | if(p > this->itsPrecision) this->itsWidth += (p-this->itsPrecision); |
---|
111 | this->itsPrecision = p; |
---|
112 | |
---|
113 | } |
---|
114 | |
---|
115 | void Column::checkPrec(double val) |
---|
116 | { |
---|
117 | /// Checks a decimal value to see if it is in -1<val<1. If |
---|
118 | /// so, we need sufficient precision to represent at least |
---|
119 | /// one significant figure. |
---|
120 | if((fabs(val)<1.)){ |
---|
121 | int impliedPrec = int(fabs(log10(val))+1); |
---|
122 | for(int i=this->itsPrecision;i<=impliedPrec;i++) this->upPrec(); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | void Column::checkWidth(int width) |
---|
127 | { |
---|
128 | /// Three checks on the width, looking at the name, the |
---|
129 | /// units string, and then some minimum width. This can be |
---|
130 | /// obtained from the other check() functions that work |
---|
131 | /// from various value types. |
---|
132 | |
---|
133 | for(int i=this->itsWidth;i<=width;i++) this->widen();// +1 for the space |
---|
134 | for(int i=this->itsWidth;i<=int(this->itsName.size());i++) this->widen(); // +1 for the space |
---|
135 | for(int i=this->itsWidth;i<=int(this->itsUnits.size());i++) this->widen(); // +1 for the space |
---|
136 | |
---|
137 | } |
---|
138 | |
---|
139 | //------------------------------------------------------------ |
---|
140 | void Column::printTitle(std::ostream &stream) |
---|
141 | { |
---|
142 | stream << std::setw(this->itsWidth) |
---|
143 | << std::setfill(' ') |
---|
144 | << this->itsName; |
---|
145 | } |
---|
146 | |
---|
147 | void Column::printUnits(std::ostream &stream) |
---|
148 | { |
---|
149 | stream << std::setw(this->itsWidth) |
---|
150 | << std::setfill(' ') |
---|
151 | << this->itsUnits; |
---|
152 | } |
---|
153 | |
---|
154 | void Column::printDash (std::ostream &stream) |
---|
155 | { |
---|
156 | stream << std::setw(this->itsWidth) |
---|
157 | << std::setfill('-') |
---|
158 | << "" |
---|
159 | << std::setfill(' '); |
---|
160 | } |
---|
161 | |
---|
162 | void Column::printBlank(std::ostream &stream) |
---|
163 | { |
---|
164 | stream << std::setw(this->itsWidth) |
---|
165 | << std::setfill(' ') |
---|
166 | << ""; |
---|
167 | } |
---|
168 | |
---|
169 | template <class T> void Column::printEntry(std::ostream &stream, T value) |
---|
170 | { |
---|
171 | /// \param stream Where the printing is done. |
---|
172 | /// \param value The value to be printed. |
---|
173 | |
---|
174 | stream << std::setprecision(this->itsPrecision) |
---|
175 | << std::setw(this->itsWidth) |
---|
176 | << std::setfill(' ') |
---|
177 | << value; |
---|
178 | } |
---|
179 | template void Column::printEntry<int>(std::ostream &stream, int value); |
---|
180 | template void Column::printEntry<long>(std::ostream &stream, long value); |
---|
181 | template void Column::printEntry<unsigned int>(std::ostream &stream, unsigned int value); |
---|
182 | template void Column::printEntry<unsigned long>(std::ostream &stream, unsigned long value); |
---|
183 | template void Column::printEntry<float>(std::ostream &stream, float value); |
---|
184 | template void Column::printEntry<double>(std::ostream &stream, double value); |
---|
185 | template void Column::printEntry<std::string>(std::ostream &stream, std::string value); |
---|
186 | |
---|
187 | |
---|
188 | bool Column::doCol(DESTINATION tableType, bool flagFint) |
---|
189 | { |
---|
190 | /// @details Determines whether a given column is used for a |
---|
191 | /// given table type, based on the Column::type string. |
---|
192 | /// \param tableType The type of table: one of FILE, SCREEN, LOG, VOTABLE. |
---|
193 | /// \param flagFint Whether to use FINT (true) or FTOT |
---|
194 | /// (false). This defaults to true, so need not be given. It only |
---|
195 | /// applies to the screen and votable cases -- both are written for the |
---|
196 | /// results file case. |
---|
197 | /// \return True if column is used for given table type. False |
---|
198 | /// otherwise. False if tableType not one of four listed. |
---|
199 | |
---|
200 | |
---|
201 | const size_t sizeFileList=43; |
---|
202 | std::string FileList[sizeFileList]={"NUM","NAME","X","Y","Z","RA","DEC","RAJD","DECJD","VEL","MAJ","MIN","PA","WRA","WDEC", |
---|
203 | "W50","W20","WVEL","FINT","FINTERR","FTOT","FTOTERR","FPEAK","SNRPEAK", |
---|
204 | "X1","X2","Y1","Y2","Z1","Z2","NVOX","NUMCH","SPATSIZE","FLAG","XAV","YAV", |
---|
205 | "ZAV","XCENT","YCENT","ZCENT","XPEAK","YPEAK","ZPEAK"}; |
---|
206 | const size_t sizeScreenList=24; |
---|
207 | std::string ScreenList[sizeScreenList]={"NUM","NAME","X","Y","Z","RA","DEC","VEL","MAJ","MIN","PA", |
---|
208 | "W50","FPEAK","SNRPEAK","X1","X2","Y1", |
---|
209 | "Y2","Z1","Z2","NVOX","NUMCH","SPATSIZE","FLAG"}; |
---|
210 | const size_t sizeLogList=16; |
---|
211 | std::string LogList[sizeLogList]={"NUM","X","Y","Z","FTOT","FPEAK","SNRPEAK", |
---|
212 | "X1","X2","Y1","Y2","Z1","Z2","NVOX","NUMCH","SPATSIZE"}; |
---|
213 | // const size_t sizeVOList=23; |
---|
214 | // std::string VOList[sizeVOList]={"NUM","NAME","RAJD","DECJD","VEL","MAJ","MIN","PA", |
---|
215 | // "W50","W20","WVEL","FPEAK","SNRPEAK","FLAG","XAV","YAV", |
---|
216 | // "ZAV","XCENT","YCENT","ZCENT","XPEAK","YPEAK","ZPEAK"}; |
---|
217 | |
---|
218 | bool doIt=false; |
---|
219 | if(tableType == FILE){ |
---|
220 | for(size_t i=0;i<sizeFileList && !doIt;i++) doIt = doIt || (this->itsType==FileList[i]); |
---|
221 | } |
---|
222 | else if(tableType == SCREEN){ |
---|
223 | if(this->itsType=="FTOT") doIt = !flagFint; |
---|
224 | else if(this->itsType == "FINT") doIt = flagFint; |
---|
225 | else for(size_t i=0;i<sizeScreenList && !doIt;i++) doIt = doIt || (this->itsType==ScreenList[i]); |
---|
226 | } |
---|
227 | else if(tableType == LOG){ |
---|
228 | for(size_t i=0;i<sizeLogList && !doIt;i++) doIt = doIt || (this->itsType==LogList[i]); |
---|
229 | } |
---|
230 | else if(tableType == VOTABLE){ |
---|
231 | if(this->itsType=="FTOT" || this->itsType=="FTOTERR") doIt = !flagFint; |
---|
232 | else if(this->itsType == "FINT" || this->itsType=="FINTERR") doIt = flagFint; |
---|
233 | // else for(size_t i=0;i<sizeVOList && !doIt;i++) doIt = doIt || (this->itsType==VOList[i]); |
---|
234 | else{ |
---|
235 | for(size_t i=0;i<sizeFileList && !doIt;i++){ |
---|
236 | if(FileList[i]!="RA" && FileList[i]!="DEC") |
---|
237 | doIt = doIt || (this->itsType==FileList[i]); |
---|
238 | } |
---|
239 | } |
---|
240 | } |
---|
241 | |
---|
242 | return doIt; |
---|
243 | |
---|
244 | } |
---|
245 | |
---|
246 | Column defaultColumn(std::string type) |
---|
247 | { |
---|
248 | // type|name|units|width|prec|ucd|datatype|extraInfo |
---|
249 | if (type == "NUM") return Column(type,"ObjID","",6,0,"meta.id","int","col_objnum",""); |
---|
250 | else if(type=="NAME") return Column(type,"Name","",8,0,"meta.id;meta.main","char","col_name",""); |
---|
251 | else if(type=="X") return Column(type,"X","",6,prXYZ,"pos.cartesian.x","float","col_x",""); |
---|
252 | else if(type=="Y") return Column(type,"Y","",6,prXYZ,"pos.cartesian.y","float","col_y",""); |
---|
253 | else if(type=="Z") return Column(type,"Z","",6,prXYZ,"pos.cartesian.z","float","col_z",""); |
---|
254 | else if(type=="RA") return Column(type,"RA","",11,0,"","char","col_ra",coordRef); |
---|
255 | else if(type=="DEC") return Column(type,"DEC","",10,0,"","char","col_dec",coordRef); |
---|
256 | else if(type=="RAJD") return Column(type,"RAJD","[deg]",11,prPOS,"","float","col_rajd",coordRef); |
---|
257 | else if(type=="DECJD") return Column(type,"DECJD","[deg]",11,prPOS,"","float","col_decjd",coordRef); |
---|
258 | else if(type=="VEL") return Column(type,"VEL","",7,prVEL,"","float","col_vel",""); |
---|
259 | else if(type=="MAJ") return Column(type,"MAJ","[deg]",6,prWPOS,"phys.angSize.smajAxis","float","col_maj",coordRef); |
---|
260 | else if(type=="MIN") return Column(type,"MIN","[deg]",6,prWPOS,"phys.angSize.sminAxis","float","col_min",coordRef); |
---|
261 | else if(type=="PA") return Column(type,"PA","[deg]",7,prWPOS,"pos.posAng;phys.angSize","float","col_pa",coordRef); |
---|
262 | else if(type=="WRA") return Column(type,"w_RA","[arcmin]",9,prWPOS,"","float","col_wra",coordRef); |
---|
263 | else if(type=="WDEC") return Column(type,"w_DEC","[arcmin]",9,prWPOS,"","float","col_wdec",coordRef); |
---|
264 | else if(type=="W50") return Column(type,"w_50","",7,prVEL,"","float","col_w50",""); |
---|
265 | else if(type=="W20") return Column(type,"w_20","",7,prVEL,"","float","col_w20",""); |
---|
266 | else if(type=="WVEL") return Column(type,"w_VEL","",7,prVEL,"","float","col_wvel",""); |
---|
267 | else if(type=="FINT") return Column(type,"F_int","",10,prFLUX,"phot.flux.density.integrated","float","col_fint",""); |
---|
268 | else if(type=="FINTERR") return Column(type,"eF_int","",10,prFLUX,"phot.flux.density.integrated;stat.err","float","col_efint",""); |
---|
269 | else if(type=="FTOT") return Column(type,"F_tot","",10,prFLUX,"phot.flux.density","float","col_ftot",""); |
---|
270 | else if(type=="FTOTERR") return Column(type,"eF_tot","",10,prFLUX,"phot.flux.density;stat.err","float","col_eftot",""); |
---|
271 | else if(type=="FPEAK") return Column(type,"F_peak","",9,prFLUX,"phot.flux;stat.max","float","col_fpeak",""); |
---|
272 | else if(type=="SNRPEAK") return Column(type,"S/Nmax","",7,prSNR,"stat.snr;phot.flux","float","col_snrmax",""); |
---|
273 | else if(type=="X1") return Column(type,"X1","",4,0,"pos.cartesian.x;stat.min","int","col_x1",""); |
---|
274 | else if(type=="Y1") return Column(type,"Y1","",4,0,"pos.cartesian.y;stat.min","int","col_y1",""); |
---|
275 | else if(type=="Z1") return Column(type,"Z1","",4,0,"pos.cartesian.z;stat.min","int","col_z1",""); |
---|
276 | else if(type=="X2") return Column(type,"X2","",4,0,"pos.cartesian.x;stat.max","int","col_x2",""); |
---|
277 | else if(type=="Y2") return Column(type,"Y2","",4,0,"pos.cartesian.y;stat.max","int","col_y2",""); |
---|
278 | else if(type=="Z2") return Column(type,"Z2","",4,0,"pos.cartesian.z;stat.max","int","col_z2",""); |
---|
279 | else if(type=="NVOX") return Column(type,"Nvoxel","",7,0,"phys.size;instr.pixel;em.bin","int","col_nvox",""); |
---|
280 | else if(type=="NUMCH") return Column(type,"Nchan","",6,0,"spect.line.width.full;em.bin","int","col_nch",""); |
---|
281 | else if(type=="SPATSIZE") return Column(type,"Nspatpix","",9,0,"phys.angArea;instr.pixel","int","col_spsize",""); |
---|
282 | else if(type=="FLAG") return Column(type,"Flag","",5,0,"meta.code.qual","char","col_flag",""); |
---|
283 | else if(type=="XAV") return Column(type,"X_av","",6,prXYZ,"pos.cartesian.x;stat.mean","float","col_xav",""); |
---|
284 | else if(type=="YAV") return Column(type,"Y_av","",6,prXYZ,"pos.cartesian.y;stat.mean","float","col_yav",""); |
---|
285 | else if(type=="ZAV") return Column(type,"Z_av","",6,prXYZ,"pos.cartesian.z;stat.mean","float","col_zav",""); |
---|
286 | else if(type=="XCENT") return Column(type,"X_cent","",7,prXYZ,"pos.cartesian.x;stat.centroid","float","col_xcent",""); |
---|
287 | else if(type=="YCENT") return Column(type,"Y_cent","",7,prXYZ,"pos.cartesian.y;stat.centroid","float","col_ycent",""); |
---|
288 | else if(type=="ZCENT") return Column(type,"Z_cent","",7,prXYZ,"pos.cartesian.z;stat.centroid","float","col_zcent",""); |
---|
289 | else if(type=="XPEAK") return Column(type,"X_peak","",7,prXYZ,"pos.cartesian.x;phot.flux;stat.max","int","col_xpeak",""); |
---|
290 | else if(type=="YPEAK") return Column(type,"Y_peak","",7,prXYZ,"pos.cartesian.y;phot.flux;stat.max","int","col_ypeak",""); |
---|
291 | else if(type=="ZPEAK") return Column(type,"Z_peak","",7,prXYZ,"pos.cartesian.z;phot.flux;stat.max","int","col_zpeak",""); |
---|
292 | else { |
---|
293 | Column col; |
---|
294 | col.setType(type); |
---|
295 | return col; |
---|
296 | } |
---|
297 | |
---|
298 | } |
---|
299 | |
---|
300 | CatalogueSpecification getFullColSet(std::vector<Detection> &objectList, FitsHeader &head) |
---|
301 | { |
---|
302 | /// @details A function that returns a catalogue specification |
---|
303 | /// containing information on the columns necessary for output |
---|
304 | /// to the results file: |
---|
305 | /// Obj#,NAME,X,Y,Z,RA,DEC,VEL,w_RA,w_DEC,w_VEL,F_tot,F_int,F_peak, |
---|
306 | /// X1,X2,Y1,Y2,Z1,Z2,Nvox,Flag, |
---|
307 | /// XAV,YAV,ZAV,XCENT,YCENT,ZCENT,XPEAK,YPEAK,ZPEAK |
---|
308 | /// |
---|
309 | /// Each object in the provided objectList is checked to see if it |
---|
310 | /// requires any column to be widened, or for that column to have |
---|
311 | /// its precision increased. |
---|
312 | /// |
---|
313 | /// Both Ftot and Fint are provided -- it is up to the calling |
---|
314 | /// function to determine which to use. |
---|
315 | /// |
---|
316 | /// \param objectList A std::vector list of Detection objects that the |
---|
317 | /// columns need to fit. |
---|
318 | /// \param head The FitsHeader object defining the World Coordinate |
---|
319 | /// System. |
---|
320 | /// \return A CatalogueSpecification |
---|
321 | |
---|
322 | CatalogueSpecification newset; |
---|
323 | |
---|
324 | // desired precisions for fluxes, velocities and SNR value |
---|
325 | int precVel,precFlux,precSNR; |
---|
326 | if(objectList.size()>0){ |
---|
327 | precVel=objectList[0].getVelPrec(); |
---|
328 | precFlux=objectList[0].getFpeakPrec(); // same as FintPrec at this point. |
---|
329 | precSNR=objectList[0].getSNRPrec(); |
---|
330 | } |
---|
331 | else { |
---|
332 | precVel = prVEL; |
---|
333 | precFlux = prFLUX; |
---|
334 | precSNR = prSNR; |
---|
335 | } |
---|
336 | |
---|
337 | // set up the default columns |
---|
338 | newset.addColumn( Column("NUM") ); |
---|
339 | newset.addColumn( Column("NAME") ); |
---|
340 | newset.addColumn( Column("X") ); |
---|
341 | newset.addColumn( Column("Y") ); |
---|
342 | newset.addColumn( Column("Z") ); |
---|
343 | newset.addColumn( Column("RA") ); |
---|
344 | newset.addColumn( Column("DEC") ); |
---|
345 | newset.addColumn( Column("RAJD") ); |
---|
346 | newset.addColumn( Column("DECJD") ); |
---|
347 | newset.addColumn( Column("VEL") ); |
---|
348 | newset.addColumn( Column("MAJ") ); |
---|
349 | newset.addColumn( Column("MIN") ); |
---|
350 | newset.addColumn( Column("PA") ); |
---|
351 | newset.addColumn( Column("WRA") ); |
---|
352 | newset.addColumn( Column("WDEC") ); |
---|
353 | newset.addColumn( Column("W50") ); |
---|
354 | newset.addColumn( Column("W20") ); |
---|
355 | newset.addColumn( Column("WVEL") ); |
---|
356 | newset.addColumn( Column("FINT") ); |
---|
357 | newset.addColumn( Column("FINTERR") ); |
---|
358 | newset.addColumn( Column("FTOT") ); |
---|
359 | newset.addColumn( Column("FTOTERR") ); |
---|
360 | newset.addColumn( Column("FPEAK") ); |
---|
361 | newset.addColumn( Column("SNRPEAK") ); |
---|
362 | newset.addColumn( Column("X1") ); |
---|
363 | newset.addColumn( Column("X2") ); |
---|
364 | newset.addColumn( Column("Y1") ); |
---|
365 | newset.addColumn( Column("Y2") ); |
---|
366 | newset.addColumn( Column("Z1") ); |
---|
367 | newset.addColumn( Column("Z2") ); |
---|
368 | newset.addColumn( Column("NVOX") ); |
---|
369 | newset.addColumn( Column("NUMCH") ); |
---|
370 | newset.addColumn( Column("SPATSIZE") ); |
---|
371 | newset.addColumn( Column("FLAG") ); |
---|
372 | newset.addColumn( Column("XAV") ); |
---|
373 | newset.addColumn( Column("YAV") ); |
---|
374 | newset.addColumn( Column("ZAV") ); |
---|
375 | newset.addColumn( Column("XCENT") ); |
---|
376 | newset.addColumn( Column("YCENT") ); |
---|
377 | newset.addColumn( Column("ZCENT") ); |
---|
378 | newset.addColumn( Column("XPEAK") ); |
---|
379 | newset.addColumn( Column("YPEAK") ); |
---|
380 | newset.addColumn( Column("ZPEAK") ); |
---|
381 | |
---|
382 | // Define the column names and units where not predifined by the |
---|
383 | // default settings (ie. for those columns that depend on the |
---|
384 | // WCS or image units) |
---|
385 | if(head.isWCS()){ |
---|
386 | newset.column("RA").setName(head.lngtype()); |
---|
387 | newset.column("DEC").setName(head.lattype()); |
---|
388 | newset.column("RAJD").setName(head.lngtype()); |
---|
389 | newset.column("DECJD").setName(head.lattype()); |
---|
390 | if(head.canUseThirdAxis()){ |
---|
391 | if(head.WCS().spec < 0) // if it's not a spectral axis |
---|
392 | newset.column("VEL").setName( head.WCS().ctype[2] ); |
---|
393 | else |
---|
394 | newset.column("VEL").setName(head.getSpectralType()); |
---|
395 | if(head.getSpectralUnits().size()>0) |
---|
396 | newset.column("VEL").setUnits("[" + head.getSpectralUnits() + "]"); |
---|
397 | } |
---|
398 | newset.column("MAJ").setUnits("["+head.getShapeUnits()+"]"); |
---|
399 | newset.column("MIN").setUnits("["+head.getShapeUnits()+"]"); |
---|
400 | newset.column("WRA").setName("w_"+head.lngtype()); |
---|
401 | newset.column("WDEC").setName("w_"+head.lattype()); |
---|
402 | if(head.canUseThirdAxis()){ |
---|
403 | if(head.getSpectralUnits().size()>0){ |
---|
404 | newset.column("W50").setUnits("[" + head.getSpectralUnits() + "]"); |
---|
405 | newset.column("W20").setUnits("[" + head.getSpectralUnits() + "]"); |
---|
406 | newset.column("WVEL").setUnits("[" + head.getSpectralUnits() + "]"); |
---|
407 | } |
---|
408 | if(head.WCS().spec < 0) // if it's not a spectral axis |
---|
409 | newset.column("WVEL").setName( std::string("w_") + head.WCS().ctype[2] ); |
---|
410 | else |
---|
411 | newset.column("WVEL").setName(std::string("w_")+head.getSpectralType()); |
---|
412 | } |
---|
413 | } |
---|
414 | if(head.getIntFluxUnits().size()>0){ |
---|
415 | newset.column("FINT").setUnits("[" + head.getIntFluxUnits() + "]"); |
---|
416 | newset.column("FINTERR").setUnits("[" + head.getIntFluxUnits() + "]"); |
---|
417 | } |
---|
418 | newset.column("FTOT").setUnits("[" + head.getFluxUnits() + "]"); |
---|
419 | newset.column("FTOTERR").setUnits("[" + head.getFluxUnits() + "]"); |
---|
420 | newset.column("FPEAK").setUnits("[" + head.getFluxUnits() + "]"); |
---|
421 | |
---|
422 | |
---|
423 | // Now test each object against each new column, ensuring each |
---|
424 | // column has sufficient width and (in most cases) precision to |
---|
425 | // accomodate the data. |
---|
426 | std::vector<Detection>::iterator obj; |
---|
427 | for(obj = objectList.begin(); obj < objectList.end(); obj++){ |
---|
428 | |
---|
429 | newset.column("NUM").check(obj->getID()); |
---|
430 | newset.column("NAME").check(obj->getName()); |
---|
431 | newset.column("X").check(obj->getXcentre()+obj->getXOffset()); |
---|
432 | newset.column("Y").check(obj->getYcentre()+obj->getYOffset()); |
---|
433 | newset.column("Z").check(obj->getZcentre()+obj->getZOffset()); |
---|
434 | if(head.isWCS()){ |
---|
435 | newset.column("RA").check(obj->getRAs()); |
---|
436 | newset.column("DEC").check(obj->getDecs()); |
---|
437 | newset.column("RAJD").check(obj->getRA()); |
---|
438 | newset.column("DECJD").check(obj->getDec()); |
---|
439 | if(head.canUseThirdAxis()){ |
---|
440 | newset.column("VEL").check(obj->getVel()); |
---|
441 | } |
---|
442 | newset.column("MAJ").check(obj->getMajorAxis()); |
---|
443 | newset.column("MIN").check(obj->getMinorAxis()); |
---|
444 | // For the PA column, we don't increase the precision. If |
---|
445 | // something is very close to zero position angle, then |
---|
446 | // we're happy to call it zero. |
---|
447 | newset.column("PA").check(obj->getPositionAngle(),false); |
---|
448 | newset.column("WRA").check(obj->getRAWidth()); |
---|
449 | newset.column("WDEC").check(obj->getDecWidth()); |
---|
450 | if(head.canUseThirdAxis()){ |
---|
451 | newset.column("W50").check(obj->getW50()); |
---|
452 | newset.column("W20").check(obj->getW20()); |
---|
453 | newset.column("WVEL").check(obj->getVelWidth()); |
---|
454 | } |
---|
455 | |
---|
456 | newset.column("FINT").check(obj->getIntegFlux()); |
---|
457 | if(obj->getIntegFluxError()>0.) |
---|
458 | newset.column("FINTERR").check(obj->getIntegFluxError()); |
---|
459 | } |
---|
460 | newset.column("FTOT").check(obj->getTotalFlux()); |
---|
461 | if(obj->getTotalFluxError()>0.) |
---|
462 | newset.column("FTOTERR").check(obj->getTotalFluxError()); |
---|
463 | newset.column("FPEAK").check(obj->getPeakFlux()); |
---|
464 | if(obj->getPeakSNR()>0.) |
---|
465 | newset.column("SNRPEAK").check(obj->getPeakSNR()); |
---|
466 | newset.column("X1").check(obj->getXmin()+obj->getXOffset()); |
---|
467 | newset.column("X2").check(obj->getXmax()+obj->getXOffset()); |
---|
468 | newset.column("Y1").check(obj->getYmin()+obj->getYOffset()); |
---|
469 | newset.column("Y2").check(obj->getYmax()+obj->getYOffset()); |
---|
470 | newset.column("Z1").check(obj->getZmin()+obj->getZOffset()); |
---|
471 | newset.column("Z2").check(obj->getZmax()+obj->getZOffset()); |
---|
472 | newset.column("NVOX").check(obj->getSize()); |
---|
473 | newset.column("XAV").check(obj->getXaverage()+obj->getXOffset()); |
---|
474 | newset.column("YAV").check(obj->getYaverage()+obj->getYOffset()); |
---|
475 | newset.column("ZAV").check(obj->getZaverage()+obj->getZOffset()); |
---|
476 | newset.column("XCENTROID").check(obj->getXCentroid()+obj->getXOffset()); |
---|
477 | newset.column("YCENTROID").check(obj->getYCentroid()+obj->getYOffset()); |
---|
478 | newset.column("ZCENTROID").check(obj->getZCentroid()+obj->getZOffset()); |
---|
479 | newset.column("XPEAK").check(obj->getXPeak()+obj->getXOffset()); |
---|
480 | newset.column("YPEAK").check(obj->getYPeak()+obj->getYOffset()); |
---|
481 | newset.column("ZPEAK").check(obj->getZPeak()+obj->getZOffset()); |
---|
482 | newset.column("NUMCH").check(obj->getNumChannels()); |
---|
483 | newset.column("SPATSIZE").check(obj->getSpatialSize()); |
---|
484 | |
---|
485 | } |
---|
486 | |
---|
487 | return newset; |
---|
488 | |
---|
489 | } |
---|
490 | |
---|
491 | } |
---|
492 | |
---|
493 | } |
---|