source: tags/release-1.0.6/src/param.hh @ 813

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

Implemented a request (from ticket:1) for the ability to not display the pgplot
window showing the moment map. This is now switched on and off by the
flagXOutput parameter.
Updated code and documentation.

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