source: branches/NewStructure/src/duchamp.hh @ 1441

Last change on this file since 1441 was 1120, checked in by MatthewWhiting, 12 years ago

Ticket #170, #105 - The bulk of the work allowing this to happen. Have implemented different classes for each of the output types, including the baselines (which required new parameters etc.) Not yet implemented in mainDuchamp, so needs testing.

File size: 11.6 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  void duchampFITSerror(int status, std::string subroutine, std::string error);
128
129  /// The spectral type that we want the wcsprm structs to be in.
130  const char duchampVelocityType[9] = "VOPT-F2W";
131  //const char duchampVelocityType[9] = "VELO-F2V";
132  /// The spectral type that we want the wcsprm structs to be in when no velocity info is present.
133  const char duchampFrequencyType[9] = "FREQ    ";
134
135  /// Descriptions of the various spectral axis types
136  enum TYPEDESC {FREQUENCY=0,VELOCITY,WAVELENGTH};
137  /// Human-readable descriptions of the various spectral axis types
138  const std::string duchampSpectralDescription[3]=
139    {"Frequency", "Velocity", "Wavelength"};
140
141  // The following are the FITS Header Keywords corresponding to the
142  // parameters related to the atrous reconstruction.
143
144  /// FITS header keyword for min atrous scale
145  const std::string keyword_scaleMin     = "DU_MINSC";
146  /// FITS header keyword for S/N used in atrous reconstruction
147  const std::string keyword_snrRecon     = "DU_ATCUT";
148  /// FITS header keyword for number of dimensions used in atrous reconstruction
149  const std::string keyword_reconDim     = "DU_ATDIM";
150  /// FITS header keyword for the code number of the filter used in atrous reconstruction
151  const std::string keyword_filterCode   = "DU_FILTR";
152  /// FITS header keyword: does this file hold the reconstructed array or the residual?
153  const std::string keyword_ReconResid   = "DU_RECON";
154  /// FITS header keyword: type of smoothing done.
155  const std::string keyword_smoothtype   = "DU_SMTYP";
156  /// FITS header keyword for the gaussian kernel major axis FWHM
157  const std::string keyword_kernmaj      = "DU_KMAJ";
158  /// FITS header keyword for the gaussian kernel minor axis FWHM
159  const std::string keyword_kernmin      = "DU_KMIN";
160  /// FITS header keyword for the gaussian kernel position angle
161  const std::string keyword_kernpa       = "DU_KPA";
162  /// FITS header keyword for the Hanning filter width
163  const std::string keyword_hanningwidth = "DU_WHANN";
164  /// FITS header keyword for the image subsection used
165  const std::string keyword_subsection   = "DU_IMSUB";
166
167  // And these are the comments corresponding to the relevant keywords
168  /// FITS header comment for DU_MINSC keyword
169  const std::string comment_scaleMin     = "Duchamp parameter scaleMin";
170  /// FITS header comment for DU_ATCUT keyword
171  const std::string comment_snrRecon     = "Duchamp parameter snrRecon";
172  /// FITS header comment for DU_ATDIM keyword
173  const std::string comment_reconDim     = "Duchamp parameter reconDim";
174  /// FITS header comment for DU_FILTR keyword
175  const std::string comment_filterCode   = "Duchamp parameter filterCode";
176  /// FITS header comment for DU_RECON keyword
177  const std::string comment_ReconResid   = "Is this the reconstruction or residual?";
178  /// FITS header comment for DU_SMTYP keyword
179  const std::string comment_smoothtype   = "Type of smoothing done";
180  /// FITS header comment for DU_KMAJ  keyword
181  const std::string comment_kernmaj      = "Duchamp parameter kernMaj";
182  /// FITS header comment for DU_KMIN  keyword
183  const std::string comment_kernmin      = "Duchamp parameter kernMin";
184  /// FITS header comment for DU_KPA   keyword
185  const std::string comment_kernpa       = "Duchamp parameter kernPA";
186  /// FITS header comment for DU_WHANN keyword
187  const std::string comment_hanningwidth = "Duchamp parameter hanningWidth";
188  /// FITS header comment for DU_IMSUB keyword
189  const std::string comment_subsection   = "Subsection of the original image";
190
191  // Descriptive Headers: for the reconstruction case
192  const std::string header_reconHistory1 =
193             "Reconstructed with a trous wavelet technique";
194  const std::string header_reconHistory2 =
195             "Reconstruction by " + PROGNAME + " v." + VERSION;
196  const std::string header_reconHistory_input =
197             "Original (input) image used by " + PROGNAME + " follows";
198  const std::string header_reconSubsection_comment  =
199             "A subsection of the original was reconstructed by " + PROGNAME;
200  const std::string header_atrous_comment  =
201             "The following are the Duchamp parameters used in reconstruction";
202
203  // Descriptive Headers: for the Smoothing case
204  const std::string header_smoothHistory =
205             "Smoothed by " + PROGNAME + " v." + VERSION;
206  const std::string header_smoothHistory_input =
207             "Original (input) image used by " + PROGNAME + " follows";
208  const std::string header_smoothSubsection_comment  =
209             "A subsection of the original was smoothed by " + PROGNAME;
210  const std::string header_smoothSpatial = "Spatial, gaussian kernel";
211  const std::string header_smoothSpectral= "Spectral, hanning filter";
212
213  // Descriptive Headers: for the output Mask image
214  const std::string header_maskHistory =
215             "Results of searching by " + PROGNAME + " v." + VERSION;
216  const std::string header_maskHistory_input =
217             "Input image used by " + PROGNAME + " follows";
218  const std::string header_maskSubsection_comment =
219             "A subsection of the original was searched by " + PROGNAME;
220
221  // Descriptive Headers: for the output Baseline image
222  const std::string header_baselineHistory =
223             "Results of baseline extraction by " + PROGNAME + " v." + VERSION;
224  const std::string header_baselineHistory_input =
225             "Input image used by " + PROGNAME + " follows";
226  const std::string header_baselineSubsection_comment =
227             "A subsection of the original was searched by " + PROGNAME;
228
229  // Descriptive Headers: for the output Moment-0 image
230  const std::string header_moment0History =
231             "Moment-0 map from searching by " + PROGNAME + " v." + VERSION;
232  const std::string header_moment0History_input =
233             "Input image used by " + PROGNAME + " follows";
234  const std::string header_moment0Subsection_comment =
235             "A subsection of the original was searched by " + PROGNAME;
236
237  // Default colour used for the annotation files
238  const std::string annotationColour = "RED";
239
240}
241
242#ifdef HAVE_PGPLOT
243namespace duchamp
244{
245
246  // Colours used in graphical output
247  /// The colour for the Blank edges
248  const int DUCHAMP_BLANK_EDGE_COLOUR = mycpgplot::MAGENTA;
249  /// The colour for the edge of the cube
250  const int DUCHAMP_CUBE_EDGE_COLOUR = mycpgplot::YELLOW;
251  /// The colour for the reconstructed spectra
252  const int DUCHAMP_RECON_SPECTRA_COLOUR = mycpgplot::RED;
253  /// The colour for the baseline spectra
254  const int DUCHAMP_BASELINE_SPECTRA_COLOUR = mycpgplot::YELLOW;
255  /// The colour for the object outline
256  const int DUCHAMP_OBJECT_OUTLINE_COLOUR = mycpgplot::BLUE;
257  /// The colour for the Milky-way region spectral boundaries
258  const int DUCHAMP_MILKY_WAY_COLOUR = mycpgplot::DARKGREEN;
259  /// The colour for the tick marks in the image cutouts
260  const int DUCHAMP_TICKMARK_COLOUR = mycpgplot::RED;
261  /// The colour for the text identifying objects on the maps
262  const int DUCHAMP_ID_TEXT_COLOUR = mycpgplot::RED;
263  /// The colour for the WCS axes on the maps
264  const int DUCHAMP_WCS_AXIS_COLOUR = mycpgplot::WCSGREEN;
265
266}
267
268#else
269namespace duchamp
270{
271  /// The colour for the text identifying objects on the maps
272  const int DUCHAMP_ID_TEXT_COLOUR = 2;
273  /// The colour for the WCS axes on the maps
274  const int DUCHAMP_WCS_AXIS_COLOUR = 3;
275
276}
277
278#endif
279
280
281#endif
Note: See TracBrowser for help on using the repository browser.