source: branches/fitshead-branch/param.hh @ 1441

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

Four major sets of changes and a couple of minor ones:

  • Changed name of saved recon/resid FITS file, so that it incorporates all reconstruction parameters.
  • Removed MW parameters from header file
  • Added hashed box to be drawn over MW range in spectral plots
  • Fixed bug that meant reon would be done in 1- or 2-d even if recon array has been read in.

Summary:
param.hh -- prototypes for FITS file name calculation functions
param.cc -- FITS file name calculation functions
Cubes/plots.hh -- drawMWRange function
ATrous/ReconSearch.cc -- tests to see if reconExists for 1- and 2-D recon
Cubes/cubes.cc -- work out enclosed flux correctly for flagNegative
Cubes/detectionIO.cc -- added reconDim line to VOTable output
Cubes/outputSpectra.cc -- added code to draw MW range
Cubes/readRecon.cc -- added call to FITS file name function, and removed

MW params and superfluous tests on atrous parameters

Cubes/saveImage.cc -- improved logical flow. added call to FITS file name func

removed MW keywords.

Detection/columns.cc -- added extra column to fluxes if negative.

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