// ----------------------------------------------------------------------- // columns.hh: Define the column class that formats Duchamp output. // ----------------------------------------------------------------------- // Copyright (C) 2006, Matthew Whiting, ATNF // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your // option) any later version. // // Duchamp is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License // along with Duchamp; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA // // Correspondence concerning Duchamp may be directed to: // Internet email: Matthew.Whiting [at] atnf.csiro.au // Postal address: Dr. Matthew Whiting // Australia Telescope National Facility, CSIRO // PO Box 76 // Epping NSW 1710 // AUSTRALIA // ----------------------------------------------------------------------- #ifndef COLUMNS_H #define COLUMNS_H #include #include #include #include namespace duchamp { class Detection; class FitsHeader; /// A namespace controlling the formatting of columns of output for Duchamp. namespace Column { // First, define some basic quantities. // The default values for the columns, and default values for // the precision of different types of columns. /// @brief Total number of columns being considered. const int numColumns=38; /// @brief Enumerated column titles enum COLNAME {NUM=0, NAME, X, Y, Z, RA, DEC, RAJD, DECJD, VEL, WRA, WDEC, W50, W20, WVEL, FINT, FTOT, FPEAK, SNRPEAK, X1, X2, Y1, Y2, Z1, Z2, NPIX, FLAG, XAV, YAV, ZAV, XCENT, YCENT, ZCENT, XPEAK, YPEAK, ZPEAK, NUMCH, SPATSIZE, UNKNOWN}; // the last is for unclassified columns /// @brief Guide for which columns are used for the results file const bool isFile[numColumns+1]= {true,true,true,true,true, true,true,false,false,true, true,true,true,true,true, true,true,true,true, true,true,true,true,true,true,true,true, true,true,true,true,true,true, true,true,true, false,false, false}; /// @brief Guide for which columns are used for the results printed to screen const bool isScreen[numColumns+1]= {true,true,true,true,true, true,true,false,false,true, true,true,true,false,false, true,true,true,true, true,true,true,true,true,true,true,true, false,false,false,false,false,false, false,false,false, false,false, false}; /// @brief Guide for which columns are used for the log file const bool isLog[numColumns+1]= {true,false,true,true,true, false,false,false,false,false, false,false,false,false,false, false,true,true,true, true,true,true,true,true,true,true,false, false,false,false,false,false,false, false,false,false, true,true, false}; /// @brief Guide for which columns are used for the VOTable file const bool isVOTable[numColumns+1]= {true,true,false,false,false, false,false,true,true,true, true,true,true,true,true, true,true,true,true, false,false,false,false,false,false,false,true, true,true,true,true,true,true, true,true,true, false,false, false}; /// @brief Total number of columns used in logfile (no WCS ones). const int numColumnsLog=16; /// @brief Enumerated column titles for logfile enum LOGNAME {lNUM=0, lX, lY, lZ, lFTOT, lFPEAK, lSNRPEAK, lX1, lX2, lY1, lY2, lZ1, lZ2, lNPIX, lNUMCH, lSPATSIZE}; /// @brief Number of types of precision. const int numPrec=6; /// @brief Enumerated precision categories enum PrecType {prFLUX=3, prVEL=3, prXYZ=1, prPOS=6, prWPOS=2, prSNR=2}; /// @brief Default widths of all columns. const int defaultWidth[numColumns+1]= {5, 8, 6, 6, 6, 13, 13, 11, 11, 7, 9, 9, 7, 7, 7, 10, 10, 9, 7, 4, 4, 4, 4, 4, 4, 6, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, 6, 8, 1}; /// @brief Default precisions for all columns. const int defaultPrec[numColumns+1]= {0, 0, prXYZ, prXYZ, prXYZ, 0, 0, prPOS, prPOS, prVEL, prWPOS, prWPOS, prVEL, prVEL, prVEL, prFLUX, prFLUX, prFLUX, prSNR, 0, 0, 0, 0, 0, 0, 0, 0, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, prXYZ, 0, 0, 0}; /// @brief Default Titles of all columns. const std::string defaultName[numColumns+1]= {"Obj#","Name","X","Y","Z", "RA","DEC","RAJD","DECJD","VEL", "w_RA","w_DEC","w_50","w_20","w_VEL", "F_int","F_tot","F_peak", "S/Nmax", "X1","X2","Y1","Y2","Z1","Z2","Npix","Flag", "X_av", "Y_av", "Z_av", "X_cent", "Y_cent", "Z_cent", "X_peak", "Y_peak", "Z_peak", "Nch", "Sp_size", " "}; /// @brief Default units of all columns. const std::string defaultUnits[numColumns+1]= {"","","","","", "","","[deg]","[deg]","", "[arcmin]","[arcmin]","","","", "","","", "", "","","","","","","[pix]","", "","","","","","","","","", "","", ""}; /// @brief Class to store information about a single column. /// /// @details This contains information about a given column -- /// its width, the precision associated with it, its title and /// the units. Plus the usual array of accessor functions and so /// on. class Col{ public: Col(); ///< Basic constructor Col(int num, int prec=-1); ///< Specific constructor Col(std::string name, std::string units, int width, int prec); ///< Generic constructor Col(const Col& c);///< Assignment constructor Col& operator=(const Col& c); ///< Copy constructor virtual ~Col(); ///< Default destructor; //-------------- // basic accessor functions // int getWidth(){return width;}; void setWidth(int i){width=i;}; int getPrecision(){return precision;}; void setPrecision(int i){precision=i;}; std::string getName(){return name;}; void setName(std::string s){name=s;}; std::string getUnits(){return units;}; void setUnits(std::string s){units=s;}; COLNAME getType(){return type;}; void setType(COLNAME coltype){type=coltype;}; //-------------- // other functions // /// @brief Make the column one space wider. void widen(){width++;}; /// @brief Increase the precision by one, widening the column if necessary. void upPrec(){precision++; width++;}; void changePrec(int p); //-------------- // Outputting functions -- all in columns.cc // /// @brief write the title of the column to the stream void printTitle(std::ostream &stream); /// @brief write the units of the column to the stream void printUnits(std::ostream &stream); /// @brief write dashes the full width of the column to the stream void printDash (std::ostream &stream); /// @brief write blanks the full width of the column to the stream void printBlank(std::ostream &stream); /// @brief Print a given value in a column with correct width & precision. template void printEntry(std::ostream &stream, T value); /// @brief Decides whether the column is used for a given table type bool doCol(std::string type, bool flagFint=true); private: int width; ///< How wide is the column (in ascii spaces) int precision; ///< What precision should be used to print the values? (If 0, the setprecision command is not used.) std::string name; ///< The title of the column std::string units; ///< The units that the values in the column are expressed in. COLNAME type; ///< The type of the column }; /// @brief Returns a vector of Col for results file output. std::vector getFullColSet(std::vector &objectList, FitsHeader &head); /// @brief Returns a vector of Col for logfile output. std::vector getLogColSet(std::vector &objectList, FitsHeader &head); } } #endif