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

Last change on this file since 144 was 144, checked in by Matthew Whiting, 18 years ago

Made changes to the way the columns are dealt with. Now much more resilient
towards low values (eg of flux -- if much below 1 it will change the width
and precision so that enough significant figures are shown).
These changes are also propagated through to the information in the spectral
plots.
The ColSet? class was removed and replaced with a more simple vector<Col>.

File size: 3.4 KB
Line 
1#ifndef COLUMNS_H
2#define COLUMNS_H
3
4#include <iostream>
5#include <iomanip>
6#include <string>
7#include <vector>
8
9using std::string;
10using std::vector;
11
12class Detection;
13class FitsHeader;
14
15namespace Column
16{
17  // First, define some basic quantities.
18  // The default values for the columns, and default values for
19  //  the precision of different types of columns.
20
21  enum PrecType {prFLUX, prVEL, prXYZ, prPOS, prWPOS};
22  const int prec[5]={3, 3, 1, 6, 2};
23
24  enum COLNAME {NUM=0, NAME, X, Y, Z,
25                RA, DEC, VEL,
26                WRA, WDEC, WVEL,
27                FINT, FTOT, FPEAK,
28                X1, X2, Y1, Y2, Z1, Z2, NPIX, FLAG};
29
30  enum LOGNAME {lNUM, lX, lY, lZ,
31                lFTOT, lFPEAK,
32                lX1, lX2, lY1, lY2, lZ1, lZ2, lNPIX};
33
34  const int defaultWidth[22]={5, 8, 6, 6, 6,
35                              13, 13, 7, 9, 9, 7,
36                              10, 10, 9,
37                              4, 4, 4, 4, 4, 4, 6, 5};
38  const int defaultPrec[22]={0, 0, prec[prXYZ], prec[prXYZ], prec[prXYZ],
39                             0, 0, prec[prVEL],
40                             prec[prWPOS], prec[prWPOS], prec[prVEL],
41                             prec[prFLUX], prec[prFLUX], prec[prFLUX],
42                             0, 0, 0, 0, 0, 0, 0, 0};
43  const string defaultName[22]={"Obj#","Name","X","Y","Z",
44                                "RA","DEC","VEL",
45                                "w_RA","w_DEC","w_VEL",
46                                "F_int","F_tot","F_peak",
47                                "X1","X2","Y1","Y2","Z1","Z2","Npix","Flag"};
48  const string defaultUnits[22]={"","","","","",
49                                 "","","",
50                                 "[arcmin]","[arcmin]","",
51                                 "","","",
52                                 "","","","","","","[pix]",""};
53
54
55  // Now define the Col class.
56  // This contains information about a given column -- its width, the
57  //  precision associated with it, its title and the units.
58  // Plus the usual array of accessor functions and so on.
59
60  class Col{
61  public:
62    Col(){width=1; precision=0; name=" "; units=" ";};
63    Col(int num);  // in columns.cc
64    virtual ~Col(){};
65    // basic accessor functions
66    int    getWidth(){return width;};
67    void   setWidth(int i){width=i;};
68    int    getPrecision(){return precision;};
69    void   setPrecision(int i){precision=i;};
70    string getName(){return name;};
71    void   setName(string s){name=s;};
72    string getUnits(){return units;};
73    void   setUnits(string s){units=s;};
74    // other functions
75    int    widen(){width++;};
76    int    upPrec(){precision++; width++;};
77    // outputting functions -- all in columns.cc
78    void   printTitle(std::ostream &stream){
79      stream << std::setw(this->width) << this->name;
80    };
81    void   printUnits(std::ostream &stream){
82      stream << std::setw(this->width) << this->units;
83    };
84    void   printDash (std::ostream &stream){
85      stream << std::setfill('-') << std::setw(this->width)
86             << ""<< std::setfill(' ');
87    };
88    void   printBlank(std::ostream &stream){
89      stream << std::setfill(' ') << std::setw(this->width) << "";
90    };
91    template <class T> void printEntry(std::ostream &stream, T value)// ;
92    {
93      stream << setprecision(precision);
94      stream << std::setw(width) << value;
95    }
96
97  private:
98    int width;          // how wide is the column (in ascii spaces)
99    int precision;      // what precision should be used to print the values?
100                        //   if 0, the setprecision command is not used.
101    string name;        // the title of the column
102    string units;       // what units the values in the column are expressed in
103  };
104
105 
106}
107vector<Column::Col> getFullColSet(vector<Detection> &objectList, FitsHeader &head);
108vector<Column::Col> getLogColSet(vector<Detection> &objectList, FitsHeader &head);
109
110
111#endif
112
Note: See TracBrowser for help on using the repository browser.