source: trunk/src/duchamp.hh @ 195

Last change on this file since 195 was 187, checked in by Matthew Whiting, 18 years ago

Large suite of edits, mostly due to testing with valgrind, which clear up bad memory allocations and so on.
Improved the printing of progress bars in some routines by introducing a new ProgressBar? class, with associated functions to do the printing (now much cleaner).

File size: 4.1 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;};
57  ProgressBar(int newlength){length=newlength;};
58  void init(int size){ 
59    std::cout << "|"; printSpace(length);
60    std::cout << "|" << std::flush;
61    fraction = size/length;
62  };
63  void update(int num){
64    if(num%fraction==0){
65      printBackSpace(length+2); std::cout << "|";
66      printHash(num/fraction); printSpace(length-num/fraction);
67      std::cout << "|" << std::flush;
68    }
69  };
70  void rewind(){printBackSpace(length+2);};
71private:
72  int fraction;
73  int length;
74};
75
76// The spectral type that we want the wcsprm structs to be in
77const char duchampVelocityType[9] = "VELO-F2V";
78const char duchampFrequencyType[9] = "FREQ";
79
80enum TYPEDESC {FREQUENCY=0,VELOCITY,WAVELENGTH};
81const std::string duchampSpectralDescription[3]=
82  {"Frequency", "Velocity", "Wavelength"};
83
84// The following are the FITS Header Keywords corresponding to the
85//  parameters related to the atrous reconstruction.
86const std::string keyword_scaleMin   = "DU_MINSC";
87const std::string keyword_snrRecon   = "DU_ATCUT";
88const std::string keyword_reconDim   = "DU_ATDIM";
89const std::string keyword_filterCode = "DU_FILTR";
90const std::string keyword_ReconResid = "DU_RECON";//reconstruction or residual?
91const std::string keyword_subsection = "DU_IMSUB";
92
93// And these are the comments corresponding to the relevant keywords
94const std::string comment_scaleMin   = "Duchamp parameter scaleMin";
95const std::string comment_snrRecon   = "Duchamp parameter snrRecon";
96const std::string comment_reconDim   = "Duchamp parameter reconDim";
97const std::string comment_filterCode = "Duchamp parameter filterCode";
98const std::string comment_ReconResid = "Is this the reconstruction or residual?";
99const std::string comment_subsection = "Subsection of the original image";
100// Descriptive Headers:
101const std::string header_history1 = "Reconstructed with a trous wavelet technique";
102const std::string header_history2 = "Reconstruction by Duchamp v." + VERSION;
103const std::string header_history_input = "Original (input) image used by Duchamp follows";
104const std::string header_subsection_comment  = "A subsection of the original was reconstructed by Duchamp";
105const std::string header_atrous_comment  = "The following are the Duchamp parameters used in reconstruction";
106
107#endif
108
Note: See TracBrowser for help on using the repository browser.