source: tags/release-1.2.2/src/duchamp.hh

Last change on this file was 1076, checked in by MatthewWhiting, 12 years ago

Adding a "join-the-dots" function to the annotation files, and adding the flexibility of being able to change the colour.

File size: 11.1 KB
Line 
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// -----------------------------------------------------------------------
28#ifndef DUCHAMP_HH
29#define DUCHAMP_HH
30
31#include <iostream>
32#include <stdexcept>
33#include <string>
34#include <sstream>
35
36// need to undef these in case other packages have them defined.
37#undef PACKAGE_BUGREPORT
38#undef PACKAGE_NAME
39#undef PACKAGE_STRING
40#undef PACKAGE_TARNAME
41#undef PACKAGE_VERSION
42#undef HAVE_PGPLOT
43#include <duchamp/config.h>
44
45#ifdef HAVE_PGPLOT
46#include <duchamp/Utils/mycpgplot.hh>
47#endif
48
49/// The primary namespace for all functionality directly related to Duchamp
50namespace duchamp
51{
52
53  /// @brief How to convey whether a function has worked
54  enum OUTCOME {SUCCESS=0, FAILURE};
55
56  /// Usage message for command line help.
57  const std::string ERR_USAGE_MSG =
58    "Usage: Duchamp [OPTION] [FILE]\n\
59Duchamp 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\
63  -x           Do not use X-windows PGPLOT output\n\
64               (equivalent to setting flagXOutput=false -- overrides the parameter file)\n\n\
65  -v           Return version number and exit\n\
66  -h           Display this help information and exit\n";
67
68  /// Usage message for command line help for Selavy.
69  const std::string SELAVY_ERR_USAGE_MSG =
70    "Usage: Selavy [OPTION] [FILE]\n\
71Selavy 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
80  /// Shorter Usage message for command line help.
81  const std::string ERR_USAGE_MSG_SHORT="Usage: Duchamp -p [parameter file]\n";
82
83  /// The program name. (Duchamp)
84  const std::string PROGNAME = PACKAGE_NAME;
85
86  /// The program version
87  const std::string VERSION = PACKAGE_VERSION;
88
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  };
98
99  // Macro to handle warnings, specifying the origin of the warning and taking a streamed input
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);                                                         \
107  }     
108 
109  // Macro to handle errors, with origin and streamed input. No exception is thrown (use DUCHAMPTHROW instead)
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  }
118
119#define DUCHAMPTHROW(origin,stream)             \
120  {                                             \
121    DUCHAMPERROR(origin,"\a"<<stream);          \
122    std::ostringstream error;                   \
123    error << stream;                            \
124    throw DuchampError(error.str());            \
125  }
126
127  /// The spectral type that we want the wcsprm structs to be in.
128  const char duchampVelocityType[9] = "VOPT-F2W";
129  //const char duchampVelocityType[9] = "VELO-F2V";
130  /// The spectral type that we want the wcsprm structs to be in when no velocity info is present.
131  const char duchampFrequencyType[9] = "FREQ    ";
132
133  /// Descriptions of the various spectral axis types
134  enum TYPEDESC {FREQUENCY=0,VELOCITY,WAVELENGTH};
135  /// Human-readable descriptions of the various spectral axis types
136  const std::string duchampSpectralDescription[3]=
137    {"Frequency", "Velocity", "Wavelength"};
138
139  // The following are the FITS Header Keywords corresponding to the
140  // parameters related to the atrous reconstruction.
141
142  /// FITS header keyword for min atrous scale
143  const std::string keyword_scaleMin     = "DU_MINSC";
144  /// FITS header keyword for S/N used in atrous reconstruction
145  const std::string keyword_snrRecon     = "DU_ATCUT";
146  /// FITS header keyword for number of dimensions used in atrous reconstruction
147  const std::string keyword_reconDim     = "DU_ATDIM";
148  /// FITS header keyword for the code number of the filter used in atrous reconstruction
149  const std::string keyword_filterCode   = "DU_FILTR";
150  /// FITS header keyword: does this file hold the reconstructed array or the residual?
151  const std::string keyword_ReconResid   = "DU_RECON";
152  /// FITS header keyword: type of smoothing done.
153  const std::string keyword_smoothtype   = "DU_SMTYP";
154  /// FITS header keyword for the gaussian kernel major axis FWHM
155  const std::string keyword_kernmaj      = "DU_KMAJ";
156  /// FITS header keyword for the gaussian kernel minor axis FWHM
157  const std::string keyword_kernmin      = "DU_KMIN";
158  /// FITS header keyword for the gaussian kernel position angle
159  const std::string keyword_kernpa       = "DU_KPA";
160  /// FITS header keyword for the Hanning filter width
161  const std::string keyword_hanningwidth = "DU_WHANN";
162  /// FITS header keyword for the image subsection used
163  const std::string keyword_subsection   = "DU_IMSUB";
164
165  // And these are the comments corresponding to the relevant keywords
166  /// FITS header comment for DU_MINSC keyword
167  const std::string comment_scaleMin     = "Duchamp parameter scaleMin";
168  /// FITS header comment for DU_ATCUT keyword
169  const std::string comment_snrRecon     = "Duchamp parameter snrRecon";
170  /// FITS header comment for DU_ATDIM keyword
171  const std::string comment_reconDim     = "Duchamp parameter reconDim";
172  /// FITS header comment for DU_FILTR keyword
173  const std::string comment_filterCode   = "Duchamp parameter filterCode";
174  /// FITS header comment for DU_RECON keyword
175  const std::string comment_ReconResid   = "Is this the reconstruction or residual?";
176  /// FITS header comment for DU_SMTYP keyword
177  const std::string comment_smoothtype   = "Type of smoothing done";
178  /// FITS header comment for DU_KMAJ  keyword
179  const std::string comment_kernmaj      = "Duchamp parameter kernMaj";
180  /// FITS header comment for DU_KMIN  keyword
181  const std::string comment_kernmin      = "Duchamp parameter kernMin";
182  /// FITS header comment for DU_KPA   keyword
183  const std::string comment_kernpa       = "Duchamp parameter kernPA";
184  /// FITS header comment for DU_WHANN keyword
185  const std::string comment_hanningwidth = "Duchamp parameter hanningWidth";
186  /// FITS header comment for DU_IMSUB keyword
187  const std::string comment_subsection   = "Subsection of the original image";
188
189  // Descriptive Headers: for the reconstruction case
190  const std::string header_reconHistory1 =
191             "Reconstructed with a trous wavelet technique";
192  const std::string header_reconHistory2 =
193             "Reconstruction by " + PROGNAME + " v." + VERSION;
194  const std::string header_reconHistory_input =
195             "Original (input) image used by " + PROGNAME + " follows";
196  const std::string header_reconSubsection_comment  =
197             "A subsection of the original was reconstructed by " + PROGNAME;
198  const std::string header_atrous_comment  =
199             "The following are the Duchamp parameters used in reconstruction";
200
201  // Descriptive Headers: for the Smoothing case
202  const std::string header_smoothHistory =
203             "Smoothed by " + PROGNAME + " v." + VERSION;
204  const std::string header_smoothHistory_input =
205             "Original (input) image used by " + PROGNAME + " follows";
206  const std::string header_smoothSubsection_comment  =
207             "A subsection of the original was smoothed by " + PROGNAME;
208  const std::string header_smoothSpatial = "Spatial, gaussian kernel";
209  const std::string header_smoothSpectral= "Spectral, hanning filter";
210
211  // Descriptive Headers: for the output Mask image
212  const std::string header_maskHistory =
213             "Results of searching by " + PROGNAME + " v." + VERSION;
214  const std::string header_maskHistory_input =
215             "Input image used by " + PROGNAME + " follows";
216  const std::string header_maskSubsection_comment =
217             "A subsection of the original was searched by " + PROGNAME;
218
219  // Descriptive Headers: for the output Moment-0 image
220  const std::string header_moment0History =
221             "Moment-0 map from searching by " + PROGNAME + " v." + VERSION;
222  const std::string header_moment0History_input =
223             "Input image used by " + PROGNAME + " follows";
224  const std::string header_moment0Subsection_comment =
225             "A subsection of the original was searched by " + PROGNAME;
226
227  // Default colour used for the annotation files
228  const std::string annotationColour = "RED";
229
230}
231
232#ifdef HAVE_PGPLOT
233namespace duchamp
234{
235
236  // Colours used in graphical output
237  /// The colour for the Blank edges
238  const int DUCHAMP_BLANK_EDGE_COLOUR = mycpgplot::MAGENTA;
239  /// The colour for the edge of the cube
240  const int DUCHAMP_CUBE_EDGE_COLOUR = mycpgplot::YELLOW;
241  /// The colour for the reconstructed spectra
242  const int DUCHAMP_RECON_SPECTRA_COLOUR = mycpgplot::RED;
243  /// The colour for the baseline spectra
244  const int DUCHAMP_BASELINE_SPECTRA_COLOUR = mycpgplot::YELLOW;
245  /// The colour for the object outline
246  const int DUCHAMP_OBJECT_OUTLINE_COLOUR = mycpgplot::BLUE;
247  /// The colour for the Milky-way region spectral boundaries
248  const int DUCHAMP_MILKY_WAY_COLOUR = mycpgplot::DARKGREEN;
249  /// The colour for the tick marks in the image cutouts
250  const int DUCHAMP_TICKMARK_COLOUR = mycpgplot::RED;
251  /// The colour for the text identifying objects on the maps
252  const int DUCHAMP_ID_TEXT_COLOUR = mycpgplot::RED;
253  /// The colour for the WCS axes on the maps
254  const int DUCHAMP_WCS_AXIS_COLOUR = mycpgplot::WCSGREEN;
255
256}
257
258#else
259namespace duchamp
260{
261  /// The colour for the text identifying objects on the maps
262  const int DUCHAMP_ID_TEXT_COLOUR = 2;
263  /// The colour for the WCS axes on the maps
264  const int DUCHAMP_WCS_AXIS_COLOUR = 3;
265
266}
267
268#endif
269
270
271#endif
Note: See TracBrowser for help on using the repository browser.