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

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

Large collection of changes. Mostly minor fixes, but major additions are:

  • ability to store flagMW in the recon FITS file
  • slight change to way precision is dealt with in output files
  • improvement to VOTable output
  • generalisation of spectral plotting.

Summary of changes:
duchamp.hh -- added keywords/comments for storing flagMW in FITS files
Utils/wcsFunctions.cc -- minor correction
Cubes/plotting.cc -- minor corrections
Cubes/saveImage.cc -- writing flagMW as header keyword
Cubes/readRecon.cc -- able to read in flagMW. Improved formatting of comments
Cubes/detectionIO.cc -- made VOTable output able to cope with Column

definitions. Added new columns.

Cubes/cubes.hh -- added frontends to wcs-pix functions. Changed prototypes

of some plotting functions.

Cubes/plots.hh -- generalised some functionality of the classes
Cubes/drawMomentCutout.cc -- made a class function
Cubes/outputSpectra.cc -- made a Cube class function that plots a

single spectrum.

param.cc -- improved calling of local variables, and the way units are

dealt with.

docs/example_moment_map.pdf -- new version
docs/cover_image.ps -- new version
docs/example_spectrum.pdf -- new version
docs/cover_image.pdf -- new version
docs/example_moment_map.ps -- new version
docs/example_spectrum.ps -- new version
mainDuchamp.cc -- fixed order of some function calls. Other minor corrections.
ATrous/atrous_2d_reconstruct.cc -- improved speed of loop execution
ATrous/atrous_3d_reconstruct.cc -- improved speed of loop execution
Makefile -- addition of columns.cc
Detection/detection.cc -- minor corrections (removal of commented code)
Detection/outputDetection.cc -- minor change to output style and

precision variable name.

Detection/columns.cc -- use new precision variable
Detection/columns.hh -- new precision variables for position and position

width columns

param.hh -- added prototype for makelower(string) function.

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