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

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

Minor edits, mostly to get pedantic compilation working.
Added an if clause to getImage, so that the spectral axis setup is not done
if we are examining a 2D image.

File size: 3.5 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++; if(width<precision+3) width++;};
77    // outputting functions -- all in columns.cc
78    void   printTitle(std::ostream &stream){
79      stream << std::setw(this->width) << std::setfill(' ') << this->name;
80    };
81    void   printUnits(std::ostream &stream){
82      stream << std::setw(this->width) << std::setfill(' ') << this->units;
83    };
84    void   printDash (std::ostream &stream){
85      stream << std::setw(this->width) << std::setfill('-')
86             << "" << std::setfill(' ');
87    };
88    void   printBlank(std::ostream &stream){
89      stream << std::setw(this->width) << std::setfill(' ') << "";
90    };
91    template <class T> void printEntry(std::ostream &stream, T value)
92    {
93      stream << std::setprecision(this->precision)
94             << std::setw(this->width)
95             << std::setfill(' ')
96             << value;
97    }
98
99  private:
100    int width;          // how wide is the column (in ascii spaces)
101    int precision;      // what precision should be used to print the values?
102                        //   if 0, the setprecision command is not used.
103    string name;        // the title of the column
104    string units;       // what units the values in the column are expressed in
105  };
106
107 
108}
109vector<Column::Col> getFullColSet(vector<Detection> &objectList, FitsHeader &head);
110vector<Column::Col> getLogColSet(vector<Detection> &objectList, FitsHeader &head);
111
112
113#endif
114
Note: See TracBrowser for help on using the repository browser.