source: trunk/src/param.hh @ 146

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

Corrected bug in FitsHeader::getAvPixScale(), so that it now returns the
correct pixel scale in all instances.
Corrected bug in Col::upPrec() that over-widened some columns.
Minor edits to Detection/outputDetection.cc to improve readability.

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