source: trunk/src/Detection/columns.hh @ 528

Last change on this file since 528 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: 8.4 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  /// A namespace controlling the formatting of columns of output for Duchamp.
43
44  namespace Column
45  {
46    // First, define some basic quantities.
47    // The default values for the columns, and default values for
48    //  the precision of different types of columns.
49
50    /// @brief Total number of columns being considered.
51    const int numColumns=36;   
52    /// @brief Enumerated column titles
53    enum COLNAME {NUM=0, NAME, X, Y, Z,
54                  RA, DEC, RAJD, DECJD, VEL,
55                  WRA, WDEC, W50, W20, WVEL,
56                  FINT, FTOT, FPEAK, SNRPEAK,
57                  X1, X2, Y1, Y2, Z1, Z2, NPIX, FLAG,
58                  XAV, YAV, ZAV, XCENT, YCENT, ZCENT,
59                  XPEAK, YPEAK, ZPEAK,
60                  UNKNOWN};  // the last is for unclassified columns
61
62    /// @brief Guide for which columns are used for the results file
63    const bool isFile[numColumns+1]=
64      {true,true,true,true,true,
65       true,true,false,false,true,
66       true,true,true,true,true,
67       true,true,true,true,
68       true,true,true,true,true,true,true,true,
69       true,true,true,true,true,true,
70       true,true,true,
71       false};
72
73    /// @brief Guide for which columns are used for the results printed to screen
74    const bool isScreen[numColumns+1]=
75      {true,true,true,true,true,
76       true,true,false,false,true,
77       true,true,true,false,false,
78       true,true,true,true,
79       true,true,true,true,true,true,true,true,
80       false,false,false,false,false,false,
81       false,false,false,
82       false};
83
84    /// @brief Guide for which columns are used for the log file
85    const bool isLog[numColumns+1]=
86      {true,false,true,true,true,
87       false,false,false,false,false,
88       false,false,false,false,false,
89       false,true,true,true,
90       true,true,true,true,true,true,true,false,
91       false,false,false,false,false,false,
92       false,false,false,
93       false};
94
95     /// @brief Guide for which columns are used for the VOTable file
96    const bool isVOTable[numColumns+1]=
97      {true,true,false,false,false,
98       false,false,true,true,true,
99       true,true,true,true,true,
100       true,true,true,true,
101       false,false,false,false,false,false,false,true,
102       true,true,true,true,true,true,
103       true,true,true,
104       false};
105
106    /// @brief Total number of columns used in logfile (no WCS ones).
107    const int numColumnsLog=14;
108    /// @brief Enumerated column titles for logfile
109    enum LOGNAME {lNUM=0, lX, lY, lZ,
110                  lFTOT, lFPEAK, lSNRPEAK,
111                  lX1, lX2, lY1, lY2, lZ1, lZ2, lNPIX};
112
113    /// @brief Number of types of precision.
114    const int numPrec=6;       
115    /// @brief Enumerated precision categories
116    enum PrecType {prFLUX=3, prVEL=3, prXYZ=1, prPOS=6, prWPOS=2, prSNR=2};
117
118    /// @brief Default widths of all columns.
119    const int defaultWidth[numColumns+1]=
120      {5, 8, 6, 6, 6,
121       13, 13, 11, 11, 7,
122       9, 9, 7, 7, 7,
123       10, 10, 9, 7,
124       4, 4, 4, 4, 4, 4, 6, 5,
125       6, 6, 6, 7, 7, 7,
126       7, 7, 7,
127       1};
128
129    /// @brief Default precisions for all columns.
130    const int defaultPrec[numColumns+1]=
131      {0, 0, prXYZ, prXYZ, prXYZ,
132       0, 0, prPOS, prPOS, prVEL,
133       prWPOS, prWPOS, prVEL, prVEL, prVEL,
134       prFLUX, prFLUX, prFLUX,
135       prSNR, 0, 0, 0, 0, 0, 0, 0, 0,
136       prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ,
137       prXYZ, prXYZ, prXYZ,
138       0};
139
140    /// @brief Default Titles of all columns.
141    const std::string defaultName[numColumns+1]=
142      {"Obj#","Name","X","Y","Z",
143       "RA","DEC","RAJD","DECJD","VEL",
144       "w_RA","w_DEC","w_50","w_20","w_VEL",
145       "F_int","F_tot","F_peak", "S/Nmax",
146       "X1","X2","Y1","Y2","Z1","Z2","Npix","Flag",
147       "X_av", "Y_av", "Z_av", "X_cent", "Y_cent", "Z_cent",
148       "X_peak", "Y_peak", "Z_peak",
149       " "};
150
151    /// @brief Default units of all columns.
152    const std::string defaultUnits[numColumns+1]=
153      {"","","","","",
154       "","","[deg]","[deg]","",
155       "[arcmin]","[arcmin]","","","",
156       "","","", "",
157       "","","","","","","[pix]","",
158       "","","","","","","","","",
159       ""};
160
161
162    ///  @brief Class to store information about a single column.
163    ///
164    ///  @details This contains information about a given column --
165    ///  its width, the precision associated with it, its title and
166    ///  the units.  Plus the usual array of accessor functions and so
167    ///  on.
168
169    class Col{
170    public:
171      Col();          ///< Basic constructor
172      Col(int num, int prec=-1);   ///< Specific constructor
173      Col(const Col& c);///< Assignment constructor
174      Col& operator=(const Col& c); ///< Copy constructor
175      virtual ~Col(); ///< Default destructor;
176      //--------------
177      // basic accessor functions
178      //
179      int    getWidth(){return width;};         
180      void   setWidth(int i){width=i;};   
181      int    getPrecision(){return precision;};     
182      void   setPrecision(int i){precision=i;};
183      std::string getName(){return name;};         
184      void   setName(std::string s){name=s;}; 
185      std::string getUnits(){return units;};         
186      void   setUnits(std::string s){units=s;};
187      COLNAME getType(){return type;};
188      void   setType(COLNAME coltype){type=coltype;};
189
190      //--------------
191      // other functions
192      //
193      /// @brief Make the column one space wider.
194      void   widen(){width++;};
195
196      /// @brief Increase the precision by one, widening the column if necessary.
197      void   upPrec(){precision++; width++;};
198
199      //--------------
200      // Outputting functions -- all in columns.cc
201      //
202      /// @brief write the title of the column to the stream
203      void   printTitle(std::ostream &stream);
204
205      /// @brief write the units of the column to the stream
206      void   printUnits(std::ostream &stream);
207
208      /// @brief write dashes the full width of the column to the stream
209      void   printDash (std::ostream &stream);
210
211      /// @brief write blanks the full width of the column to the stream
212      void   printBlank(std::ostream &stream);
213
214      /// @brief Print a given value in a column with correct width & precision.
215      template <class T> void printEntry(std::ostream &stream, T value);
216
217      /// @brief Decides whether the column is used for a given table type
218      bool   doCol(std::string type, bool flagFint=true);
219
220
221    private:
222      int width;          ///< How wide is the column (in ascii spaces)
223      int precision;      ///< What precision should be used to print the values? (If 0, the setprecision command is not used.)
224      std::string name;   ///< The title of the column
225      std::string units;  ///< The units that the values in the column are expressed in.
226      COLNAME type;       ///< The type of the column
227    };
228
229 
230    /// @brief Returns a vector of Col for results file output.
231    std::vector<Column::Col> getFullColSet(std::vector<Detection> &objectList,
232                                           FitsHeader &head);
233
234    /// @brief Returns a vector of Col for logfile output.
235    std::vector<Column::Col> getLogColSet(std::vector<Detection> &objectList,
236                                          FitsHeader &head);
237
238  }
239
240}
241
242#endif
243
Note: See TracBrowser for help on using the repository browser.