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 | /** |
---|
16 | * A namespace controlling the formatting of columns of output for Duchamp. |
---|
17 | */ |
---|
18 | |
---|
19 | namespace Column |
---|
20 | { |
---|
21 | // First, define some basic quantities. |
---|
22 | // The default values for the columns, and default values for |
---|
23 | // the precision of different types of columns. |
---|
24 | |
---|
25 | const int numColumns=23; ///< Total number of columns being considered. |
---|
26 | /** Enumerated column titles */ |
---|
27 | enum COLNAME {NUM=0, NAME, X, Y, Z, |
---|
28 | RA, DEC, VEL, |
---|
29 | WRA, WDEC, WVEL, |
---|
30 | FINT, FTOT, FPEAK, SNRPEAK, |
---|
31 | X1, X2, Y1, Y2, Z1, Z2, NPIX, FLAG}; |
---|
32 | |
---|
33 | const int numColumnsLog=14; ///< Total number of columns used in logfile (no WCS ones). |
---|
34 | /** Enumerated column titles for logfile*/ |
---|
35 | enum LOGNAME {lNUM, lX, lY, lZ, |
---|
36 | lFTOT, lFPEAK, lSNRPEAK, |
---|
37 | lX1, lX2, lY1, lY2, lZ1, lZ2, lNPIX}; |
---|
38 | |
---|
39 | |
---|
40 | const int numPrec=6; ///< Number of types of precision |
---|
41 | enum PrecType {prFLUX, prVEL, prXYZ, prPOS, prWPOS, prSNR}; ///< Enumerated precision categories |
---|
42 | const int prec[numPrec]={3, 3, 1, 6, 2, 2}; ///< Precision values in same order as enum list. |
---|
43 | |
---|
44 | const int defaultWidth[numColumns]= |
---|
45 | {5, 8, 6, 6, 6, |
---|
46 | 13, 13, 7, 9, 9, 7, |
---|
47 | 10, 10, 9, 7, |
---|
48 | 4, 4, 4, 4, 4, 4, 6, 5}; ///< Default widths of all columns. |
---|
49 | const int defaultPrec[numColumns]= |
---|
50 | {0, 0, prec[prXYZ], prec[prXYZ], prec[prXYZ], |
---|
51 | 0, 0, prec[prVEL], |
---|
52 | prec[prWPOS], prec[prWPOS], prec[prVEL], |
---|
53 | prec[prFLUX], prec[prFLUX], prec[prFLUX], |
---|
54 | prec[prSNR], 0, 0, 0, 0, 0, 0, 0, 0}; ///< Default precisions for all columns. |
---|
55 | const string defaultName[numColumns]= |
---|
56 | {"Obj#","Name","X","Y","Z", |
---|
57 | "RA","DEC","VEL", |
---|
58 | "w_RA","w_DEC","w_VEL", |
---|
59 | "F_int","F_tot","F_peak", "S/Nmax", |
---|
60 | "X1","X2","Y1","Y2","Z1","Z2","Npix","Flag"}; ///< Default Titles of all columns |
---|
61 | const string defaultUnits[numColumns]= |
---|
62 | {"","","","","", |
---|
63 | "","","", |
---|
64 | "[arcmin]","[arcmin]","", |
---|
65 | "","","", "", |
---|
66 | "","","","","","","[pix]",""}; ///< Default units of all columns. |
---|
67 | |
---|
68 | |
---|
69 | /** Class to store information about a single column. |
---|
70 | * This contains information about a given column -- its width, the |
---|
71 | * precision associated with it, its title and the units. |
---|
72 | * Plus the usual array of accessor functions and so on. |
---|
73 | */ |
---|
74 | class Col{ |
---|
75 | public: |
---|
76 | Col(); ///< Basic constructor |
---|
77 | Col(int num); ///< Specific constructor |
---|
78 | virtual ~Col(); ///< Default destructor; |
---|
79 | //-------------- |
---|
80 | // basic accessor functions |
---|
81 | // |
---|
82 | int getWidth(){return width;}; |
---|
83 | void setWidth(int i){width=i;}; |
---|
84 | int getPrecision(){return precision;}; |
---|
85 | void setPrecision(int i){precision=i;}; |
---|
86 | string getName(){return name;}; |
---|
87 | void setName(string s){name=s;}; |
---|
88 | string getUnits(){return units;}; |
---|
89 | void setUnits(string s){units=s;}; |
---|
90 | |
---|
91 | //-------------- |
---|
92 | // other functions |
---|
93 | // |
---|
94 | /** Make the column one space wider. */ |
---|
95 | int widen(){width++;}; |
---|
96 | |
---|
97 | /** Increase the precision by one, widening the column if necessary. */ |
---|
98 | int upPrec(){precision++; if(width<precision+3) width++;}; |
---|
99 | |
---|
100 | //-------------- |
---|
101 | // Outputting functions -- all in columns.cc |
---|
102 | // |
---|
103 | /** write the title of the column to the stream */ |
---|
104 | void printTitle(std::ostream &stream){ |
---|
105 | stream << std::setw(this->width) << std::setfill(' ') << this->name; |
---|
106 | }; |
---|
107 | |
---|
108 | /** write the units of the column to the stream */ |
---|
109 | void printUnits(std::ostream &stream){ |
---|
110 | stream << std::setw(this->width) << std::setfill(' ') << this->units; |
---|
111 | }; |
---|
112 | |
---|
113 | /** write dashes the full width of the column to the stream */ |
---|
114 | void printDash (std::ostream &stream){ |
---|
115 | stream << std::setw(this->width) << std::setfill('-') |
---|
116 | << "" << std::setfill(' '); |
---|
117 | }; |
---|
118 | |
---|
119 | /** write blanks the full width of the column to the stream */ |
---|
120 | void printBlank(std::ostream &stream){ |
---|
121 | stream << std::setw(this->width) << std::setfill(' ') << ""; |
---|
122 | }; |
---|
123 | |
---|
124 | /** Print a given value in a column with correct width & precision. */ |
---|
125 | template <class T> void printEntry(std::ostream &stream, T value); |
---|
126 | |
---|
127 | private: |
---|
128 | int width; ///< How wide is the column (in ascii spaces) |
---|
129 | int precision; ///< What precision should be used to print the values? (If 0, the setprecision command is not used.) |
---|
130 | string name; ///< The title of the column |
---|
131 | string units; ///< The units that the values in the column are expressed in. |
---|
132 | }; |
---|
133 | |
---|
134 | |
---|
135 | } |
---|
136 | /** Returns a vector of Col for results file output.*/ |
---|
137 | vector<Column::Col> getFullColSet(vector<Detection> &objectList, |
---|
138 | FitsHeader &head); |
---|
139 | |
---|
140 | /** Returns a vector of Col for logfile output.*/ |
---|
141 | vector<Column::Col> getLogColSet(vector<Detection> &objectList, |
---|
142 | FitsHeader &head); |
---|
143 | |
---|
144 | |
---|
145 | #endif |
---|
146 | |
---|