source: tags/release-1.0.2/src/param.hh @ 1323

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

Introduced error and warning reporting functions, to normalise the format
of errors and warnings. Definitions of functions go in duchamp.cc.
Changed all code that reports errors/warnings to use these new functions.

Fixed a couple of bugs that affected the way 2D images were dealt with:
ReconSearch? now looks at how many dimensions there are in the data array
before choosing the dimension of the reconstruction, and the minChannels
test was improved for the case of minChannels=0.

Some minor additions made to the Guide as well.

File size: 14.9 KB
Line 
1#ifndef PARAM_H
2#define PARAM_H
3
4#include <iostream>
5#include <string>
6#include <vector>
7#include <wcs.h>
8
9using std::string;
10using std::vector;
11
12/**
13 * Param class.
14 *   Used for storing parameters used by all functions.
15 */
16
17class FitsHeader; // foreshadow this so that Param knows it exists
18
19class Param
20{
21public:
22  Param();
23  virtual ~Param(){};
24  void parseSubsection();               // in param.cc
25  void readParams(string paramfile);    // in param.cc
26  void copyHeaderInfo(FitsHeader &head);// in param.cc
27  bool isBlank(float &value);           // in param.cc
28  bool isInMW(int z){return ( this->flagMW && (z>=this->minMW) && (z<=this->maxMW) );};
29  string outputReconFile();             // in param.cc
30  string outputResidFile();             // in param.cc
31  friend std::ostream& operator<< ( std::ostream& theStream, Param& par);
32  friend class Image;
33 
34  //
35  string getImageFile(){return imageFile;};
36  void   setImageFile(string fname){imageFile = fname;};
37  string getFullImageFile(){
38    if(flagSubsection) return imageFile+subsection;
39    else return imageFile;
40  };
41  bool   getFlagSubsection(){return flagSubsection;};
42  void   setFlagSubsection(bool flag){flagSubsection=flag;};
43  string getSubsection(){return subsection;};
44  void   setSubsection(string range){subsection = range;};
45  bool   getFlagReconExists(){return flagReconExists;};
46  void   setFlagReconExists(bool flag){flagReconExists=flag;};
47  string getReconFile(){return reconFile;};
48  void   setReconFile(string file){reconFile = file;};
49  //
50  bool   getFlagLog(){return flagLog;};
51  void   setFlagLog(bool flag){flagLog=flag;};
52  string getLogFile(){return logFile;};
53  void   setLogFile(string fname){logFile = fname;};
54  string getOutFile(){return outFile;};
55  void   setOutFile(string fname){outFile = fname;};
56  string getSpectraFile(){return spectraFile;};
57  void   setSpectraFile(string fname){spectraFile = fname;};
58  bool   getFlagOutputRecon(){return flagOutputRecon;};
59  void   setFlagOutputRecon(bool flag){flagOutputRecon=flag;};
60  bool   getFlagOutputResid(){return flagOutputResid;};
61  void   setFlagOutputResid(bool flag){flagOutputResid=flag;};
62  bool   getFlagVOT(){return flagVOT;};
63  void   setFlagVOT(bool flag){flagVOT=flag;};
64  string getVOTFile(){return votFile;};
65  void   setVOTFile(string fname){votFile = fname;};
66  bool   getFlagKarma(){return flagKarma;};
67  void   setFlagKarma(bool flag){flagKarma=flag;};
68  string getKarmaFile(){return karmaFile;};
69  void   setKarmaFile(string fname){karmaFile = fname;};
70  bool   getFlagMaps(){return flagMaps;};
71  void   setFlagMaps(bool flag){flagMaps=flag;};
72  string getDetectionMap(){return detectionMap;};
73  void   setDetectionMap(string fname){detectionMap = fname;};
74  string getMomentMap(){return momentMap;};
75  void   setMomentMap(string fname){momentMap = fname;};
76  //
77  bool   getFlagNegative(){return flagNegative;};
78  void   setFlagNegative(bool flag){flagNegative=flag;};
79  bool   getFlagBlankPix(){return flagBlankPix;};
80  void   setFlagBlankPix(bool flag){flagBlankPix=flag;};
81  float  getBlankPixVal(){return blankPixValue;};
82  void   setBlankPixVal(float v){blankPixValue=v;};
83  int    getBlankKeyword(){return blankKeyword;};
84  void   setBlankKeyword(int v){blankKeyword=v;};
85  float  getBscaleKeyword(){return bscaleKeyword;};
86  void   setBscaleKeyword(float v){bscaleKeyword=v;};
87  float  getBzeroKeyword(){return bzeroKeyword;};
88  void   setBzeroKeyword(float v){bzeroKeyword=v;};
89  bool   getFlagUsingBlank(){return flagUsingBlank;};
90  void   setFlagUsingBlank(bool b){flagUsingBlank=b;};
91  bool   getFlagMW(){return flagMW;};
92  bool   setFlagMW(bool flag){flagMW=flag;};
93  int    getMaxMW(){return maxMW;};
94  void   setMaxMW(int m){maxMW=m;};
95  int    getMinMW(){return minMW;};
96  void   setMinMW(int m){minMW=m;};
97  void   setBeamSize(float s){numPixBeam = s;};
98  float  getBeamSize(){return numPixBeam;};
99  //
100  bool   getFlagCubeTrimmed(){return flagTrimmed;};
101  void   setFlagCubeTrimmed(bool flag){flagTrimmed = flag;};
102  long   getBorderLeft(){return borderLeft;};
103  void   setBorderLeft(long b){borderLeft = b;};
104  long   getBorderRight(){return borderRight;};
105  void   setBorderRight(long b){borderRight = b;};
106  long   getBorderBottom(){return borderBottom;};
107  void   setBorderBottom(long b){borderBottom = b;};
108  long   getBorderTop(){return borderTop;};
109  void   setBorderTop(long b){borderTop = b;};
110  //
111  long   getXOffset(){return xSubOffset;};
112  void   setXOffset(long o){xSubOffset = o;};
113  long   getYOffset(){return ySubOffset;};
114  void   setYOffset(long o){ySubOffset = o;};
115  long   getZOffset(){return zSubOffset;};
116  void   setZOffset(long o){zSubOffset = o;};
117  //
118  int    getMinPix(){return minPix;};
119  void   setMinPix(int m){minPix=m;};
120  //     
121  bool   getFlagGrowth(){return flagGrowth;};
122  void   setFlagGrowth(bool flag){flagGrowth=flag;};
123  float  getGrowthCut(){return growthCut;};
124  void   setGrowthCut(float c){growthCut=c;};
125  //     
126  bool   getFlagFDR(){return flagFDR;};
127  void   setFlagFDR(bool flag){flagFDR=flag;};
128  float  getAlpha(){return alphaFDR;};
129  void   setAlpha(float a){alphaFDR=a;};
130  //
131  bool   getFlagBaseline(){return flagBaseline;};
132  void   setFlagBaseline(bool flag){flagBaseline = flag;};
133  //
134  float  getCut(){return snrCut;};
135  void   setCut(float c){snrCut=c;};
136  //     
137  bool   getFlagATrous(){return flagATrous;};
138  void   setFlagATrous(bool flag){flagATrous=flag;};
139  int    getReconDim(){return reconDim;};
140  void   setReconDim(int i){reconDim=i;};
141  int    getMinScale(){return scaleMin;};
142  void   setMinScale(int s){scaleMin=s;};
143  float  getAtrousCut(){return snrRecon;};
144  void   setAtrousCut(float c){snrRecon=c;};
145  int    getFilterCode(){return filterCode;};
146  void   setFilterCode(int c){filterCode=c;};
147  string getFilterName(){return filterName;};
148  void   setFilterName(string s){filterName=s;};
149  //     
150  bool   getFlagAdjacent(){return flagAdjacent;};
151  void   setFlagAdjacent(bool flag){flagAdjacent=flag;};
152  float  getThreshS(){return threshSpatial;};
153  void   setThreshS(float t){threshSpatial=t;};
154  float  getThreshV(){return threshVelocity;};
155  void   setThreshV(float t){threshVelocity=t;};
156  int    getMinChannels(){return minChannels;};
157  void   setMinChannels(int n){minChannels=n;};
158  //
159  string getSpectralMethod(){return spectralMethod;};
160  void   setSpectralMethod(string s){spectralMethod=s;};
161  string getSpectralUnits(){return spectralUnits;};
162  void   setSpectralUnits(string s){spectralUnits=s;};
163  bool   drawBorders(){return borders;};
164  void   setDrawBorders(bool f){borders=f;};
165  bool   isVerbose(){return verbose;};
166  void   setVerbosity(bool f){verbose=f;};
167 
168private:
169  // Input files
170  string imageFile;       // The image to be analysed.
171  bool   flagSubsection;  // Whether we just want a subsection of the image
172  string subsection;      // The subsection requested, of the form [x1:x2,y1:y2,z1:z2]
173                          //   If you want the full range of one index, use *
174  bool   flagReconExists; // The reconstructed array is in a FITS file on disk.
175  string reconFile;       // The FITS file containing the reconstructed array.
176
177  // Output files
178  bool   flagLog;         // Should we do the intermediate logging?
179  string logFile;         // Where the intermediate logging goes.
180  string outFile;         // Where the final results get put.
181  string spectraFile;     // Where the spectra are displayed
182  bool   flagOutputRecon; // Should the reconstructed cube be written?
183  bool   flagOutputResid; // Should the reconstructed cube be written?
184  bool   flagVOT;         // Should we save results in VOTable format?
185  string votFile;         // Where the VOTable goes.
186  bool   flagKarma;       // Should we save results in Karma annotation format?
187  string karmaFile;       // Where the Karma annotation file goes.
188  bool   flagMaps;        // Should we produce detection and moment maps in postscript form?
189  string detectionMap;    // The name of the detection map (ps file).
190  string momentMap;       // The name of the 0th moment map (ps file).
191
192  // Cube related parameters
193  bool   flagNegative;    // Are we going to search for negative features?
194  bool   flagBlankPix;    // A flag that indicates whether there are pixels
195                          //   defined as BLANK and whether we need to remove
196                          //   & ignore them in processing.
197  float  blankPixValue;   // Pixel value that is considered BLANK.
198  int    blankKeyword;    // The FITS header keyword BLANK.
199  float  bscaleKeyword;   // The FITS header keyword BSCALE.
200  float  bzeroKeyword;    // The FITS header keyword BZERO.
201  bool   flagUsingBlank;  // If true, we are using the blankPixValue keyword,
202                          // otherwise we are using the value in the FITS header.
203  bool   flagMW;          // A flag that indicates whether to excise the Milky Way.
204  int    maxMW;           // Last  Galactic velocity plane for HIPASS cubes
205  int    minMW;           // First Galactic velocity plane for HIPASS cubes
206  float  numPixBeam;      // Size (area) of the beam in pixels.
207  // Trim-related         
208  bool   flagTrimmed;     // Has the cube been trimmed of excess BLANKs around the edge?
209  long   borderLeft;      // The number of BLANK pixels trimmed from the Left of the cube;
210  long   borderRight;     // The number of BLANK pixels trimmed from the Right of the cube;
211  long   borderBottom;    // The number of BLANK pixels trimmed from the Bottom of the cube;
212  long   borderTop;       // The number of BLANK pixels trimmed from the Top of the cube;
213  // Subsection offsets
214  long   xSubOffset;      // The offset in the x-direction from the subsection
215  long   ySubOffset;      // The offset in the y-direction from the subsection
216  long   zSubOffset;      // The offset in the z-direction from the subsection
217  // Baseline related;
218  bool   flagBaseline;    // Whether to do baseline subtraction before reconstruction and/or searching.
219  // Detection-related   
220  int    minPix;          // Minimum number of pixels for a detected object to be counted
221  // Object growth       
222  bool   flagGrowth;      // Are we growing objects once they are found?
223  float  growthCut;       // The SNR that we are growing objects down to.
224  // FDR analysis         
225  bool   flagFDR;         // Should the FDR method be used?
226  float  alphaFDR;        // Alpha value for FDR detection algorithm
227  // Other detection     
228  float  snrCut;          // How many sigma above mean is a detection when sigma-clipping
229  // A trous reconstruction parameters
230  bool   flagATrous;      // Are we using the a trous reconstruction?
231  int    reconDim;        // How many dimensions to use for the reconstruction?
232  int    scaleMin;        // Min scale used in a trous reconstruction
233  float  snrRecon;        // SNR cutoff used in a trous reconstruction
234                          //   (only wavelet coefficients that survive this threshold are kept)
235  int    filterCode;      // The code number for the filter to be used (saves having to parse names)
236  string filterName;      // The code number converted into a name, for outputting purposes.
237
238  // Volume-merging parameters
239  bool   flagAdjacent;    // Whether to use the adjacent criterion for
240                          //    judging if objects are to be merged.
241  float  threshSpatial;   // Maximum spatial separation between objects
242  float  threshVelocity;  // Maximum channels separation between objects
243  int    minChannels;     // Minimum no. of channels to make an object
244  // Input-Output related
245  string spectralMethod;  // A string indicating choice of spectral plotting method:
246                          //   choices are "peak" or "sum" (peak is the default).
247  string spectralUnits;   // A string indicating what units the spectral axis should be quoted in.
248  bool   borders;         // Whether to draw a border around the individual
249                          //   pixels of a detection in the spectral display
250  bool   verbose;         // Whether to use maximum verbosity -- progress indicators in the
251                          //   reconstruction & merging functions.
252
253};
254
255class FitsHeader
256{
257  /**
258   *  FitsHeader Class
259   *
260   *   Stores information from a FITS header, including WCS information
261   *    in the form of a wcsprm struct, as well as various keywords.
262   */
263
264public:
265  FitsHeader();
266  ~FitsHeader(){};
267  FitsHeader(const FitsHeader& h);
268  FitsHeader& operator= (const FitsHeader& h);
269
270  wcsprm *getWCS();             // in param.cc
271  void    setWCS(wcsprm *w);    // in param.cc
272  bool    isWCS(){return wcsIsGood;};
273  int     getNWCS(){return nwcs;};
274  void    setNWCS(int i){nwcs=i;};
275  string  getSpectralUnits(){return spectralUnits;};
276  void    setSpectralUnits(string s){spectralUnits=s;};
277  string  getFluxUnits(){return fluxUnits;};
278  void    setFluxUnits(string s){fluxUnits=s;};
279  string  getIntFluxUnits(){return intFluxUnits;};
280  void    setIntFluxUnits(string s){intFluxUnits=s;};
281  float   getBeamSize(){return beamSize;};
282  void    setBeamSize(float f){beamSize=f;};
283  float   getBmajKeyword(){return bmajKeyword;};
284  void    setBmajKeyword(float f){bmajKeyword=f;};
285  float   getBminKeyword(){return bminKeyword;};
286  void    setBminKeyword(float f){bminKeyword=f;};
287  int     getBlankKeyword(){return blankKeyword;};
288  void    setBlankKeyword(int f){blankKeyword=f;};
289  float   getBzeroKeyword(){return bzeroKeyword;};
290  void    setBzeroKeyword(float f){bzeroKeyword=f;};
291  float   getBscaleKeyword(){return bscaleKeyword;};
292  void    setBscaleKeyword(float f){bscaleKeyword=f;};
293
294  // front ends to WCS functions
295  int     wcsToPix(const double *world, double *pix);
296  int     pixToWCS(const double *pix, double *world);
297  int     wcsToPix(const double *world, double *pix, const int npts);
298  int     pixToWCS(const double *pix, double *world, const int npts);
299  double  pixToVel(double &x, double &y, double &z);
300  double *pixToVel(double &x, double &y, double *zarray, int size);
301  double  specToVel(const double &z);
302  double  velToSpec(const float &vel);
303  string  getIAUName(double ra, double dec);
304
305  void    fixUnits(Param &par);
306 
307private:
308  wcsprm *wcs;             // The WCS parameters for the cube -- a struct from wcslib
309  int     nwcs;            // The number of WCS parameters
310  bool    wcsIsGood;       // A flag indicating whether there is a valid WCS present.
311  string  spectralUnits;   // The units of the spectral dimension
312  string  fluxUnits;       // The units of pixel flux (from header)
313  string  intFluxUnits;    // The units of pixel flux (from header)
314  float   beamSize;        // The calculated beam size in pixels.
315  float   bmajKeyword;     // The FITS header keyword BMAJ.
316  float   bminKeyword;     // The FITS header keyword BMIN.
317  int     blankKeyword;    // The FITS header keyword BLANK.
318  float   bzeroKeyword;    // The FITS header keyword BZERO.
319  float   bscaleKeyword;   // The FITS header keyword BSCALE.
320  double  scale;           // scale parameter for converting spectral coords
321  double  offset;          // offset parameter for converting spectral coords
322  double  power;           // power parameter for converting spectral coords
323};
324
325string makelower( string s );
326
327#endif
Note: See TracBrowser for help on using the repository browser.