source: trunk/src/param.hh @ 378

Last change on this file since 378 was 378, checked in by MatthewWhiting, 17 years ago

Large amount of changes, but really just making a "duchamp" namespace to encompass duchamp-specific stuff. Not the PixelMap? stuff though.

File size: 20.2 KB
Line 
1// -----------------------------------------------------------------------
2// param.hh: Definition of the parameter set.
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#ifndef PARAM_H
29#define PARAM_H
30
31#include <iostream>
32#include <string>
33#include <vector>
34#include <math.h>
35#include <wcs.h>
36#include <wcshdr.h>
37#include <Utils/Section.hh>
38#include <ATrous/filter.hh>
39
40namespace duchamp
41{
42
43
44  class FitsHeader; // foreshadow this so that Param knows it exists
45
46  /**
47   * Class to store general parameters.
48   *
49   * This is a general repository for parameters that are used by all
50   * functions. This is how the user interacts with the program, as
51   * parameters are read in from disk files through functions in this
52   * class.
53   */
54
55  class Param
56  {
57  public:
58    /** Default constructor. */
59    Param();
60
61    /** Copy constructor for Param. */
62    Param(const Param& p);
63
64    /** Assignment operator for Param.*/
65    Param& operator= (const Param& p);
66
67    /** Destructor function.  */
68    virtual ~Param();
69
70    /** Define the default values of each parameter.*/
71    void  defaultValues();
72
73    //-----------------
74    // Functions in param.cc
75    //
76    /** Parse the command line parameters correctly. */
77    int    getopts(int argc, char ** argv);
78
79    /** Read in parameters from a disk file. */
80    int    readParams(std::string paramfile);
81
82    /** Copy certain necessary FITS header parameters from a FitsHeader
83        object */
84    void   copyHeaderInfo(FitsHeader &head);
85
86    /** Determine filename in which to save the smoothed array. */
87    std::string outputSmoothFile();
88
89    /** Determine filename in which to save the reconstructed array. */
90    std::string outputReconFile();
91
92    /** Determine filename in which to save the residual array from the
93        atrous reconstruction. */
94    std::string outputResidFile();
95
96    /** Print the parameter set in a readable fashion. */
97    friend std::ostream& operator<< ( std::ostream& theStream, Param& par);
98    friend class Image;
99
100    //------------------
101    // Functions in FitsIO/subsection.cc
102    //
103    /** Make sure the subsection strings are OK. */
104    int    verifySubsection();
105
106    /** Set the correct offset values for each axis */
107    void   setOffsets(struct wcsprm *wcs);
108
109    /** Set the correct offset values for each axis */
110    void   setOffsets(struct wcsprm &wcs);
111
112    //------------------
113    // These are in param.cc
114    /** Is a pixel value a BLANK? */
115    bool   isBlank(float &value);
116
117    /** Is a given channel flagged as being in the Milky Way?*/           
118    bool   isInMW(int z);
119
120    /** Is a given pixel position OK for use with stats calculations? */
121    bool   isStatOK(int x, int y, int z);
122
123    /** Make a mask array -- an array saying whether each pixel is BLANK
124        or not*/
125    bool  *makeBlankMask(float *array, int size);
126
127
128    //--------------------
129    // Basic inline accessor functions
130    //
131    std::string getImageFile(){return imageFile;};
132    void   setImageFile(std::string fname){imageFile = fname;};
133    std::string getFullImageFile(){
134      if(flagSubsection) return imageFile+pixelSec.getSection();
135      else return imageFile;
136    };
137    bool   getFlagSubsection(){return flagSubsection;};
138    void   setFlagSubsection(bool flag){flagSubsection=flag;};
139    std::string getSubsection(){return pixelSec.getSection();};
140    void   setSubsection(std::string range){pixelSec.setSection(range);};
141    Section &section(){Section &rsection = pixelSec; return rsection;};
142    bool   getFlagReconExists(){return flagReconExists;};
143    void   setFlagReconExists(bool flag){flagReconExists=flag;};
144    std::string getReconFile(){return reconFile;};
145    void   setReconFile(std::string file){reconFile = file;};
146    bool   getFlagSmoothExists(){return flagSmoothExists;};
147    void   setFlagSmoothExists(bool flag){flagSmoothExists=flag;};
148    std::string getSmoothFile(){return smoothFile;};
149    void   setSmoothFile(std::string file){smoothFile = file;};
150    //
151    bool   getFlagLog(){return flagLog;};
152    void   setFlagLog(bool flag){flagLog=flag;};
153    std::string getLogFile(){return logFile;};
154    void   setLogFile(std::string fname){logFile = fname;};
155    std::string getOutFile(){return outFile;};
156    void   setOutFile(std::string fname){outFile = fname;};
157    bool   getFlagSeparateHeader(){return flagSeparateHeader;};
158    void   setFlagSeparateHeader(bool b){flagSeparateHeader=b;};
159    std::string getHeaderFile(){return headerFile;};
160    void   setHeaderFile(std::string s){headerFile=s;};
161    std::string getSpectraFile(){return spectraFile;};
162    void   setSpectraFile(std::string fname){spectraFile = fname;};
163    bool   getFlagOutputSmooth(){return flagOutputSmooth;};
164    void   setFlagOutputSmooth(bool flag){flagOutputSmooth=flag;};
165    bool   getFlagOutputRecon(){return flagOutputRecon;};
166    void   setFlagOutputRecon(bool flag){flagOutputRecon=flag;};
167    bool   getFlagOutputResid(){return flagOutputResid;};
168    void   setFlagOutputResid(bool flag){flagOutputResid=flag;};
169    bool   getFlagVOT(){return flagVOT;};
170    void   setFlagVOT(bool flag){flagVOT=flag;};
171    std::string getVOTFile(){return votFile;};
172    void   setVOTFile(std::string fname){votFile = fname;};
173    bool   getFlagKarma(){return flagKarma;};
174    void   setFlagKarma(bool flag){flagKarma=flag;};
175    std::string getKarmaFile(){return karmaFile;};
176    void   setKarmaFile(std::string fname){karmaFile = fname;};
177    bool   getFlagMaps(){return flagMaps;};
178    void   setFlagMaps(bool flag){flagMaps=flag;};
179    std::string getDetectionMap(){return detectionMap;};
180    void   setDetectionMap(std::string fname){detectionMap = fname;};
181    std::string getMomentMap(){return momentMap;};
182    void   setMomentMap(std::string fname){momentMap = fname;};
183    bool   getFlagXOutput(){return flagXOutput;};
184    void   setFlagXOutput(bool b){flagXOutput=b;};
185    //
186    bool   getFlagNegative(){return flagNegative;};
187    void   setFlagNegative(bool flag){flagNegative=flag;};
188    bool   getFlagBlankPix(){return flagBlankPix;};
189    void   setFlagBlankPix(bool flag){flagBlankPix=flag;};
190    float  getBlankPixVal(){return blankPixValue;};
191    void   setBlankPixVal(float v){blankPixValue=v;};
192    int    getBlankKeyword(){return blankKeyword;};
193    void   setBlankKeyword(int v){blankKeyword=v;};
194    float  getBscaleKeyword(){return bscaleKeyword;};
195    void   setBscaleKeyword(float v){bscaleKeyword=v;};
196    float  getBzeroKeyword(){return bzeroKeyword;};
197    void   setBzeroKeyword(float v){bzeroKeyword=v;};
198    bool   getFlagMW(){return flagMW;};
199    void   setFlagMW(bool flag){flagMW=flag;};
200    int    getMaxMW(){return maxMW;};
201    void   setMaxMW(int m){maxMW=m;};
202    int    getMinMW(){return minMW;};
203    void   setMinMW(int m){minMW=m;};
204    void   setBeamSize(float s){numPixBeam = s;};
205    float  getBeamSize(){return numPixBeam;};
206    bool   getFlagUsingBeam(){return flagUsingBeam;};
207    void   setFlagUsingBeam(bool b){flagUsingBeam=b;};
208    //
209    bool   getFlagTrim(){return flagTrim;};
210    void   setFlagTrim(bool b){flagTrim=b;};
211    bool   getFlagCubeTrimmed(){return hasBeenTrimmed;};
212    void   setFlagCubeTrimmed(bool flag){hasBeenTrimmed = flag;};
213    long   getBorderLeft(){return borderLeft;};
214    void   setBorderLeft(long b){borderLeft = b;};
215    long   getBorderRight(){return borderRight;};
216    void   setBorderRight(long b){borderRight = b;};
217    long   getBorderBottom(){return borderBottom;};
218    void   setBorderBottom(long b){borderBottom = b;};
219    long   getBorderTop(){return borderTop;};
220    void   setBorderTop(long b){borderTop = b;};
221    //
222    long   getXOffset(){return xSubOffset;};
223    void   setXOffset(long o){xSubOffset = o;};
224    long   getYOffset(){return ySubOffset;};
225    void   setYOffset(long o){ySubOffset = o;};
226    long   getZOffset(){return zSubOffset;};
227    void   setZOffset(long o){zSubOffset = o;};
228    //
229    int    getMinPix(){return minPix;};
230    void   setMinPix(int m){minPix=m;};
231    //   
232    bool   getFlagGrowth(){return flagGrowth;};
233    void   setFlagGrowth(bool flag){flagGrowth=flag;};
234    float  getGrowthCut(){return growthCut;};
235    void   setGrowthCut(float c){growthCut=c;};
236    //   
237    bool   getFlagFDR(){return flagFDR;};
238    void   setFlagFDR(bool flag){flagFDR=flag;};
239    float  getAlpha(){return alphaFDR;};
240    void   setAlpha(float a){alphaFDR=a;};
241    //
242    bool   getFlagBaseline(){return flagBaseline;};
243    void   setFlagBaseline(bool flag){flagBaseline = flag;};
244    //
245    bool   getFlagStatSec(){return flagStatSec;};
246    void   setFlagStatSec(bool flag){flagStatSec=flag;};
247    std::string getStatSec(){return statSec.getSection();};
248    void   setStatSec(std::string range){statSec.setSection(range);};
249    float  getCut(){return snrCut;};
250    void   setCut(float c){snrCut=c;};
251    float  getThreshold(){return threshold;};
252    void   setThreshold(float f){threshold=f;};
253    bool   getFlagUserThreshold(){return flagUserThreshold;};
254    void   setFlagUserThreshold(bool b){flagUserThreshold=b;};
255    //   
256    bool   getFlagSmooth(){return flagSmooth;};
257    void   setFlagSmooth(bool b){flagSmooth=b;};
258    std::string getSmoothType(){return smoothType;};
259    void   setSmoothType(std::string s){smoothType=s;};
260    int    getHanningWidth(){return hanningWidth;};
261    void   setHanningWidth(int f){hanningWidth=f;};
262    void   setKernMaj(float f){kernMaj=f;};
263    float  getKernMaj(){return kernMaj;};
264    void   setKernMin(float f){kernMin=f;};
265    float  getKernMin(){return kernMin;};
266    void   setKernPA(float f){kernPA=f;};
267    float  getKernPA(){return kernPA;};
268    //   
269    bool   getFlagATrous(){return flagATrous;};
270    void   setFlagATrous(bool flag){flagATrous=flag;};
271    int    getReconDim(){return reconDim;};
272    void   setReconDim(int i){reconDim=i;};
273    int    getMinScale(){return scaleMin;};
274    void   setMinScale(int s){scaleMin=s;};
275    int    getMaxScale(){return scaleMax;};
276    void   setMaxScale(int s){scaleMax=s;};
277    float  getAtrousCut(){return snrRecon;};
278    void   setAtrousCut(float c){snrRecon=c;};
279    int    getFilterCode(){return filterCode;};
280    void   setFilterCode(int c){filterCode=c;};
281    std::string getFilterName(){return reconFilter.getName();};
282    Filter& filter(){ Filter &rfilter = reconFilter; return rfilter; };
283    //   
284    bool   getFlagAdjacent(){return flagAdjacent;};
285    void   setFlagAdjacent(bool flag){flagAdjacent=flag;};
286    float  getThreshS(){return threshSpatial;};
287    void   setThreshS(float t){threshSpatial=t;};
288    float  getThreshV(){return threshVelocity;};
289    void   setThreshV(float t){threshVelocity=t;};
290    int    getMinChannels(){return minChannels;};
291    void   setMinChannels(int n){minChannels=n;};
292    //
293    std::string getSpectralMethod(){return spectralMethod;};
294    void   setSpectralMethod(std::string s){spectralMethod=s;};
295    std::string getSpectralUnits(){return spectralUnits;};
296    void   setSpectralUnits(std::string s){spectralUnits=s;};
297    std::string getPixelCentre(){return pixelCentre;};
298    void   setPixelCentre(std::string s){pixelCentre=s;};
299    bool   drawBorders(){return borders;};
300    void   setDrawBorders(bool f){borders=f;};
301    bool   drawBlankEdge(){return blankEdge;};
302    void   setDrawBlankEdge(bool f){blankEdge=f;};
303
304    /** Are we in verbose mode? */
305    bool   isVerbose(){return verbose;};
306    void   setVerbosity(bool f){verbose=f;};
307 
308  private:
309    // Input files
310    std::string imageFile;  ///< The image to be analysed.
311    bool   flagSubsection;  ///< Whether we just want a subsection of
312    ///   the image
313    Section pixelSec;       ///< The Section object storing the pixel
314    ///   subsection information.
315    bool   flagReconExists; ///< The reconstructed array is in a FITS
316    ///   file on disk.
317    std::string reconFile;  ///< The FITS file containing the
318    ///   reconstructed array.
319    bool   flagSmoothExists;///< The smoothed array is in a FITS file.
320    std::string smoothFile; ///< The FITS file containing the smoothed
321    ///   array.
322
323    // Output files
324    bool   flagLog;         ///< Should we do the intermediate logging?
325    std::string logFile;    ///< Where the intermediate logging goes.
326    std::string outFile;    ///< Where the final results get put.
327    bool   flagSeparateHeader;///< Should the header information
328    ///   (parameters & statistics) be written
329    ///   to a separate file to the table of
330    ///   results?
331    std::string headerFile; ///< Where the header information to go with
332    ///   the results table should be written.
333    std::string spectraFile;///< Where the spectra are displayed
334    bool   flagOutputSmooth;///< Should the smoothed cube be written?
335    bool   flagOutputRecon; ///< Should the reconstructed cube be
336    ///   written?
337    bool   flagOutputResid; ///< Should the reconstructed cube be
338    ///   written?
339    bool   flagVOT;         ///< Should we save results in VOTable
340    ///   format?
341    std::string votFile;    ///< Where the VOTable goes.
342    bool   flagKarma;       ///< Should we save results in Karma
343    ///   annotation format?
344    std::string karmaFile;  ///< Where the Karma annotation file goes.
345    bool   flagMaps;        ///< Should we produce detection and moment
346    ///   maps in postscript form?
347    std::string detectionMap;///< The name of the detection map
348    ///   (postscript file).
349    std::string momentMap;  ///< The name of the 0th moment map (ps file).
350    bool   flagXOutput;     ///< Should there be an xwindows output of
351    ///   the detection map?
352
353    // Cube related parameters
354    bool   flagNegative;    ///< Are we going to search for negative
355    ///   features?
356    bool   flagBlankPix;    ///< A flag that indicates whether there are
357    ///   pixels defined as BLANK and whether we
358    ///   need to remove & ignore them in
359    ///   processing.
360    float  blankPixValue;   ///< Pixel value that is considered BLANK.
361    int    blankKeyword;    ///< The FITS header keyword BLANK.
362    float  bscaleKeyword;   ///< The FITS header keyword BSCALE.
363    float  bzeroKeyword;    ///< The FITS header keyword BZERO.
364    //Milky-Way parameters
365    bool   flagMW;          ///< A flag that indicates whether to ignore
366    ///   the Milky Way channels.
367    int    maxMW;           ///< Last  Milky Way channel
368    int    minMW;           ///< First Milky Way channel
369    // Trim-related
370    bool   flagTrim;        ///< Does the user want the cube trimmed?
371    bool   hasBeenTrimmed;  ///< Has the cube been trimmed of excess
372    ///   BLANKs around the edge?
373    long   borderLeft;      ///< The number of BLANK pixels trimmed from
374    ///   the left of the cube;
375    long   borderRight;     ///< The number trimmed from the Right of
376    ///   the cube;
377    long   borderBottom;    ///< The number trimmed from the Bottom of
378    ///   the cube;
379    long   borderTop;       ///< The number trimmed from the Top of the
380    ///   cube;
381    // Subsection offsets
382    long  *offsets;         ///< The array of offsets for each FITS axis.
383    long   sizeOffsets;     ///< The size of the offsets array.
384    long   xSubOffset;      ///< The subsection's x-axis offset
385    long   ySubOffset;      ///< The subsection's y-axis offset
386    long   zSubOffset;      ///< The subsection's z-axis offset
387    // Baseline related
388    bool   flagBaseline;    ///< Whether to do baseline subtraction
389    ///   before reconstruction and/or searching.
390    // Detection-related
391    int    minPix;          ///< Minimum number of pixels for a detected
392    ///   object to be counted
393    float  numPixBeam;      ///< Size (area) of the beam in pixels.
394    bool   flagUsingBeam;   ///< If true, we are using the numPixBeam
395    ///   parameter, otherwise we use the value
396    ///   in the FITS header.
397    // Object growth
398    bool   flagGrowth;      ///< Are we growing objects once they are
399    ///   found?
400    float  growthCut;       ///< The SNR that we are growing objects
401    ///   down to.
402    // FDR analysis
403    bool   flagFDR;         ///< Should the FDR method be used?
404    float  alphaFDR;        ///< Alpha value for FDR detection algorithm
405    // Basic detection
406    bool   flagStatSec;     ///< Whether we just want to use a
407    ///   subsection of the image to calculate
408    ///   the statistics.
409    Section statSec;       ///< The Section object storing the statistics
410    ///   subsection information.
411    float  snrCut;          ///< How many sigma above mean is a
412    ///   detection when sigma-clipping
413    float  threshold;       ///< What the threshold is (when
414    ///   sigma-clipping).
415    bool   flagUserThreshold;///< Whether the user has defined a
416    ///   threshold of their own.
417    // Smoothing of the cube
418    bool   flagSmooth;      ///< Should the cube be smoothed before
419    ///   searching?
420    std::string smoothType; ///< The type of smoothing to be done.
421    int    hanningWidth;    ///< Width for hanning smoothing.
422    float  kernMaj;         ///< Semi-Major axis of gaussian smoothing kernel
423    float  kernMin;         ///< Semi-Minor axis of gaussian smoothing kernel
424    float  kernPA;          ///< Position angle of gaussian smoothing
425    ///   kernel, in degrees east of north
426    ///   (i.e. anticlockwise).
427    // A trous reconstruction parameters
428    bool   flagATrous;      ///< Are we using the a trous reconstruction?
429    int    reconDim;        ///< How many dimensions to use for the
430    ///   reconstruction?
431    int    scaleMin;        ///< Min scale used in a trous reconstruction
432    int    scaleMax;        ///< Max scale used in a trous reconstruction
433    float  snrRecon;        ///< SNR cutoff used in a trous
434    ///   reconstruction (only wavelet coefficients
435    ///   that survive this threshold are kept)
436    Filter reconFilter;     ///< The filter used for reconstructions.
437    int    filterCode;      ///< The code number for the filter to be
438    ///   used (saves having to parse names)
439    std::string filterName; ///< The code number converted into a name,
440    ///   for outputting purposes.
441
442    // Volume-merging parameters
443    bool   flagAdjacent;    ///< Whether to use the adjacent criterion
444    ///   for judging if objects are to be merged.
445    float  threshSpatial;   ///< Maximum spatial separation between
446    ///   objects
447    float  threshVelocity;  ///< Maximum channels separation between
448    ///   objects
449    int    minChannels;     ///< Minimum no. of channels to make an object
450    // Input-Output related
451    std::string spectralMethod; ///< A string indicating choice of
452    ///   spectral plotting method: choices are
453    ///   "peak" (default) or "sum"
454    std::string spectralUnits;   ///< A string indicating what units the
455    ///   spectral axis should be quoted in.
456    std::string pixelCentre;///< A string indicating which type of
457    ///   centre to give the results in: "average",
458    ///   "centroid", or "peak"(flux).
459    bool   borders;         ///< Whether to draw a border around the
460    ///   individual pixels of a detection in the
461    ///   spectral display
462    bool   blankEdge;       ///< Whether to draw a border around the
463    ///   BLANK pixel region in the moment maps and
464    ///   cutout images
465    bool   verbose;         ///< Whether to use maximum verbosity -- use
466    ///   progress indicators in the reconstruction
467    ///   & merging steps.
468
469  };
470
471  //===========================================================================
472
473
474  std::string makelower( std::string s );
475
476}
477#endif
Note: See TracBrowser for help on using the repository browser.