[299] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // duchamp.hh: Definitions for use with Duchamp |
---|
| 3 | // ----------------------------------------------------------------------- |
---|
| 4 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 5 | // |
---|
| 6 | // This program is free software; you can redistribute it and/or modify it |
---|
| 7 | // under the terms of the GNU General Public License as published by the |
---|
| 8 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 9 | // option) any later version. |
---|
| 10 | // |
---|
| 11 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 12 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 13 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 14 | // for more details. |
---|
| 15 | // |
---|
| 16 | // You should have received a copy of the GNU General Public License |
---|
| 17 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 18 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 19 | // |
---|
| 20 | // Correspondence concerning Duchamp may be directed to: |
---|
| 21 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 22 | // Postal address: Dr. Matthew Whiting |
---|
| 23 | // Australia Telescope National Facility, CSIRO |
---|
| 24 | // PO Box 76 |
---|
| 25 | // Epping NSW 1710 |
---|
| 26 | // AUSTRALIA |
---|
| 27 | // ----------------------------------------------------------------------- |
---|
[105] | 28 | #ifndef DUCHAMP_HH |
---|
| 29 | #define DUCHAMP_HH |
---|
| 30 | |
---|
[175] | 31 | #include <iostream> |
---|
[872] | 32 | #include <stdexcept> |
---|
[125] | 33 | #include <string> |
---|
[913] | 34 | #include <sstream> |
---|
[125] | 35 | |
---|
[523] | 36 | // need to undef these in case other packages have them defined. |
---|
[141] | 37 | #undef PACKAGE_BUGREPORT |
---|
| 38 | #undef PACKAGE_NAME |
---|
| 39 | #undef PACKAGE_STRING |
---|
| 40 | #undef PACKAGE_TARNAME |
---|
| 41 | #undef PACKAGE_VERSION |
---|
[321] | 42 | #undef HAVE_PGPLOT |
---|
[489] | 43 | #include <duchamp/config.h> |
---|
[110] | 44 | |
---|
[488] | 45 | #ifdef HAVE_PGPLOT |
---|
| 46 | #include <duchamp/Utils/mycpgplot.hh> |
---|
| 47 | #endif |
---|
| 48 | |
---|
[759] | 49 | /// The primary namespace for all functionality directly related to Duchamp |
---|
[378] | 50 | namespace duchamp |
---|
| 51 | { |
---|
[71] | 52 | |
---|
[759] | 53 | /// @brief How to convey whether a function has worked |
---|
[378] | 54 | enum OUTCOME {SUCCESS=0, FAILURE}; |
---|
| 55 | |
---|
[759] | 56 | /// Usage message for command line help. |
---|
[378] | 57 | const std::string ERR_USAGE_MSG = |
---|
| 58 | "Usage: Duchamp [OPTION] [FILE]\n\ |
---|
[266] | 59 | Duchamp is an object finder for spectral-line FITS cubes.\n\ |
---|
| 60 | \n\ |
---|
| 61 | -p FILE Read in parameters from FILE, including FITS image location.\n\ |
---|
| 62 | -f FILE Use default parameters with imageFile=FILE\n\ |
---|
[294] | 63 | -x Do not use X-windows PGPLOT output\n\ |
---|
| 64 | (equivalent to setting flagXOutput=false -- overrides the parameter file)\n\n\ |
---|
[266] | 65 | -v Return version number and exit\n\ |
---|
| 66 | -h Display this help information and exit\n"; |
---|
[57] | 67 | |
---|
[759] | 68 | /// Usage message for command line help for Selavy. |
---|
[474] | 69 | const std::string SELAVY_ERR_USAGE_MSG = |
---|
| 70 | "Usage: Selavy [OPTION] [FILE]\n\ |
---|
| 71 | Selavy re-analyses and re-plots objects found by Duchamp.\n\ |
---|
| 72 | \n\ |
---|
| 73 | -p FILE Read in parameters from FILE, including FITS image location.\n\ |
---|
| 74 | -f FILE Use default parameters with imageFile=FILE\n\ |
---|
| 75 | -x Do not use X-windows PGPLOT output\n\ |
---|
| 76 | (equivalent to setting flagXOutput=false -- overrides the parameter file)\n\n\ |
---|
| 77 | -v Return version number and exit\n\ |
---|
| 78 | -h Display this help information and exit\n"; |
---|
| 79 | |
---|
[759] | 80 | /// Shorter Usage message for command line help. |
---|
[378] | 81 | const std::string ERR_USAGE_MSG_SHORT="Usage: Duchamp -p [parameter file]\n"; |
---|
[57] | 82 | |
---|
[759] | 83 | /// The program name. (Duchamp) |
---|
[378] | 84 | const std::string PROGNAME = PACKAGE_NAME; |
---|
[57] | 85 | |
---|
[759] | 86 | /// The program version |
---|
[378] | 87 | const std::string VERSION = PACKAGE_VERSION; |
---|
[71] | 88 | |
---|
[872] | 89 | /// Define the duchamp exception class. |
---|
| 90 | class DuchampError: public std::runtime_error |
---|
| 91 | { |
---|
| 92 | public: |
---|
| 93 | /// Constructor taking a message |
---|
| 94 | explicit DuchampError(const std::string& message); |
---|
| 95 | /// empty destructor |
---|
| 96 | virtual ~DuchampError() throw(); |
---|
| 97 | }; |
---|
[201] | 98 | |
---|
[909] | 99 | // Macro to handle warnings, specifying the origin of the warning and taking a streamed input |
---|
[1076] | 100 | #define DUCHAMPWARN(origin,stream) \ |
---|
| 101 | { \ |
---|
| 102 | do { \ |
---|
| 103 | std::ostringstream oss; \ |
---|
| 104 | oss << stream; \ |
---|
| 105 | std::cerr << "WARNING <" << origin << "> : " << oss.str()<<"\n"; \ |
---|
| 106 | } while(0); \ |
---|
[909] | 107 | } |
---|
| 108 | |
---|
| 109 | // Macro to handle errors, with origin and streamed input. No exception is thrown (use DUCHAMPTHROW instead) |
---|
[1076] | 110 | #define DUCHAMPERROR(origin,stream) \ |
---|
| 111 | { \ |
---|
| 112 | do { \ |
---|
| 113 | std::ostringstream oss; \ |
---|
| 114 | oss << stream; \ |
---|
| 115 | std::cerr << "ERROR <" << origin << "> : " << oss.str() << "\n"; \ |
---|
| 116 | } while(0); \ |
---|
| 117 | } |
---|
[872] | 118 | |
---|
[1076] | 119 | #define DUCHAMPTHROW(origin,stream) \ |
---|
| 120 | { \ |
---|
| 121 | DUCHAMPERROR(origin,"\a"<<stream); \ |
---|
| 122 | std::ostringstream error; \ |
---|
| 123 | error << stream; \ |
---|
| 124 | throw DuchampError(error.str()); \ |
---|
| 125 | } |
---|
[872] | 126 | |
---|
[759] | 127 | /// The spectral type that we want the wcsprm structs to be in. |
---|
[1076] | 128 | const char duchampVelocityType[9] = "VOPT-F2W"; |
---|
[772] | 129 | //const char duchampVelocityType[9] = "VELO-F2V"; |
---|
[759] | 130 | /// The spectral type that we want the wcsprm structs to be in when no velocity info is present. |
---|
[378] | 131 | const char duchampFrequencyType[9] = "FREQ "; |
---|
[103] | 132 | |
---|
[759] | 133 | /// Descriptions of the various spectral axis types |
---|
[378] | 134 | enum TYPEDESC {FREQUENCY=0,VELOCITY,WAVELENGTH}; |
---|
[759] | 135 | /// Human-readable descriptions of the various spectral axis types |
---|
[378] | 136 | const std::string duchampSpectralDescription[3]= |
---|
| 137 | {"Frequency", "Velocity", "Wavelength"}; |
---|
[186] | 138 | |
---|
[378] | 139 | // The following are the FITS Header Keywords corresponding to the |
---|
| 140 | // parameters related to the atrous reconstruction. |
---|
[759] | 141 | |
---|
| 142 | /// FITS header keyword for min atrous scale |
---|
[378] | 143 | const std::string keyword_scaleMin = "DU_MINSC"; |
---|
[759] | 144 | /// FITS header keyword for S/N used in atrous reconstruction |
---|
[378] | 145 | const std::string keyword_snrRecon = "DU_ATCUT"; |
---|
[759] | 146 | /// FITS header keyword for number of dimensions used in atrous reconstruction |
---|
[378] | 147 | const std::string keyword_reconDim = "DU_ATDIM"; |
---|
[759] | 148 | /// FITS header keyword for the code number of the filter used in atrous reconstruction |
---|
[378] | 149 | const std::string keyword_filterCode = "DU_FILTR"; |
---|
[759] | 150 | /// FITS header keyword: does this file hold the reconstructed array or the residual? |
---|
[378] | 151 | const std::string keyword_ReconResid = "DU_RECON"; |
---|
[759] | 152 | /// FITS header keyword: type of smoothing done. |
---|
[378] | 153 | const std::string keyword_smoothtype = "DU_SMTYP"; |
---|
[759] | 154 | /// FITS header keyword for the gaussian kernel major axis FWHM |
---|
[378] | 155 | const std::string keyword_kernmaj = "DU_KMAJ"; |
---|
[759] | 156 | /// FITS header keyword for the gaussian kernel minor axis FWHM |
---|
[378] | 157 | const std::string keyword_kernmin = "DU_KMIN"; |
---|
[759] | 158 | /// FITS header keyword for the gaussian kernel position angle |
---|
[378] | 159 | const std::string keyword_kernpa = "DU_KPA"; |
---|
[759] | 160 | /// FITS header keyword for the Hanning filter width |
---|
[378] | 161 | const std::string keyword_hanningwidth = "DU_WHANN"; |
---|
[759] | 162 | /// FITS header keyword for the image subsection used |
---|
[378] | 163 | const std::string keyword_subsection = "DU_IMSUB"; |
---|
[142] | 164 | |
---|
[378] | 165 | // And these are the comments corresponding to the relevant keywords |
---|
[759] | 166 | /// FITS header comment for DU_MINSC keyword |
---|
[378] | 167 | const std::string comment_scaleMin = "Duchamp parameter scaleMin"; |
---|
[759] | 168 | /// FITS header comment for DU_ATCUT keyword |
---|
[378] | 169 | const std::string comment_snrRecon = "Duchamp parameter snrRecon"; |
---|
[759] | 170 | /// FITS header comment for DU_ATDIM keyword |
---|
[378] | 171 | const std::string comment_reconDim = "Duchamp parameter reconDim"; |
---|
[759] | 172 | /// FITS header comment for DU_FILTR keyword |
---|
[378] | 173 | const std::string comment_filterCode = "Duchamp parameter filterCode"; |
---|
[759] | 174 | /// FITS header comment for DU_RECON keyword |
---|
[378] | 175 | const std::string comment_ReconResid = "Is this the reconstruction or residual?"; |
---|
[759] | 176 | /// FITS header comment for DU_SMTYP keyword |
---|
[378] | 177 | const std::string comment_smoothtype = "Type of smoothing done"; |
---|
[759] | 178 | /// FITS header comment for DU_KMAJ keyword |
---|
[378] | 179 | const std::string comment_kernmaj = "Duchamp parameter kernMaj"; |
---|
[759] | 180 | /// FITS header comment for DU_KMIN keyword |
---|
[378] | 181 | const std::string comment_kernmin = "Duchamp parameter kernMin"; |
---|
[759] | 182 | /// FITS header comment for DU_KPA keyword |
---|
[378] | 183 | const std::string comment_kernpa = "Duchamp parameter kernPA"; |
---|
[759] | 184 | /// FITS header comment for DU_WHANN keyword |
---|
[378] | 185 | const std::string comment_hanningwidth = "Duchamp parameter hanningWidth"; |
---|
[759] | 186 | /// FITS header comment for DU_IMSUB keyword |
---|
[378] | 187 | const std::string comment_subsection = "Subsection of the original image"; |
---|
[105] | 188 | |
---|
[378] | 189 | // Descriptive Headers: for the reconstruction case |
---|
| 190 | const std::string header_reconHistory1 = |
---|
[1076] | 191 | "Reconstructed with a trous wavelet technique"; |
---|
[378] | 192 | const std::string header_reconHistory2 = |
---|
[1076] | 193 | "Reconstruction by " + PROGNAME + " v." + VERSION; |
---|
[378] | 194 | const std::string header_reconHistory_input = |
---|
[1076] | 195 | "Original (input) image used by " + PROGNAME + " follows"; |
---|
[378] | 196 | const std::string header_reconSubsection_comment = |
---|
[1076] | 197 | "A subsection of the original was reconstructed by " + PROGNAME; |
---|
[378] | 198 | const std::string header_atrous_comment = |
---|
[1076] | 199 | "The following are the Duchamp parameters used in reconstruction"; |
---|
[208] | 200 | |
---|
[378] | 201 | // Descriptive Headers: for the Smoothing case |
---|
| 202 | const std::string header_smoothHistory = |
---|
[1076] | 203 | "Smoothed by " + PROGNAME + " v." + VERSION; |
---|
[378] | 204 | const std::string header_smoothHistory_input = |
---|
[1076] | 205 | "Original (input) image used by " + PROGNAME + " follows"; |
---|
[378] | 206 | const std::string header_smoothSubsection_comment = |
---|
[1076] | 207 | "A subsection of the original was smoothed by " + PROGNAME; |
---|
[378] | 208 | const std::string header_smoothSpatial = "Spatial, gaussian kernel"; |
---|
| 209 | const std::string header_smoothSpectral= "Spectral, hanning filter"; |
---|
| 210 | |
---|
[379] | 211 | // Descriptive Headers: for the output Mask image |
---|
| 212 | const std::string header_maskHistory = |
---|
[1076] | 213 | "Results of searching by " + PROGNAME + " v." + VERSION; |
---|
[379] | 214 | const std::string header_maskHistory_input = |
---|
[1076] | 215 | "Input image used by " + PROGNAME + " follows"; |
---|
[379] | 216 | const std::string header_maskSubsection_comment = |
---|
[1076] | 217 | "A subsection of the original was searched by " + PROGNAME; |
---|
[379] | 218 | |
---|
[670] | 219 | // Descriptive Headers: for the output Moment-0 image |
---|
| 220 | const std::string header_moment0History = |
---|
[1076] | 221 | "Moment-0 map from searching by " + PROGNAME + " v." + VERSION; |
---|
[670] | 222 | const std::string header_moment0History_input = |
---|
[1076] | 223 | "Input image used by " + PROGNAME + " follows"; |
---|
[670] | 224 | const std::string header_moment0Subsection_comment = |
---|
[1076] | 225 | "A subsection of the original was searched by " + PROGNAME; |
---|
[670] | 226 | |
---|
[1076] | 227 | // Default colour used for the annotation files |
---|
| 228 | const std::string annotationColour = "RED"; |
---|
| 229 | |
---|
[378] | 230 | } |
---|
| 231 | |
---|
[489] | 232 | #ifdef HAVE_PGPLOT |
---|
| 233 | namespace duchamp |
---|
| 234 | { |
---|
| 235 | |
---|
| 236 | // Colours used in graphical output |
---|
[759] | 237 | /// The colour for the Blank edges |
---|
[489] | 238 | const int DUCHAMP_BLANK_EDGE_COLOUR = mycpgplot::MAGENTA; |
---|
[759] | 239 | /// The colour for the edge of the cube |
---|
[489] | 240 | const int DUCHAMP_CUBE_EDGE_COLOUR = mycpgplot::YELLOW; |
---|
[759] | 241 | /// The colour for the reconstructed spectra |
---|
[489] | 242 | const int DUCHAMP_RECON_SPECTRA_COLOUR = mycpgplot::RED; |
---|
[759] | 243 | /// The colour for the baseline spectra |
---|
[489] | 244 | const int DUCHAMP_BASELINE_SPECTRA_COLOUR = mycpgplot::YELLOW; |
---|
[759] | 245 | /// The colour for the object outline |
---|
[489] | 246 | const int DUCHAMP_OBJECT_OUTLINE_COLOUR = mycpgplot::BLUE; |
---|
[759] | 247 | /// The colour for the Milky-way region spectral boundaries |
---|
[489] | 248 | const int DUCHAMP_MILKY_WAY_COLOUR = mycpgplot::DARKGREEN; |
---|
[759] | 249 | /// The colour for the tick marks in the image cutouts |
---|
[489] | 250 | const int DUCHAMP_TICKMARK_COLOUR = mycpgplot::RED; |
---|
[759] | 251 | /// The colour for the text identifying objects on the maps |
---|
[489] | 252 | const int DUCHAMP_ID_TEXT_COLOUR = mycpgplot::RED; |
---|
[759] | 253 | /// The colour for the WCS axes on the maps |
---|
[489] | 254 | const int DUCHAMP_WCS_AXIS_COLOUR = mycpgplot::WCSGREEN; |
---|
| 255 | |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | #else |
---|
| 259 | namespace duchamp |
---|
| 260 | { |
---|
[759] | 261 | /// The colour for the text identifying objects on the maps |
---|
[489] | 262 | const int DUCHAMP_ID_TEXT_COLOUR = 2; |
---|
[759] | 263 | /// The colour for the WCS axes on the maps |
---|
[489] | 264 | const int DUCHAMP_WCS_AXIS_COLOUR = 3; |
---|
| 265 | |
---|
| 266 | } |
---|
| 267 | |
---|
[105] | 268 | #endif |
---|
| 269 | |
---|
[489] | 270 | |
---|
| 271 | #endif |
---|