source: trunk/src/duchamp.hh @ 208

Last change on this file since 208 was 208, checked in by Matthew Whiting, 18 years ago
  • Enabled saving and reading in of a smoothed array, in manner directly analogous to that for the recon array.
    • New file : src/Cubes/readSmooth.cc
    • The other new functions go in existing files eg. saveImage.cc
    • Renamed some functions (like writeHeader...) to be more obvious what they do.
    • The reading in is taken care of by new function Cube::readSavedArrays() -- handles both smoothed and recon'd arrays.
    • Associated parameters in Param class
    • Clarified names of FITS header strings in duchamp.hh.
  • Updated the documentation to describe the ability to smooth a cube.
  • Added description of feedback mechanisms in the Install appendix.
  • Also, Hanning class improved to guard against memory leaks.


File size: 5.0 KB
Line 
1/* src/duchamp.hh.  Generated by configure.  */
2#ifndef DUCHAMP_HH
3#define DUCHAMP_HH
4
5#include <iostream>
6#include <string>
7
8#undef PACKAGE_BUGREPORT
9#undef PACKAGE_NAME
10#undef PACKAGE_STRING
11#undef PACKAGE_TARNAME
12#undef PACKAGE_VERSION
13#include "config.h"
14
15// how to convey whether a function has worked
16enum OUTCOME {SUCCESS=0, FAILURE};
17
18const std::string ERR_USAGE_MSG =
19"Usage:: Duchamp -p [parameter file]\n\
20  Other options:\n\
21    -f <file>  Use default parameters with imageFile=<file>\n\
22    -v         Version number\n\
23    -h         This help information\n";
24
25const std::string ERR_USAGE_MSG_SHORT="Usage:: Duchamp -p [parameter file]\n";
26
27const std::string PROGNAME = PACKAGE_NAME;
28
29const std::string VERSION = PACKAGE_VERSION;
30
31// Specialised functions to report warnings and errors.
32// These are defined in duchamp.cc
33void duchampWarning(std::string subroutine, std::string warning);
34void duchampError(std::string subroutine, std::string error);
35
36// A simple functions to print a given number of backspaces or spaces
37//  to std::cout
38inline void printBackSpace(int num){for(int i=0;i<num;i++) std::cout << '\b';};
39inline void printSpace(int num){ for(int i=0;i<num;i++) std::cout << ' '; };
40inline void printHash(int num){ for(int i=0;i<num;i++) std::cout << '#'; };
41class ProgressBar
42{
43  /**
44   *  ProgressBar Class
45   *   A class that prints out a progress bar in the form |####    |
46   *    that shows how far through a function or loop you are.
47   *   The length of it defaults to 20, but can be set when declaring the
48   *    object.
49   *   There are three functions:
50   *        init(size) --> prints an empty bar, and defines the increment
51   *        update(num) --> prints the correct number of #s, but only when
52   *                        num is a multiple of the increment.
53   *        rewind(num) --> prints backspaces to cover the entire bar.
54   */
55public:
56  ProgressBar(){length=20; loc=BEG;};
57  ProgressBar(int newlength){length=newlength; loc=BEG;};
58  enum POS {BEG=0,END};
59
60  void init(int size){ 
61    std::cout << "|"; printSpace(length);
62    std::cout << "|" << std::flush;
63    fraction = size/length;
64    loc = END;
65  };
66  void update(int num){
67    if(num%fraction==0){
68      printBackSpace(length+2); std::cout << "|";
69      printHash(num/fraction); printSpace(length-num/fraction);
70      std::cout << "|" << std::flush;
71    }
72    loc=END;
73  };
74  void rewind(){
75    if(loc==END) printBackSpace(length+2);
76    loc=BEG;
77    std::cout << std::flush;
78  };
79  void remove(){
80    rewind();
81    printSpace(length+2);
82    loc=END;
83    rewind();
84    std::cout << std::flush;
85  };
86  void fillSpace(std::string someString){
87    rewind();
88    std::cout << someString;
89    printSpace(length+2-someString.size());
90    loc=END;
91  }
92private:
93  POS loc;
94  int fraction;
95  int length;
96};
97
98// The spectral type that we want the wcsprm structs to be in
99const char duchampVelocityType[9] = "VELO-F2V";
100const char duchampFrequencyType[9] = "FREQ";
101
102enum TYPEDESC {FREQUENCY=0,VELOCITY,WAVELENGTH};
103const std::string duchampSpectralDescription[3]=
104  {"Frequency", "Velocity", "Wavelength"};
105
106// The following are the FITS Header Keywords corresponding to the
107//  parameters related to the atrous reconstruction.
108const std::string keyword_scaleMin     = "DU_MINSC";
109const std::string keyword_snrRecon     = "DU_ATCUT";
110const std::string keyword_reconDim     = "DU_ATDIM";
111const std::string keyword_filterCode   = "DU_FILTR";
112const std::string keyword_ReconResid   = "DU_RECON";//reconstruction/residual?
113const std::string keyword_hanningwidth = "DU_WHANN"; // hanning width
114const std::string keyword_subsection   = "DU_IMSUB";
115
116// And these are the comments corresponding to the relevant keywords
117const std::string comment_scaleMin     = "Duchamp parameter scaleMin";
118const std::string comment_snrRecon     = "Duchamp parameter snrRecon";
119const std::string comment_reconDim     = "Duchamp parameter reconDim";
120const std::string comment_filterCode   = "Duchamp parameter filterCode";
121const std::string comment_ReconResid   = "Is this the reconstruction or residual?";
122const std::string comment_hanningwidth = "Duchamp parameter hanningWidth";
123const std::string comment_subsection   = "Subsection of the original image";
124
125// Descriptive Headers: for the reconstruction case
126const std::string header_reconHistory1 =
127"Reconstructed with a trous wavelet technique";
128const std::string header_reconHistory2 =
129"Reconstruction by Duchamp v." + VERSION;
130const std::string header_reconHistory_input =
131"Original (input) image used by Duchamp follows";
132const std::string header_reconSubsection_comment  =
133"A subsection of the original was reconstructed by Duchamp";
134const std::string header_atrous_comment  =
135"The following are the Duchamp parameters used in reconstruction";
136
137// Descriptive Headers: for the Hanning-smoothing case
138const std::string header_smoothHistory =
139"Hanning smoothed by Duchamp v." + VERSION;
140const std::string header_smoothHistory_input =
141"Original (input) image used by Duchamp follows";
142const std::string header_smoothSubsection_comment  =
143"A subsection of the original was smoothed by Duchamp";
144
145#endif
146
Note: See TracBrowser for help on using the repository browser.