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

Last change on this file since 349 was 304, checked in by Matthew Whiting, 17 years ago

Minor corrections.

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