source: trunk/src/duchamp.hh @ 204

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

A large commit, based on improving memory usage, allocation, etc:

  • src/param.hh :
    • Added a delete command for the offsets array in Param. Keep track of size via new sizeOffsets variable.
    • Changed "wcsprm" to "struct wcsprm", for clarity.
    • Put wcsvfree in the FitsHeader? destructor so that memory is deallocated correctly.
  • src/param.cc :
    • Improved the FitsHeader? constructor functions, so that memory for the wcsprm structures is allocated appropriately.
    • Other wcsprm-related tweaks.
    • Included code for sizeOffsets -- the size of the offsets array in Param, so that we can properly deallocate its memory in the destructor function.
  • src/FitsIO/subsection.cc : Changed "wcsprm" to "struct wcsprm", for clarity, and added a sizeOffsets to track the memory allocation for offsets.
  • src/FitsIO/dataIO.cc : renamed the local variable array to pixarray so that there is no confusion. Added delete[] commands for local arrays.
  • src/FitsIO/wcsIO.cc : Improved the struct wcsprm memory allocation. Now using a local wcs variable so that we don't get confusion with the FitsHeader? one.
  • src/Utils/wcsFunctions.cc : changed "wcsprm" to "struct wcsprm", for clarity.
  • src/Cubes/CubicSearch.cc : removed two allocation calls (to new) that were not needed, as well as unused commented-out code.
  • src/Cubes/plotting.cc :
    • Corrected the way the detection map is worked out and the scale bar range calculated.
    • Changed "wcsprm" to "struct wcsprm", for clarity.
  • src/duchamp.hh : better implementation of the rewind() and remove() functions for ProgressBar?
  • src/Utils/getStats.cc : minor diffs
  • src/Utils/utils.hh : changed prototypes
  • src/Cubes/cubes.cc : Changed the way the setCubeStats() function works, so that stats aren't needlessly calculated if the threshold has already been specified.
  • src/Cubes/cubes.hh : minor presentation changes
  • src/Cubes/drawMomentCutout.cc : Tried to improve the scale-bar drawing function, to cope with very high angular resolution data. Not quite working properly yet.
  • src/Cubes/outputSpectra.cc : Corrected the flux labels so that the appropriate units are used, and not just Jy or Jy/beam.
File size: 4.5 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 or residual?
113const std::string keyword_subsection = "DU_IMSUB";
114
115// And these are the comments corresponding to the relevant keywords
116const std::string comment_scaleMin   = "Duchamp parameter scaleMin";
117const std::string comment_snrRecon   = "Duchamp parameter snrRecon";
118const std::string comment_reconDim   = "Duchamp parameter reconDim";
119const std::string comment_filterCode = "Duchamp parameter filterCode";
120const std::string comment_ReconResid = "Is this the reconstruction or residual?";
121const std::string comment_subsection = "Subsection of the original image";
122// Descriptive Headers:
123const std::string header_history1 = "Reconstructed with a trous wavelet technique";
124const std::string header_history2 = "Reconstruction by Duchamp v." + VERSION;
125const std::string header_history_input = "Original (input) image used by Duchamp follows";
126const std::string header_subsection_comment  = "A subsection of the original was reconstructed by Duchamp";
127const std::string header_atrous_comment  = "The following are the Duchamp parameters used in reconstruction";
128
129#endif
130
Note: See TracBrowser for help on using the repository browser.