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

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

Changed source tree structure: added a src/ directory that contains all the
code. Makefile.in and configure.ac changed to match.

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