source: trunk/src/duchamp.hh @ 1441

Last change on this file since 1441 was 1363, checked in by MatthewWhiting, 10 years ago

For ticket #224 - moving all pgplot constants to specific values defined in duchamp.hh. In the process, change the line style for the spectral boundaries to solid.

File size: 11.7 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  -t THRESH    Sets the detection threshold to THRESH, overriding that given by the parameter file.\n\
64  -x           Do not use X-windows PGPLOT output\n\
65               (equivalent to setting flagXOutput=false -- overrides the parameter file)\n\n\
66  -v           Return version number and exit\n\
67  -h           Display this help information and exit\n";
68
69  /// Shorter Usage message for command line help.
70  const std::string ERR_USAGE_MSG_SHORT="Usage: Duchamp -p [parameter file]\n";
71
72  /// The program name. (Duchamp)
73  const std::string PROGNAME = PACKAGE_NAME;
74
75  /// The program version
76  const std::string VERSION = PACKAGE_VERSION;
77
78  /// Define the duchamp exception class.
79  class DuchampError: public std::runtime_error
80  {
81  public:
82    /// Constructor taking a message
83    explicit DuchampError(const std::string& message);
84    /// empty destructor
85    virtual ~DuchampError() throw();
86  };
87
88  // Macro to handle warnings, specifying the origin of the warning and taking a streamed input
89#define DUCHAMPWARN(origin,stream)                                      \
90  {                                                                     \
91    do {                                                                \
92      std::ostringstream oss;                                           \
93      oss << stream;                                                    \
94      std::cerr << "WARNING <" << origin << "> : " << oss.str()<<"\n";  \
95    } while(0);                                                         \
96  }     
97 
98  // Macro to handle errors, with origin and streamed input. No exception is thrown (use DUCHAMPTHROW instead)
99#define DUCHAMPERROR(origin,stream)                                     \
100  {                                                                     \
101    do {                                                                \
102      std::ostringstream oss;                                           \
103      oss << stream;                                                    \
104      std::cerr << "ERROR <" << origin << "> : " << oss.str() << "\n";  \
105    } while(0);                                                         \
106  }
107
108#define DUCHAMPTHROW(origin,stream)             \
109  {                                             \
110    DUCHAMPERROR(origin,"\a"<<stream);          \
111    std::ostringstream error;                   \
112    error << stream;                            \
113    throw DuchampError(error.str());            \
114  }
115
116  void duchampFITSerror(int status, std::string subroutine, std::string error);
117
118  /// The spectral type that we want the wcsprm structs to be in.
119  const char duchampVelocityType[9] = "VOPT-F2W";
120  //const char duchampVelocityType[9] = "VELO-F2V";
121  /// The spectral type that we want the wcsprm structs to be in when no velocity info is present.
122  const char duchampFrequencyType[9] = "FREQ    ";
123
124  /// Descriptions of the various spectral axis types
125  enum TYPEDESC {FREQUENCY=0,VELOCITY,WAVELENGTH};
126  /// Human-readable descriptions of the various spectral axis types
127  const std::string duchampSpectralDescription[3]=
128    {"Frequency", "Velocity", "Wavelength"};
129
130  // The following are the FITS Header Keywords corresponding to the
131  // parameters related to the atrous reconstruction.
132
133  /// FITS header keyword for min atrous scale
134  const std::string keyword_scaleMin     = "DU_MINSC";
135  /// FITS header keyword for S/N used in atrous reconstruction
136  const std::string keyword_snrRecon     = "DU_ATCUT";
137  /// FITS header keyword for number of dimensions used in atrous reconstruction
138  const std::string keyword_reconDim     = "DU_ATDIM";
139  /// FITS header keyword for the code number of the filter used in atrous reconstruction
140  const std::string keyword_filterCode   = "DU_FILTR";
141  /// FITS header keyword: does this file hold the reconstructed array or the residual?
142  const std::string keyword_ReconResid   = "DU_RECON";
143  /// FITS header keyword: type of smoothing done.
144  const std::string keyword_smoothtype   = "DU_SMTYP";
145  /// FITS header keyword for the gaussian kernel major axis FWHM
146  const std::string keyword_kernmaj      = "DU_KMAJ";
147  /// FITS header keyword for the gaussian kernel minor axis FWHM
148  const std::string keyword_kernmin      = "DU_KMIN";
149  /// FITS header keyword for the gaussian kernel position angle
150  const std::string keyword_kernpa       = "DU_KPA";
151  /// FITS header keyword for the Hanning filter width
152  const std::string keyword_hanningwidth = "DU_WHANN";
153  /// FITS header keyword for the image subsection used
154  const std::string keyword_subsection   = "DU_IMSUB";
155
156  // And these are the comments corresponding to the relevant keywords
157  /// FITS header comment for DU_MINSC keyword
158  const std::string comment_scaleMin     = "Duchamp parameter scaleMin";
159  /// FITS header comment for DU_ATCUT keyword
160  const std::string comment_snrRecon     = "Duchamp parameter snrRecon";
161  /// FITS header comment for DU_ATDIM keyword
162  const std::string comment_reconDim     = "Duchamp parameter reconDim";
163  /// FITS header comment for DU_FILTR keyword
164  const std::string comment_filterCode   = "Duchamp parameter filterCode";
165  /// FITS header comment for DU_RECON keyword
166  const std::string comment_ReconResid   = "Is this the reconstruction or residual?";
167  /// FITS header comment for DU_SMTYP keyword
168  const std::string comment_smoothtype   = "Type of smoothing done";
169  /// FITS header comment for DU_KMAJ  keyword
170  const std::string comment_kernmaj      = "Duchamp parameter kernMaj";
171  /// FITS header comment for DU_KMIN  keyword
172  const std::string comment_kernmin      = "Duchamp parameter kernMin";
173  /// FITS header comment for DU_KPA   keyword
174  const std::string comment_kernpa       = "Duchamp parameter kernPA";
175  /// FITS header comment for DU_WHANN keyword
176  const std::string comment_hanningwidth = "Duchamp parameter hanningWidth";
177  /// FITS header comment for DU_IMSUB keyword
178  const std::string comment_subsection   = "Subsection of the original image";
179
180  // Descriptive Headers: for the reconstruction case
181  const std::string header_reconHistory1 =
182             "Reconstructed with a trous wavelet technique";
183  const std::string header_reconHistory2 =
184             "Reconstruction by " + PROGNAME + " v." + VERSION;
185  const std::string header_reconHistory_input =
186             "Original (input) image used by " + PROGNAME + " follows";
187  const std::string header_reconSubsection_comment  =
188             "A subsection of the original was reconstructed by " + PROGNAME;
189  const std::string header_atrous_comment  =
190             "The following are the Duchamp parameters used in reconstruction";
191
192  // Descriptive Headers: for the Smoothing case
193  const std::string header_smoothHistory =
194             "Smoothed by " + PROGNAME + " v." + VERSION;
195  const std::string header_smoothHistory_input =
196             "Original (input) image used by " + PROGNAME + " follows";
197  const std::string header_smoothSubsection_comment  =
198             "A subsection of the original was smoothed by " + PROGNAME;
199  const std::string header_smoothSpatial = "Spatial, gaussian kernel";
200  const std::string header_smoothSpectral= "Spectral, hanning filter";
201
202  // Descriptive Headers: for the output Mask image
203  const std::string header_maskHistory =
204             "Results of searching by " + PROGNAME + " v." + VERSION;
205  const std::string header_maskHistory_input =
206             "Input image used by " + PROGNAME + " follows";
207  const std::string header_maskSubsection_comment =
208             "A subsection of the original was searched by " + PROGNAME;
209
210  // Descriptive Headers: for the output Baseline image
211  const std::string header_baselineHistory =
212             "Results of baseline extraction by " + PROGNAME + " v." + VERSION;
213  const std::string header_baselineHistory_input =
214             "Input image used by " + PROGNAME + " follows";
215  const std::string header_baselineSubsection_comment =
216             "A subsection of the original was searched by " + PROGNAME;
217
218  // Descriptive Headers: for the output Moment-0 image
219  const std::string header_moment0History =
220             "Moment-0 map from searching by " + PROGNAME + " v." + VERSION;
221  const std::string header_moment0History_input =
222             "Input image used by " + PROGNAME + " follows";
223  const std::string header_moment0Subsection_comment =
224             "A subsection of the original was searched by " + PROGNAME;
225
226  // Default colour used for the annotation files
227  const std::string annotationColour = "RED";
228
229}
230
231#ifdef HAVE_PGPLOT
232namespace duchamp
233{
234
235  // Colours used in graphical output
236  /// The colour for the Blank edges
237  const int DUCHAMP_BLANK_EDGE_COLOUR = mycpgplot::MAGENTA;
238  /// The colour for the edge of the cube
239  const int DUCHAMP_CUBE_EDGE_COLOUR = mycpgplot::YELLOW;
240  /// The colour for the reconstructed spectra
241  const int DUCHAMP_RECON_SPECTRA_COLOUR = mycpgplot::RED;
242  /// The colour for the baseline spectra
243  const int DUCHAMP_BASELINE_SPECTRA_COLOUR = mycpgplot::YELLOW;
244  /// The colour for the object outline
245  const int DUCHAMP_OBJECT_OUTLINE_COLOUR = mycpgplot::BLUE;
246  /// The linestyle for the object outline
247  const int DUCHAMP_OBJECT_OUTLINE_STYLE = mycpgplot::FULL;
248  /// The colour for the flagged-channel spectral boundaries
249  const int DUCHAMP_FLAGGED_CHAN_COLOUR = mycpgplot::DARKGREEN;
250  /// The fill style for the flagged-channel spectral boundaries
251  const int DUCHAMP_FLAGGED_CHAN_FILL = mycpgplot::HATCHED;
252  /// The line colour for the threshold lines in the spectral plots
253  const int DUCHAMP_THRESHOLD_COLOUR = mycpgplot::BLUE;
254  /// The line style for the primary threshold in the spectral plots
255  const int DUCHAMP_THRESHOLD_MAIN_STYLE = mycpgplot::DASHED;
256  /// The line style for the growth threshold in the spectral plots
257  const int DUCHAMP_THRESHOLD_GROWTH_STYLE = mycpgplot::DOTTED;
258  /// The colour for the tick marks in the image cutouts
259  const int DUCHAMP_TICKMARK_COLOUR = mycpgplot::RED;
260  /// The colour for the text identifying objects on the maps
261  const int DUCHAMP_ID_TEXT_COLOUR = mycpgplot::RED;
262  /// The colour for the WCS axes on the maps
263  const int DUCHAMP_WCS_AXIS_COLOUR = mycpgplot::WCSGREEN;
264
265}
266
267#else
268namespace duchamp
269{
270  /// The colour for the text identifying objects on the maps
271  const int DUCHAMP_ID_TEXT_COLOUR = 2;
272  /// The colour for the WCS axes on the maps
273  const int DUCHAMP_WCS_AXIS_COLOUR = 3;
274
275}
276
277#endif
278
279
280#endif
Note: See TracBrowser for help on using the repository browser.