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

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

Two sets of large changes:
1) Added reconDim, to select which dimension of reconstruction to use.
2) Changed the way the MW channels are dealt with -- now not set to 0. but

simply ignored for searching purposes.

Summary of changes for each file:
duchamp.hh -- added keyword info for reconDim
param.hh -- Introduced reconDim and flagUsingBlank and isInMW.
param.cc -- Introduced reconDim and flagUsingBlank: initialisation etc commands
InputComplete? -- Added reconDim info
mainDuchamp.cc -- Removed the removeMW call. Changed search function names
docs/Guide.tex -- New code to deal with changes: reconDim, MW removal,

up-to-date output examples, better hints & notes section

Detection/thresholding_functions.cc -- minor typo correction

Cubes/cubes.hh -- added isBlank and removeMW functions in Image class, and

renamed search function prototypes

Cubes/cubes.cc -- added removeMW function for Image class, cleaned up

Cube::removeMW as well (although now not used)

Cubes/outputSpectra.cc -- Improved use of isBlank and isInMW functions: now

show MW channels but don't use them in calculating
the flux range

Cubes/getImage.cc -- added line to indicate whether the Param's blank value

is being used, rather than the FITS header.

Cubes/cubicSearch.cc -- renamed functions: front end is now CubicSearch?, and

searching function is search3DArray.

-- Improved way MW removal is dealt with. Changed

location of stats calculations.

Cubes/saveImage.cc -- added code for saving reconDim info
Cubes/readRecon.cc -- added code for reading reconDim info (and added status

intialisations before all cfitsio commands)

ATrous/ReconSearch.cc -- renamed functions: front end is now ReconSearch?, and

searching function is searchReconArray.
Using reconDim to decide which reconstruction to use.

-- Improved way MW removal is dealt with. Changed

location of stats calculations.

ATrous/atrous_1d_reconstruct.cc -- using Median stats
ATrous/atrous_2d_reconstruct.cc -- made code up to date, to conform with 1- &

3-d code. Removed boundary conditions.

ATrous/atrous_3d_reconstruct.cc -- corrected typo (avGapY /= float(xdim)).

Using median stats.

Cubes/cubicSearchNMerge.cc -- Deleted. (not used)
Cubes/readParams.cc -- Deleted. (not used)

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