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