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