source: trunk/src/param.hh @ 348

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