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

Last change on this file since 868 was 688, checked in by MatthewWhiting, 14 years ago

Adding number of channels and spatial size to the logfile output.

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