source: tags/release-1.1.4/src/Detection/columns.hh @ 1441

Last change on this file since 1441 was 378, checked in by MatthewWhiting, 17 years ago

Large amount of changes, but really just making a "duchamp" namespace to encompass duchamp-specific stuff. Not the PixelMap? stuff though.

File size: 6.5 KB
Line 
1// -----------------------------------------------------------------------
2// columns.hh: Define the column class that formats 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#ifndef COLUMNS_H
29#define COLUMNS_H
30
31#include <iostream>
32#include <iomanip>
33#include <string>
34#include <vector>
35
36namespace duchamp
37{
38
39  class Detection;
40  class FitsHeader;
41
42  /**
43   * A namespace controlling the formatting of columns of output for Duchamp.
44   */
45
46  namespace Column
47  {
48    // First, define some basic quantities.
49    // The default values for the columns, and default values for
50    //  the precision of different types of columns.
51
52    /** Total number of columns being considered.*/
53    const int numColumns=32;   
54    /** Enumerated column titles */
55    enum COLNAME {NUM=0, NAME, X, Y, Z,
56                  RA, DEC, VEL,
57                  WRA, WDEC, WVEL,
58                  FINT, FTOT, FPEAK, SNRPEAK,
59                  X1, X2, Y1, Y2, Z1, Z2, NPIX, FLAG,
60                  XAV, YAV, ZAV, XCENT, YCENT, ZCENT,
61                  XPEAK, YPEAK, ZPEAK};
62
63    /** Total number of columns used in logfile (no WCS ones). */
64    const int numColumnsLog=14;
65    /** Enumerated column titles for logfile*/
66    enum LOGNAME {lNUM=0, lX, lY, lZ,
67                  lFTOT, lFPEAK, lSNRPEAK,
68                  lX1, lX2, lY1, lY2, lZ1, lZ2, lNPIX};
69
70    /** Number of types of precision. */
71    const int numPrec=6;       
72    /** Enumerated precision categories */
73    enum PrecType {prFLUX=0, prVEL, prXYZ, prPOS, prWPOS, prSNR};
74
75    /** Precision values in same order as enum list.*/
76    const int prec[numPrec]={3, 3, 1, 6, 2, 2};
77
78    /** Default widths of all columns.*/
79    const int defaultWidth[numColumns]=
80      {5, 8, 6, 6, 6,
81       13, 13, 7, 9, 9, 7,
82       10, 10, 9, 7,
83       4, 4, 4, 4, 4, 4, 6, 5,
84       6, 6, 6, 7, 7, 7, 7, 7, 7};
85
86    /** Default precisions for all columns.*/
87    const int defaultPrec[numColumns]=
88      {0, 0, prec[prXYZ], prec[prXYZ], prec[prXYZ],
89       0, 0, prec[prVEL],
90       prec[prWPOS], prec[prWPOS], prec[prVEL],
91       prec[prFLUX], prec[prFLUX], prec[prFLUX],
92       prec[prSNR], 0, 0, 0, 0, 0, 0, 0, 0,
93       prec[prXYZ], prec[prXYZ], prec[prXYZ],
94       prec[prXYZ], prec[prXYZ], prec[prXYZ],
95       prec[prXYZ], prec[prXYZ], prec[prXYZ]};
96
97    /** Default Titles of all columns. */
98    const std::string defaultName[numColumns]=
99      {"Obj#","Name","X","Y","Z",
100       "RA","DEC","VEL",
101       "w_RA","w_DEC","w_VEL",
102       "F_int","F_tot","F_peak", "S/Nmax",
103       "X1","X2","Y1","Y2","Z1","Z2","Npix","Flag",
104       "X_av", "Y_av", "Z_av", "X_cent", "Y_cent", "Z_cent",
105       "X_peak", "Y_peak", "Z_peak"};
106
107    /** Default units of all columns. */
108    const std::string defaultUnits[numColumns]=
109      {"","","","","",
110       "","","",
111       "[arcmin]","[arcmin]","",
112       "","","", "",
113       "","","","","","","[pix]","",
114       "","","","","","","","",""};
115
116
117    /** Class to store information about a single column.
118     * This contains information about a given column -- its width, the
119     *  precision associated with it, its title and the units.
120     * Plus the usual array of accessor functions and so on.
121     */
122    class Col{
123    public:
124      Col();          ///< Basic constructor
125      Col(int num);   ///< Specific constructor
126      Col(const Col& c);///< Assignment constructor
127      Col& operator=(const Col& c); ///< Copy constructor
128      virtual ~Col(); ///< Default destructor;
129      //--------------
130      // basic accessor functions
131      //
132      int    getWidth(){return width;};         
133      void   setWidth(int i){width=i;};   
134      int    getPrecision(){return precision;};     
135      void   setPrecision(int i){precision=i;};
136      std::string getName(){return name;};         
137      void   setName(std::string s){name=s;}; 
138      std::string getUnits(){return units;};         
139      void   setUnits(std::string s){units=s;};
140
141      //--------------
142      // other functions
143      //
144      /** Make the column one space wider. */
145      void   widen(){width++;};
146
147      /** Increase the precision by one, widening the column if necessary. */
148      void   upPrec(){precision++; width++;};
149
150      //--------------
151      // Outputting functions -- all in columns.cc
152      //
153      /** write the title of the column to the stream */
154      void   printTitle(std::ostream &stream);
155
156      /** write the units of the column to the stream */
157      void   printUnits(std::ostream &stream);
158
159      /** write dashes the full width of the column to the stream */
160      void   printDash (std::ostream &stream);
161
162      /** write blanks the full width of the column to the stream */
163      void   printBlank(std::ostream &stream);
164
165      /** Print a given value in a column with correct width & precision. */
166      template <class T> void printEntry(std::ostream &stream, T value);
167
168    private:
169      int width;          ///< How wide is the column (in ascii spaces)
170      int precision;      ///< What precision should be used to print
171      ///   the values? (If 0, the setprecision command
172      ///   is not used.)
173      std::string name;   ///< The title of the column
174      std::string units;  ///< The units that the values in the column
175      ///   are expressed in.
176    };
177
178 
179    /** Returns a vector of Col for results file output.*/
180    std::vector<Column::Col> getFullColSet(std::vector<Detection> &objectList,
181                                           FitsHeader &head);
182
183    /** Returns a vector of Col for logfile output.*/
184    std::vector<Column::Col> getLogColSet(std::vector<Detection> &objectList,
185                                          FitsHeader &head);
186
187  }
188
189}
190
191#endif
192
Note: See TracBrowser for help on using the repository browser.