source: trunk/src/param.hh @ 170

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

Three changes:

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