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

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

Several bug fixes:

  • The determination of the blank pixel value was not working correctly, due

to confusion between which out of par and head had the correct values.
getCube now reads the header values into the FitsHeader? class, and then these
are copied into the Param class by the new function Param::copyHeaderInfo.

  • The zoom box in the spectral output was scaling the flux scale by all data

points, and this caused problems when the MW channels were in view. These
channels are now omitted in the determination of the flux axis range.

  • The precision in the implied position given by the IAU name has been

increased -- it is now of the format J125345-362412 or G323.124+05.457.

Also added a CHANGES file, as we want to go to v.1.0.1, and updated
the version number in configure.ac.

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