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
RevLine 
[300]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// -----------------------------------------------------------------------
[93]28#ifndef COLUMNS_H
29#define COLUMNS_H
30
31#include <iostream>
32#include <iomanip>
33#include <string>
34#include <vector>
35
[378]36namespace duchamp
37{
[144]38
[378]39  class Detection;
40  class FitsHeader;
[222]41
[528]42  /// A namespace controlling the formatting of columns of output for Duchamp.
[93]43
[378]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.
[144]49
[528]50    /// @brief Total number of columns being considered.
[463]51    const int numColumns=36;   
[528]52    /// @brief Enumerated column titles
[378]53    enum COLNAME {NUM=0, NAME, X, Y, Z,
[439]54                  RA, DEC, RAJD, DECJD, VEL,
[463]55                  WRA, WDEC, W50, W20, WVEL,
[378]56                  FINT, FTOT, FPEAK, SNRPEAK,
57                  X1, X2, Y1, Y2, Z1, Z2, NPIX, FLAG,
58                  XAV, YAV, ZAV, XCENT, YCENT, ZCENT,
[440]59                  XPEAK, YPEAK, ZPEAK,
60                  UNKNOWN};  // the last is for unclassified columns
[144]61
[528]62    /// @brief Guide for which columns are used for the results file
[440]63    const bool isFile[numColumns+1]=
[439]64      {true,true,true,true,true,
65       true,true,false,false,true,
[463]66       true,true,true,true,true,
[439]67       true,true,true,true,
68       true,true,true,true,true,true,true,true,
69       true,true,true,true,true,true,
[440]70       true,true,true,
71       false};
[439]72
[528]73    /// @brief Guide for which columns are used for the results printed to screen
[440]74    const bool isScreen[numColumns+1]=
[439]75      {true,true,true,true,true,
76       true,true,false,false,true,
[463]77       true,true,true,false,false,
[439]78       true,true,true,true,
79       true,true,true,true,true,true,true,true,
80       false,false,false,false,false,false,
[440]81       false,false,false,
82       false};
[439]83
[528]84    /// @brief Guide for which columns are used for the log file
[440]85    const bool isLog[numColumns+1]=
[439]86      {true,false,true,true,true,
87       false,false,false,false,false,
[463]88       false,false,false,false,false,
[439]89       false,true,true,true,
90       true,true,true,true,true,true,true,false,
91       false,false,false,false,false,false,
[440]92       false,false,false,
93       false};
[439]94
[528]95     /// @brief Guide for which columns are used for the VOTable file
[440]96    const bool isVOTable[numColumns+1]=
[439]97      {true,true,false,false,false,
98       false,false,true,true,true,
[463]99       true,true,true,true,true,
[439]100       true,true,true,true,
101       false,false,false,false,false,false,false,true,
102       true,true,true,true,true,true,
[440]103       true,true,true,
104       false};
[439]105
[528]106    /// @brief Total number of columns used in logfile (no WCS ones).
[378]107    const int numColumnsLog=14;
[528]108    /// @brief Enumerated column titles for logfile
[378]109    enum LOGNAME {lNUM=0, lX, lY, lZ,
110                  lFTOT, lFPEAK, lSNRPEAK,
111                  lX1, lX2, lY1, lY2, lZ1, lZ2, lNPIX};
[221]112
[528]113    /// @brief Number of types of precision.
[378]114    const int numPrec=6;       
[528]115    /// @brief Enumerated precision categories
[439]116    enum PrecType {prFLUX=3, prVEL=3, prXYZ=1, prPOS=6, prWPOS=2, prSNR=2};
[221]117
[528]118    /// @brief Default widths of all columns.
[440]119    const int defaultWidth[numColumns+1]=
[378]120      {5, 8, 6, 6, 6,
[463]121       13, 13, 11, 11, 7,
122       9, 9, 7, 7, 7,
[378]123       10, 10, 9, 7,
124       4, 4, 4, 4, 4, 4, 6, 5,
[463]125       6, 6, 6, 7, 7, 7,
126       7, 7, 7,
[440]127       1};
[265]128
[528]129    /// @brief Default precisions for all columns.
[440]130    const int defaultPrec[numColumns+1]=
[439]131      {0, 0, prXYZ, prXYZ, prXYZ,
132       0, 0, prPOS, prPOS, prVEL,
[463]133       prWPOS, prWPOS, prVEL, prVEL, prVEL,
[439]134       prFLUX, prFLUX, prFLUX,
135       prSNR, 0, 0, 0, 0, 0, 0, 0, 0,
[463]136       prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ,
[440]137       prXYZ, prXYZ, prXYZ,
138       0};
[265]139
[528]140    /// @brief Default Titles of all columns.
[440]141    const std::string defaultName[numColumns+1]=
[378]142      {"Obj#","Name","X","Y","Z",
[439]143       "RA","DEC","RAJD","DECJD","VEL",
[463]144       "w_RA","w_DEC","w_50","w_20","w_VEL",
[378]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",
[440]148       "X_peak", "Y_peak", "Z_peak",
149       " "};
[144]150
[528]151    /// @brief Default units of all columns.
[440]152    const std::string defaultUnits[numColumns+1]=
[378]153      {"","","","","",
[439]154       "","","[deg]","[deg]","",
[463]155       "[arcmin]","[arcmin]","","","",
[378]156       "","","", "",
157       "","","","","","","[pix]","",
[440]158       "","","","","","","","","",
159       ""};
[144]160
[222]161
[528]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
[378]169    class Col{
170    public:
171      Col();          ///< Basic constructor
[438]172      Col(int num, int prec=-1);   ///< Specific constructor
[378]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;};
[440]187      COLNAME getType(){return type;};
188      void   setType(COLNAME coltype){type=coltype;};
[93]189
[378]190      //--------------
191      // other functions
192      //
[528]193      /// @brief Make the column one space wider.
[378]194      void   widen(){width++;};
[222]195
[528]196      /// @brief Increase the precision by one, widening the column if necessary.
[378]197      void   upPrec(){precision++; width++;};
[222]198
[378]199      //--------------
200      // Outputting functions -- all in columns.cc
201      //
[528]202      /// @brief write the title of the column to the stream
[378]203      void   printTitle(std::ostream &stream);
[222]204
[528]205      /// @brief write the units of the column to the stream
[378]206      void   printUnits(std::ostream &stream);
[222]207
[528]208      /// @brief write dashes the full width of the column to the stream
[378]209      void   printDash (std::ostream &stream);
[222]210
[528]211      /// @brief write blanks the full width of the column to the stream
[378]212      void   printBlank(std::ostream &stream);
[222]213
[528]214      /// @brief Print a given value in a column with correct width & precision.
[378]215      template <class T> void printEntry(std::ostream &stream, T value);
[93]216
[528]217      /// @brief Decides whether the column is used for a given table type
[440]218      bool   doCol(std::string type, bool flagFint=true);
219
220
[378]221    private:
222      int width;          ///< How wide is the column (in ascii spaces)
[528]223      int precision;      ///< What precision should be used to print the values? (If 0, the setprecision command is not used.)
[378]224      std::string name;   ///< The title of the column
[528]225      std::string units;  ///< The units that the values in the column are expressed in.
[440]226      COLNAME type;       ///< The type of the column
[378]227    };
228
[144]229 
[528]230    /// @brief Returns a vector of Col for results file output.
[378]231    std::vector<Column::Col> getFullColSet(std::vector<Detection> &objectList,
232                                           FitsHeader &head);
[232]233
[528]234    /// @brief Returns a vector of Col for logfile output.
[378]235    std::vector<Column::Col> getLogColSet(std::vector<Detection> &objectList,
236                                          FitsHeader &head);
[222]237
[378]238  }
[93]239
[378]240}
[93]241
242#endif
243
Note: See TracBrowser for help on using the repository browser.