source: tags/release-1.1.7/src/Detection/columns.cc @ 533

Last change on this file since 533 was 528, checked in by MatthewWhiting, 15 years ago

Changing the documentation comments to match the askapsoft style. Also have split ChanMap? and Object3D into separate files.

File size: 24.5 KB
Line 
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/Detection/columns.hh>
38
39namespace duchamp
40{
41
42  namespace Column
43  {
44
45
46    Col::Col()
47    {
48      /// @brief Set the default values for the parameters.
49      this->width=1;
50      this->precision=0;
51      this->name=" ";
52      this->units=" ";
53      this->type=UNKNOWN;
54    }
55
56    Col::~Col(){}
57
58    Col::Col(const Col& c)
59    {
60      operator=(c);
61    }
62
63    Col& Col::operator=(const Col& c)
64    {
65      if(this==&c) return *this;
66      this->width = c.width;
67      this->precision = c.precision;
68      this->name = c.name;
69      this->units = c.units;
70      this->type = c.type;
71      return *this;
72    }
73
74    Col::Col(int num, int prec)
75    {
76      /// A specialised constructor that defines one of the default
77      ///  columns, as defined in the Column namespace
78      /// \param num The number of the column to be constructed.
79      ///            Corresponds to the order of the columns in the const
80      ///            arrays in the Column namespace.
81      /// \param prec The precision to use, if not the default. A value
82      /// <0 or no value given results in the default being used.
83
84      if((num>=0)&&(num<numColumns)){
85        this->width     = defaultWidth[num];
86        if(prec<0) this->precision = defaultPrec[num];
87        else this->precision = prec;
88        this->name      = defaultName[num];
89        this->units     = defaultUnits[num];
90        this->type = COLNAME(num);
91      }
92      else{
93        std::stringstream errmsg;
94        errmsg << "Incorrect value for Col(num) --> num="<<num
95               << ", should be between 0 and " << numColumns-1 << ".\n";
96        duchampError("Column constructor", errmsg.str());
97        this->width = 1;
98        this->precision = 0;
99        this->name = " ";
100        this->units = " ";
101        this->type=UNKNOWN;
102      }
103    }
104
105    //------------------------------------------------------------
106    void Col::printTitle(std::ostream &stream)
107    {
108      stream << std::setw(this->width)
109             << std::setfill(' ')
110             << this->name;
111    }
112
113    void Col::printUnits(std::ostream &stream)
114    {
115      stream << std::setw(this->width)
116             << std::setfill(' ')
117             << this->units;
118    }
119 
120    void Col::printDash (std::ostream &stream)
121    {
122      stream << std::setw(this->width)
123             << std::setfill('-')
124             << ""
125             << std::setfill(' ');
126    }
127
128    void Col::printBlank(std::ostream &stream)
129    {
130      stream << std::setw(this->width)
131             << std::setfill(' ')
132             << "";
133    }
134 
135    template <class T> void Col::printEntry(std::ostream &stream, T value)
136    {
137      ///  \param stream Where the printing is done.
138      ///  \param value  The value to be printed.
139
140      stream << std::setprecision(this->precision)
141             << std::setw(this->width)
142             << std::setfill(' ')
143             << value;
144    }
145    template void Col::printEntry<int>(std::ostream &stream, int value);
146    template void Col::printEntry<long>(std::ostream &stream, long value);
147    template void Col::printEntry<unsigned>(std::ostream &stream, unsigned value);
148    template void Col::printEntry<float>(std::ostream &stream, float value);
149    template void Col::printEntry<double>(std::ostream &stream, double value);
150    template void Col::printEntry<std::string>(std::ostream &stream, std::string value);
151
152 
153    bool Col::doCol(std::string tableType, bool flagFint)
154    {
155      ///  @details Uses the info in the isFile etc arrays to
156      ///  determine whether a given column, referenced by the
157      ///  enumeration COLNAME, is used for a given table type.
158      /// \param tableType The type of table: one of file, screen, log, votable.
159      /// \param flagFint Whether to use FINT (true) or FTOT
160      /// (false). This defaults to true, so need not be given. It only
161      /// applies to the screen and votable cases -- both are written for the
162      /// results file case.
163      /// \return True if column is used for given table type. False
164      /// otherwise. False if tableType not one of four listed.
165     
166      if(tableType == "file") return isFile[this->type];
167      else if(tableType == "screen"){
168        if(flagFint && this->type==FTOT) return false;
169        if(!flagFint && this->type==FINT) return false;
170        return isScreen[this->type];
171      }
172      else if(tableType == "log") return isLog[this->type];
173      else if(tableType == "votable"){
174        if(flagFint && this->type==FTOT) return false;
175        if(!flagFint && this->type==FINT) return false;
176        return isVOTable[this->type];
177      }
178      else return false;
179    }
180
181 
182
183    std::vector<Col> getFullColSet(std::vector<Detection> &objectList,
184                                   FitsHeader &head)
185    {
186      ///  @details A function that returns a std::vector of Col
187      ///  objects containing information on the columns necessary for
188      ///  output to the results file:
189      ///    Obj#,NAME,X,Y,Z,RA,DEC,VEL,w_RA,w_DEC,w_VEL,F_tot,F_int,F_peak,
190      ///                X1,X2,Y1,Y2,Z1,Z2,Npix,Flag,
191      ///                XAV,YAV,ZAV,XCENT,YCENT,ZCENT,XPEAK,YPEAK,ZPEAK
192      ///
193      ///   Each object in the provided objectList is checked to see if it
194      ///   requires any column to be widened, or for that column to have
195      ///   its precision increased.
196      ///
197      ///   Both Ftot and Fint are provided -- it is up to the calling
198      ///   function to determine which to use.
199      ///
200      /// \param objectList A std::vector list of Detection objects that the
201      /// columns need to fit.
202      /// \param head The FitsHeader object defining the World Coordinate
203      /// System.
204      /// \return A std::vector list of Col definitions.
205
206      std::vector<Col> newset;
207
208      // desired precisions for fluxes, velocities and SNR value
209      int precVel,precFlux,precSNR;
210      if(objectList.size()>0){
211        precVel=objectList[0].getVelPrec();
212        precFlux=objectList[0].getFpeakPrec(); // same as FintPrec at this point.
213        precSNR=objectList[0].getSNRPrec();
214      }
215      else {
216        precVel = prVEL;
217        precFlux = prFLUX;
218        precSNR = prSNR;
219      }
220
221      // set up the default columns
222      newset.push_back( Col(NUM) );
223      newset.push_back( Col(NAME) );
224      newset.push_back( Col(X) );
225      newset.push_back( Col(Y) );
226      newset.push_back( Col(Z) );
227      newset.push_back( Col(RA) );
228      newset.push_back( Col(DEC) );
229      newset.push_back( Col(RAJD) );
230      newset.push_back( Col(DECJD) );
231      newset.push_back( Col(VEL, precVel) );
232      newset.push_back( Col(WRA) );
233      newset.push_back( Col(WDEC) );
234      newset.push_back( Col(W50, precVel) );
235      newset.push_back( Col(W20, precVel) );
236      newset.push_back( Col(WVEL, precVel) );
237      newset.push_back( Col(FINT, precFlux) );
238      newset.push_back( Col(FTOT, precFlux) );
239      newset.push_back( Col(FPEAK, precFlux) );
240      newset.push_back( Col(SNRPEAK, precSNR) );
241      newset.push_back( Col(X1) );
242      newset.push_back( Col(X2) );
243      newset.push_back( Col(Y1) );
244      newset.push_back( Col(Y2) );
245      newset.push_back( Col(Z1) );
246      newset.push_back( Col(Z2) );
247      newset.push_back( Col(NPIX) );
248      newset.push_back( Col(FLAG) );
249      newset.push_back( Col(XAV) );
250      newset.push_back( Col(YAV) );
251      newset.push_back( Col(ZAV) );
252      newset.push_back( Col(XCENT) );
253      newset.push_back( Col(YCENT) );
254      newset.push_back( Col(ZCENT) );
255      newset.push_back( Col(XPEAK) );
256      newset.push_back( Col(YPEAK) );
257      newset.push_back( Col(ZPEAK) );
258
259
260      // Now test each object against each new column
261      for( int obj = 0; obj < objectList.size(); obj++){
262        std::string tempstr;
263        int tempwidth;
264        float val,minval;
265
266        // Obj#
267        tempwidth = int( log10(objectList[obj].getID()) + 1) + 1;
268        for(int i=newset[NUM].getWidth();i<tempwidth;i++) newset[NUM].widen();
269
270        // Name
271        tempwidth = objectList[obj].getName().size() + 1;
272        for(int i=newset[NAME].getWidth();i<tempwidth;i++) newset[NAME].widen();
273
274        // X position
275        val = objectList[obj].getXcentre() + objectList[obj].getXOffset();
276        if((val<1.)&&(val>0.)){
277          minval = pow(10, -1. * (newset[X].getPrecision()+1));
278          if(val < minval) newset[X].upPrec();
279        }
280        tempwidth = int( log10(val) + 1) + newset[X].getPrecision() + 2;
281        for(int i=newset[X].getWidth();i<tempwidth;i++) newset[X].widen();
282        // Y position
283        val = objectList[obj].getYcentre() + objectList[obj].getYOffset();
284        if((val<1.)&&(val>0.)){
285          minval = pow(10, -1. * (newset[Y].getPrecision()+1));
286          if(val < minval) newset[Y].upPrec();
287        }
288        tempwidth = int( log10(val) + 1) + newset[Y].getPrecision() + 2;
289        for(int i=newset[Y].getWidth();i<tempwidth;i++) newset[Y].widen();
290        // Z position
291        val = objectList[obj].getZcentre() + objectList[obj].getZOffset();
292        if((val<1.)&&(val>0.)){
293          minval = pow(10, -1. * (newset[Z].getPrecision()+1));
294          if((val>0.)&&(val < minval)) newset[Z].upPrec();
295        }
296        tempwidth = int( log10(val) + 1) + newset[Z].getPrecision() + 2;
297        for(int i=newset[Z].getWidth();i<tempwidth;i++) newset[Z].widen();
298
299        if(head.isWCS()){ 
300          // RA -- assign correct title. Check width but should be ok by definition
301          tempstr = head.WCS().lngtyp;
302          newset[RA].setName(tempstr);
303          tempwidth = objectList[obj].getRAs().size() + 1;
304          for(int i=newset[RA].getWidth();i<tempwidth;i++) newset[RA].widen();
305     
306          // Dec -- assign correct title. Check width, should be ok by definition
307          tempstr = head.WCS().lattyp;
308          newset[DEC].setName(tempstr);
309          tempwidth = objectList[obj].getDecs().size() + 1;
310          for(int i=newset[DEC].getWidth();i<tempwidth;i++) newset[DEC].widen();
311
312          // RA decimal degrees -- assign correct title. Check width but should be OK
313          tempstr = head.WCS().lngtyp;
314          newset[RAJD].setName(tempstr);
315          val = objectList[obj].getRA();
316          tempwidth = int( log10(fabs(val)) + 1) + newset[RAJD].getPrecision() + 2;
317          for(int i=newset[RAJD].getWidth();i<tempwidth;i++) newset[RAJD].widen();
318     
319          // Dec decimal degrees -- assign correct title. Check width but should be OK
320          tempstr = head.WCS().lattyp;
321          newset[DECJD].setName(tempstr);
322          val = objectList[obj].getDec();
323          tempwidth = int( log10(fabs(val)) + 1) + newset[DECJD].getPrecision() + 2;
324          for(int i=newset[DECJD].getWidth();i<tempwidth;i++) newset[DECJD].widen();
325
326          // Vel -- check width, title and units.
327          //if(head.isSpecOK()){
328          if(head.canUseThirdAxis()){
329            if(head.WCS().spec < 0)  // if it's not a spectral axis
330              newset[VEL].setName( head.WCS().ctype[2] );
331//          else if(head.WCS().restfrq == 0) // using frequency, not velocity
332            else if(head.getSpectralDescription()==duchamp::duchampSpectralDescription[FREQUENCY]) // using frequency, not velocity
333              newset[VEL].setName("FREQ");
334            if(head.getSpectralUnits().size()>0)
335              newset[VEL].setUnits("[" + head.getSpectralUnits() + "]");
336            tempwidth = newset[VEL].getUnits().size() + 1;
337            for(int i=newset[VEL].getWidth();i<tempwidth;i++) newset[VEL].widen();
338       
339            val = objectList[obj].getVel();
340            if((fabs(val) < 1.)&&(val>0.)){
341              minval = pow(10, -1. * (newset[VEL].getPrecision()+1));
342              if(val < minval) newset[VEL].upPrec();
343            }
344            tempwidth = int(log10(fabs(val)) + 1) + newset[VEL].getPrecision() + 2;
345            if(val<0) tempwidth++;
346            for(int i=newset[VEL].getWidth();i<tempwidth;i++) newset[VEL].widen();
347          }
348
349          // w_RA -- check width & title. leave units for the moment.
350          tempwidth = newset[RA].getUnits().size() + 1;
351          for(int i=newset[RA].getWidth();i<tempwidth;i++) newset[RA].widen();
352          val = objectList[obj].getRAWidth();
353          if((fabs(val) < 1.)&&(val>0.)){
354            minval = pow(10, -1. * (newset[WRA].getPrecision()+1));
355            if(val < minval) newset[WRA].upPrec();
356          }
357          tempwidth = int( log10(fabs(val)) + 1) + newset[WRA].getPrecision() + 2;
358          if(val<0) tempwidth++;
359          for(int i=newset[WRA].getWidth();i<tempwidth;i++) newset[WRA].widen();
360
361          // w_DEC -- check width & title. leave units for the moment.
362          tempwidth = newset[DEC].getUnits().size() + 1;
363          for(int i=newset[DEC].getWidth();i<tempwidth;i++) newset[DEC].widen();
364          val = objectList[obj].getDecWidth();
365          if((fabs(val) < 1.)&&(val>0.)){
366            minval = pow(10, -1. * (newset[WDEC].getPrecision()+1));
367            if(val < minval) newset[WDEC].upPrec();
368          }
369          tempwidth = int( log10(fabs(val)) + 1) + newset[WDEC].getPrecision() + 2;
370          if(val<0) tempwidth++;
371          for(int i=newset[WDEC].getWidth();i<tempwidth;i++) newset[WDEC].widen();
372
373          // w_50 -- check width, title and units.
374          if(head.canUseThirdAxis()){
375            if(head.getSpectralUnits().size()>0)
376              newset[W50].setUnits("[" + head.getSpectralUnits() + "]");
377            tempwidth = newset[W50].getUnits().size() + 1;
378            for(int i=newset[W50].getWidth();i<tempwidth;i++) newset[W50].widen();
379            val = objectList[obj].getW50();
380            if((fabs(val) < 1.)&&(val>0.)){
381              minval = pow(10, -1. * (newset[W50].getPrecision()+1));
382              if(val < minval) newset[W50].upPrec();
383            }
384            tempwidth = int( log10(fabs(val)) + 1) + newset[W50].getPrecision() + 2;
385            if(val<0) tempwidth++;
386            for(int i=newset[W50].getWidth();i<tempwidth;i++) newset[W50].widen();
387          }
388
389          // w_20 -- check width, title and units.
390          if(head.canUseThirdAxis()){
391            if(head.getSpectralUnits().size()>0)
392              newset[W20].setUnits("[" + head.getSpectralUnits() + "]");
393            tempwidth = newset[W20].getUnits().size() + 1;
394            for(int i=newset[W20].getWidth();i<tempwidth;i++)newset[W20].widen();
395            val = objectList[obj].getW20();
396            if((fabs(val) < 1.)&&(val>0.)){
397              minval = pow(10, -1. * (newset[W20].getPrecision()+1));
398              if(val < minval) newset[W20].upPrec();
399            }
400            tempwidth = int( log10(fabs(val)) + 1) + newset[W20].getPrecision() + 2;
401            if(val<0) tempwidth++;
402            for(int i=newset[W20].getWidth();i<tempwidth;i++) newset[W20].widen();
403          }
404
405          // w_Vel -- check width, title and units.
406          if(head.canUseThirdAxis()){
407            if(head.WCS().spec < 0) // if it's not a spectral axis
408              newset[WVEL].setName( std::string("w_") + head.WCS().ctype[2] );
409//          else if(head.WCS().restfrq == 0) // using frequency, not velocity
410            else if(head.getSpectralDescription()==duchamp::duchampSpectralDescription[FREQUENCY]) // using frequency, not velocity
411              newset[WVEL].setName("w_FREQ");
412            if(head.getSpectralUnits().size()>0)
413              newset[WVEL].setUnits("[" + head.getSpectralUnits() + "]");
414            tempwidth = newset[WVEL].getUnits().size() + 1;
415            for(int i=newset[WVEL].getWidth();i<tempwidth;i++)newset[WVEL].widen();
416            tempwidth = newset[WVEL].getName().size() + 1;
417            for(int i=newset[WVEL].getWidth();i<tempwidth;i++) newset[WVEL].widen();
418            val = objectList[obj].getVelWidth();
419            if((fabs(val) < 1.)&&(val>0.)){
420              minval = pow(10, -1. * (newset[WVEL].getPrecision()+1));
421              if(val < minval) newset[WVEL].upPrec();
422            }
423            tempwidth = int( log10(fabs(val)) + 1) + newset[WVEL].getPrecision() + 2;
424            if(val<0) tempwidth++;
425            for(int i=newset[WVEL].getWidth();i<tempwidth;i++) newset[WVEL].widen();
426          }
427
428          // F_int -- check width & units
429          if(head.getIntFluxUnits().size()>0)
430            newset[FINT].setUnits("[" + head.getIntFluxUnits() + "]");
431          tempwidth = newset[FINT].getUnits().size() + 1;
432          for(int i=newset[FINT].getWidth();i<tempwidth;i++) newset[FINT].widen();
433          val = objectList[obj].getIntegFlux();
434          if((fabs(val) < 1.)// &&(val>0.)
435             ){
436            int minprec = int(fabs(log10(fabs(val))))+2;
437            for(int i=newset[FINT].getPrecision();i<minprec;i++) newset[FINT].upPrec();
438          }
439          tempwidth = int( log10(fabs(val)) + 1) + newset[FINT].getPrecision() + 2;
440          if(val<0) tempwidth++;
441          for(int i=newset[FINT].getWidth();i<tempwidth;i++) newset[FINT].widen();
442     
443        }
444
445        // F_tot
446        newset[FTOT].setUnits("[" + head.getFluxUnits() + "]");
447        tempwidth = newset[FTOT].getUnits().size() + 1;
448        for(int i=newset[FTOT].getWidth();i<tempwidth;i++) newset[FTOT].widen();
449        val = objectList[obj].getTotalFlux();
450        //     std::cerr << val << "\n";
451        if((fabs(val) < 1.)// &&(val>0.)
452           ){
453          int minprec = int(fabs(log10(fabs(val))))+2;
454          for(int i=newset[FTOT].getPrecision();i<minprec;i++) newset[FTOT].upPrec();
455        }
456        tempwidth = int( log10(fabs(val)) + 1) + newset[FTOT].getPrecision() + 2;
457        if(val<0) tempwidth++;
458        for(int i=newset[FTOT].getWidth();i<tempwidth;i++) newset[FTOT].widen();
459
460        // F_peak
461        newset[FPEAK].setUnits("[" + head.getFluxUnits() + "]");
462        tempwidth = newset[FPEAK].getUnits().size() + 1;
463        for(int i=newset[FPEAK].getWidth();i<tempwidth;i++) newset[FPEAK].widen();
464        val = objectList[obj].getPeakFlux();
465        if((fabs(val) < 1.)// &&(val>0.)
466           ){
467          int minprec = int(fabs(log10(fabs(val))))+2;
468          for(int i=newset[FPEAK].getPrecision();i<minprec;i++) newset[FPEAK].upPrec();
469        }
470        tempwidth = int( log10(fabs(val)) + 1) + newset[FPEAK].getPrecision() + 2;
471        if(val<0) tempwidth++;
472        for(int i=newset[FPEAK].getWidth();i<tempwidth;i++) newset[FPEAK].widen();
473
474        // S/N_peak
475        val = objectList[obj].getPeakSNR();
476        if((fabs(val) < 1.)&&(val>0.)){
477          minval = pow(10, -1. * (newset[SNRPEAK].getPrecision()+1));
478          if(val < minval) newset[SNRPEAK].upPrec();
479        }
480        tempwidth = int( log10(fabs(val)) + 1) + newset[SNRPEAK].getPrecision() +2;
481        if(val<0) tempwidth++;
482        for(int i=newset[SNRPEAK].getWidth();i<tempwidth;i++) newset[SNRPEAK].widen();
483
484        // X1 position
485        val = objectList[obj].getXmin() + objectList[obj].getXOffset();
486        tempwidth = int( log10(val) + 1) + newset[X1].getPrecision() + 1;
487        for(int i=newset[X1].getWidth();i<tempwidth;i++) newset[X1].widen();
488        // X2 position
489        val = objectList[obj].getXmax() + objectList[obj].getXOffset();
490        tempwidth = int( log10(val) + 1) + newset[X2].getPrecision() + 1;
491        for(int i=newset[X2].getWidth();i<tempwidth;i++) newset[X2].widen();
492        // Y1 position
493        val = objectList[obj].getYmin() + objectList[obj].getYOffset();
494        tempwidth = int( log10(val) + 1) + newset[Y1].getPrecision() + 1;
495        for(int i=newset[Y1].getWidth();i<tempwidth;i++) newset[Y1].widen();
496        // Y2 position
497        val = objectList[obj].getYmax() + objectList[obj].getYOffset();
498        tempwidth = int( log10(val) + 1) + newset[Y2].getPrecision() + 1;
499        for(int i=newset[Y2].getWidth();i<tempwidth;i++) newset[Y2].widen();
500        // Z1 position
501        val = objectList[obj].getZmin() + objectList[obj].getZOffset();
502        tempwidth = int( log10(val) + 1) + newset[Z1].getPrecision() + 1;
503        for(int i=newset[Z1].getWidth();i<tempwidth;i++) newset[Z1].widen();
504        // Z2 position
505        val = objectList[obj].getZmax() + objectList[obj].getZOffset();
506        tempwidth = int( log10(val) + 1) + newset[Z2].getPrecision() + 1;
507        for(int i=newset[Z2].getWidth();i<tempwidth;i++) newset[Z2].widen();
508
509        // Npix
510        tempwidth = int( log10(objectList[obj].getSize()) + 1) +
511          newset[NPIX].getPrecision() + 1;
512        for(int i=newset[NPIX].getWidth();i<tempwidth;i++) newset[NPIX].widen();
513   
514        // average X position
515        val = objectList[obj].getXAverage() + objectList[obj].getXOffset();
516        if((val<1.)&&(val>0.)){
517          minval = pow(10, -1. * (newset[XAV].getPrecision()+1));
518          if(val < minval) newset[XAV].upPrec();
519        }
520        tempwidth = int( log10(val) + 1) + newset[XAV].getPrecision() + 2;
521        for(int i=newset[XAV].getWidth();i<tempwidth;i++) newset[XAV].widen();
522        // average Y position
523        val = objectList[obj].getYAverage() + objectList[obj].getYOffset();
524        if((val<1.)&&(val>0.)){
525          minval = pow(10, -1. * (newset[YAV].getPrecision()+1));
526          if(val < minval) newset[YAV].upPrec();
527        }
528        tempwidth = int( log10(val) + 1) + newset[YAV].getPrecision() + 2;
529        for(int i=newset[YAV].getWidth();i<tempwidth;i++) newset[YAV].widen();
530        // average Z position
531        val = objectList[obj].getZAverage() + objectList[obj].getZOffset();
532        if((val<1.)&&(val>0.)){
533          minval = pow(10, -1. * (newset[ZAV].getPrecision()+1));
534          if((val>0.)&&(val < minval)) newset[ZAV].upPrec();
535        }
536        tempwidth = int( log10(val) + 1) + newset[ZAV].getPrecision() + 2;
537        for(int i=newset[ZAV].getWidth();i<tempwidth;i++) newset[ZAV].widen();
538   
539        // X position of centroid
540        val = objectList[obj].getXCentroid() + objectList[obj].getXOffset();
541        if((val<1.)&&(val>0.)){
542          minval = pow(10, -1. * (newset[XCENT].getPrecision()+1));
543          if(val < minval) newset[XCENT].upPrec();
544        }
545        tempwidth = int( log10(val) + 1) + newset[XCENT].getPrecision() + 2;
546        for(int i=newset[XCENT].getWidth();i<tempwidth;i++) newset[XCENT].widen();
547        // Y position of centroid
548        val = objectList[obj].getYCentroid() + objectList[obj].getYOffset();
549        if((val<1.)&&(val>0.)){
550          minval = pow(10, -1. * (newset[YCENT].getPrecision()+1));
551          if(val < minval) newset[YCENT].upPrec();
552        }
553        tempwidth = int( log10(val) + 1) + newset[YCENT].getPrecision() + 2;
554        for(int i=newset[YCENT].getWidth();i<tempwidth;i++) newset[YCENT].widen();
555        // Z position of centroid
556        val = objectList[obj].getZCentroid() + objectList[obj].getZOffset();
557        if((val<1.)&&(val>0.)){
558          minval = pow(10, -1. * (newset[ZCENT].getPrecision()+1));
559          if((val>0.)&&(val < minval)) newset[ZCENT].upPrec();
560        }
561        tempwidth = int( log10(val) + 1) + newset[ZCENT].getPrecision() + 2;
562        for(int i=newset[ZCENT].getWidth();i<tempwidth;i++) newset[ZCENT].widen();
563   
564        // X position of peak flux
565        val = objectList[obj].getXPeak() + objectList[obj].getXOffset();
566        if((val<1.)&&(val>0.)){
567          minval = pow(10, -1. * (newset[XPEAK].getPrecision()+1));
568          if(val < minval) newset[XPEAK].upPrec();
569        }
570        tempwidth = int( log10(val) + 1) + newset[XPEAK].getPrecision() + 2;
571        for(int i=newset[XPEAK].getWidth();i<tempwidth;i++) newset[XPEAK].widen();
572        // Y position of peak flux
573        val = objectList[obj].getYPeak() + objectList[obj].getYOffset();
574        if((val<1.)&&(val>0.)){
575          minval = pow(10, -1. * (newset[YPEAK].getPrecision()+1));
576          if(val < minval) newset[YPEAK].upPrec();
577        }
578        tempwidth = int( log10(val) + 1) + newset[YPEAK].getPrecision() + 2;
579        for(int i=newset[YPEAK].getWidth();i<tempwidth;i++) newset[YPEAK].widen();
580        // Z position of peak flux
581        val = objectList[obj].getZPeak() + objectList[obj].getZOffset();
582        if((val<1.)&&(val>0.)){
583          minval = pow(10, -1. * (newset[ZPEAK].getPrecision()+1));
584          if((val>0.)&&(val < minval)) newset[ZPEAK].upPrec();
585        }
586        tempwidth = int( log10(val) + 1) + newset[ZPEAK].getPrecision() + 2;
587        for(int i=newset[ZPEAK].getWidth();i<tempwidth;i++) newset[ZPEAK].widen();
588      }
589
590      return newset;
591
592    }
593
594    std::vector<Col> getLogColSet(std::vector<Detection> &objectList,
595                                  FitsHeader &head)
596    {
597      ///  @details A function that returns a std::vector of Col
598      ///    objects containing information on the columns necessary
599      ///    for logfile output:
600      ///    Obj#,X,Y,Z,F_tot,F_peak,X1,X2,Y1,Y2,Z1,Z2,Npix
601      ///
602      ///   Each object in the provided objectList is checked to see if
603      ///    it requires any column to be widened, or for that column to
604      ///    have its precision increased.
605      ///
606      /// \param objectList A std::vector list of Detection objects that the columns need to fit.
607      /// \param head The FitsHeader object defining the World Coordinate System.
608      /// \return A std::vector list of Col definitions.
609
610      std::vector<Col> newset,tempset;
611 
612      // set up the default columns:
613      //  get from FullColSet, and select only the ones we want.
614      tempset = getFullColSet(objectList,head);
615
616      newset.push_back( tempset[NUM] );
617      newset.push_back( tempset[X] );
618      newset.push_back( tempset[Y] );
619      newset.push_back( tempset[Z] );
620      newset.push_back( tempset[FTOT] );
621      newset.push_back( tempset[FPEAK] );
622      newset.push_back( tempset[SNRPEAK] );
623      newset.push_back( tempset[X1] );
624      newset.push_back( tempset[X2] );
625      newset.push_back( tempset[Y1] );
626      newset.push_back( tempset[Y2] );
627      newset.push_back( tempset[Z1] );
628      newset.push_back( tempset[Z2] );
629      newset.push_back( tempset[NPIX] );
630
631      return newset;
632
633    }
634
635  }
636
637}
Note: See TracBrowser for help on using the repository browser.