source: tags/release-1.1.5/src/Detection/columns.cc @ 1441

Last change on this file since 1441 was 454, checked in by MatthewWhiting, 16 years ago

Trying to fix a niggling bug in the Obj# column.

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