source: trunk/src/param.cc @ 472

Last change on this file since 472 was 461, checked in by MatthewWhiting, 16 years ago

A few fixes:

  • Fixed a bug in setupColumns and the VOTable output when there are no detections
  • Fixed some bugs from the tidy up in the last commit
  • Fixed conflicts between a manual threshold and growth thresholds. Introduced a manual growth threshold that must be used when a manual threshold is used.
  • Also, a manual threshold turns off the FDR flag.
  • Improved the growth threshold reporting in the results header.
File size: 43.9 KB
Line 
1// -----------------------------------------------------------------------
2// param.cc: Dealing with the set of parameters for Duchamp.
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#include <iostream>
29#include <iomanip>
30#include <fstream>
31#include <sstream>
32#include <string>
33#include <stdlib.h>
34#include <ctype.h>
35#include <math.h>
36#include <unistd.h>
37#include <duchamp/param.hh>
38#include <duchamp/fitsHeader.hh>
39#include <duchamp/duchamp.hh>
40#include <duchamp/pgheader.hh>
41#include <duchamp/ATrous/filter.hh>
42#include <duchamp/Utils/utils.hh>
43#include <duchamp/Utils/Section.hh>
44#include <duchamp/Detection/columns.hh>
45
46namespace duchamp
47{
48
49  /****************************************************************/
50  ///////////////////////////////////////////////////
51  //// Accessor Functions for Parameter class:
52  ///////////////////////////////////////////////////
53  Param::~Param()
54  {
55    /**
56     * Deletes the offsets array if the sizeOffsets parameter is
57     * positive.
58     */
59    if(this->sizeOffsets>0) delete [] this->offsets;
60  }
61
62  Param::Param()
63  {
64    this->defaultValues();
65  }
66
67  void Param::defaultValues()
68  {
69    /**
70     * Provides default intial values for the parameters. Note that
71     * imageFile has no default value!
72     */
73    std::string baseSection = "[*,*,*]";
74    // Input files
75    this->imageFile         = "";
76    this->flagSubsection    = false;
77    this->pixelSec.setSection(baseSection);
78    this->flagReconExists   = false;
79    this->reconFile         = "";
80    this->flagSmoothExists  = false;
81    this->smoothFile        = "";
82    // Output files
83    this->flagLog           = false;
84    this->logFile           = "duchamp-Logfile.txt";
85    this->outFile           = "duchamp-Results.txt";
86    this->flagSeparateHeader= false;
87    this->headerFile        = "duchamp-Results.hdr";
88    this->spectraFile       = "duchamp-Spectra.ps";
89    this->flagTextSpectra   = false;
90    this->spectraTextFile   = "duchamp-Spectra.txt";
91    this->flagOutputMask    = false;
92    this->flagOutputSmooth  = false;
93    this->flagOutputRecon   = false;
94    this->flagOutputResid   = false;
95    this->flagVOT           = false;
96    this->votFile           = "duchamp-Results.xml";
97    this->flagKarma         = false;
98    this->karmaFile         = "duchamp-Results.ann";
99    this->annotationType    = "borders";
100    this->flagMaps          = true;
101    this->detectionMap      = "duchamp-DetectionMap.ps";
102    this->momentMap         = "duchamp-MomentMap.ps";
103    this->flagXOutput       = true;
104    this->precFlux          = Column::prFLUX;
105    this->precVel           = Column::prVEL;
106    this->precSNR           = Column::prSNR;
107    // Cube related parameters
108    this->flagBlankPix      = true;
109    this->blankPixValue     = -8.00061;
110    this->blankKeyword      = 1;
111    this->bscaleKeyword     = -8.00061;
112    this->bzeroKeyword      = 0.;
113    this->newFluxUnits      = "";
114    // Milky-Way parameters
115    this->flagMW            = false;
116    this->maxMW             = 112;
117    this->minMW             = 75;
118    this->numPixBeam        = 10.;
119    this->flagUsingBeam     = false;
120    // Trim-related         
121    this->flagTrim          = false;
122    this->hasBeenTrimmed    = false;
123    this->borderLeft        = 0;
124    this->borderRight       = 0;
125    this->borderBottom      = 0;
126    this->borderTop         = 0;
127    // Subsection offsets
128    this->sizeOffsets       = 0;
129    this->xSubOffset        = 0;
130    this->ySubOffset        = 0;
131    this->zSubOffset        = 0;
132    // Baseline related
133    this->flagBaseline      = false;
134    // Detection-related   
135    this->flagNegative      = false;
136    // Object growth       
137    this->flagGrowth        = false;
138    this->growthCut         = 3.;
139    this->flagUserGrowthThreshold = false;
140    this->growthThreshold   = 0.;
141    // FDR analysis         
142    this->flagFDR           = false;
143    this->alphaFDR          = 0.01;
144    // Other detection     
145    this->flagStatSec       = false;
146    this->statSec.setSection(baseSection);
147    this->flagRobustStats   = true;
148    this->snrCut            = 3.;
149    this->threshold         = 0.;
150    this->flagUserThreshold = false;
151    // Smoothing
152    this->flagSmooth        = false;
153    this->smoothType        = "spectral";
154    this->hanningWidth      = 5;
155    this->kernMaj           = 3.;
156    this->kernMin           = -1.;
157    this->kernPA            = 0.;
158    // A trous reconstruction parameters
159    this->flagATrous        = false;
160    this->reconDim          = 1;
161    this->scaleMin          = 1;
162    this->scaleMax          = 0;
163    this->snrRecon          = 4.;
164    this->filterCode        = 1;
165    this->reconFilter.define(this->filterCode);
166    // Volume-merging parameters
167    this->flagAdjacent      = true;
168    this->threshSpatial     = 3.;
169    this->threshVelocity    = 7.;
170    this->minChannels       = 3;
171    this->minPix            = 2;
172    // Input-Output related
173    this->spectralMethod    = "peak";
174    this->spectralUnits     = "km/s";
175    this->pixelCentre       = "centroid";
176    this->borders           = true;
177    this->blankEdge         = true;
178    this->verbose           = true;
179  }
180
181  Param::Param (const Param& p)
182  {
183    operator=(p);
184  }
185
186  Param& Param::operator= (const Param& p)
187  {
188    if(this == &p) return *this;
189    this->imageFile         = p.imageFile;
190    this->flagSubsection    = p.flagSubsection;
191    this->pixelSec          = p.pixelSec;
192    this->flagReconExists   = p.flagReconExists;
193    this->reconFile         = p.reconFile;     
194    this->flagSmoothExists  = p.flagSmoothExists;
195    this->smoothFile        = p.smoothFile;     
196    this->flagLog           = p.flagLog;       
197    this->logFile           = p.logFile;       
198    this->outFile           = p.outFile;       
199    this->flagSeparateHeader= p.flagSeparateHeader;
200    this->headerFile        = p.headerFile;
201    this->spectraFile       = p.spectraFile;   
202    this->flagTextSpectra   = p.flagTextSpectra;   
203    this->spectraTextFile   = p.spectraTextFile;   
204    this->flagOutputMask    = p.flagOutputMask;
205    this->flagOutputSmooth  = p.flagOutputSmooth;
206    this->flagOutputRecon   = p.flagOutputRecon;
207    this->flagOutputResid   = p.flagOutputResid;
208    this->flagVOT           = p.flagVOT;         
209    this->votFile           = p.votFile;       
210    this->flagKarma         = p.flagKarma;     
211    this->karmaFile         = p.karmaFile;     
212    this->annotationType    = p.annotationType;
213    this->flagMaps          = p.flagMaps;       
214    this->detectionMap      = p.detectionMap;   
215    this->momentMap         = p.momentMap;     
216    this->flagXOutput       = p.flagXOutput;       
217    this->precFlux          = p.precFlux;
218    this->precVel           = p.precVel;
219    this->precSNR           = p.precSNR;
220    this->flagBlankPix      = p.flagBlankPix;   
221    this->blankPixValue     = p.blankPixValue; 
222    this->blankKeyword      = p.blankKeyword;   
223    this->bscaleKeyword     = p.bscaleKeyword; 
224    this->bzeroKeyword      = p.bzeroKeyword;   
225    this->newFluxUnits      = p.newFluxUnits;
226    this->flagMW            = p.flagMW;         
227    this->maxMW             = p.maxMW;         
228    this->minMW             = p.minMW;         
229    this->numPixBeam        = p.numPixBeam;     
230    this->flagTrim          = p.flagTrim;   
231    this->hasBeenTrimmed    = p.hasBeenTrimmed;   
232    this->borderLeft        = p.borderLeft;     
233    this->borderRight       = p.borderRight;   
234    this->borderBottom      = p.borderBottom;   
235    this->borderTop         = p.borderTop;     
236    if(this->sizeOffsets>0) delete [] this->offsets;
237    this->sizeOffsets       = p.sizeOffsets;
238    if(this->sizeOffsets>0){
239      this->offsets           = new long[this->sizeOffsets];
240      for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i];
241    }
242    this->xSubOffset        = p.xSubOffset;     
243    this->ySubOffset        = p.ySubOffset;     
244    this->zSubOffset        = p.zSubOffset;
245    this->flagBaseline      = p.flagBaseline;
246    this->flagNegative      = p.flagNegative;
247    this->flagGrowth        = p.flagGrowth;
248    this->growthCut         = p.growthCut;
249    this->growthThreshold   = p.threshold;
250    this->flagUserGrowthThreshold = p.flagUserThreshold;
251    this->flagFDR           = p.flagFDR;
252    this->alphaFDR          = p.alphaFDR;
253    this->flagStatSec       = p.flagStatSec;
254    this->statSec           = p.statSec;
255    this->flagRobustStats   = p.flagRobustStats;
256    this->snrCut            = p.snrCut;
257    this->threshold         = p.threshold;
258    this->flagUserThreshold = p.flagUserThreshold;
259    this->flagSmooth        = p.flagSmooth;
260    this->smoothType        = p.smoothType;
261    this->hanningWidth      = p.hanningWidth;
262    this->kernMaj           = p.kernMaj;
263    this->kernMin           = p.kernMin;
264    this->kernPA            = p.kernPA;
265    this->flagATrous        = p.flagATrous;
266    this->reconDim          = p.reconDim;
267    this->scaleMin          = p.scaleMin;
268    this->scaleMax          = p.scaleMax;
269    this->snrRecon          = p.snrRecon;
270    this->filterCode        = p.filterCode;
271    this->reconFilter       = p.reconFilter;
272    this->flagAdjacent      = p.flagAdjacent;
273    this->threshSpatial     = p.threshSpatial;
274    this->threshVelocity    = p.threshVelocity;
275    this->minChannels       = p.minChannels;
276    this->minPix            = p.minPix;
277    this->spectralMethod    = p.spectralMethod;
278    this->spectralUnits     = p.spectralUnits;
279    this->pixelCentre       = p.pixelCentre;
280    this->borders           = p.borders;
281    this->verbose           = p.verbose;
282    return *this;
283  }
284  //--------------------------------------------------------------------
285
286  int Param::getopts(int argc, char ** argv)
287  {
288    /** 
289     *   A function that reads in the command-line options, in a manner
290     *    tailored for use with the main Duchamp program.
291     *
292     *   \param argc The number of command line arguments.
293     *   \param argv The array of command line arguments.
294     */
295
296    int returnValue = FAILURE;
297    if(argc==1){
298      std::cout << ERR_USAGE_MSG;
299      returnValue = FAILURE;
300    }
301    else {
302      std::string file;
303      bool changeX = false;
304      this->defaultValues();
305      char c;
306      while( ( c = getopt(argc,argv,"p:f:hvx") )!=-1){
307        switch(c) {
308        case 'p':
309          file = optarg;
310          if(this->readParams(file)==FAILURE){
311            std::stringstream errmsg;
312            errmsg << "Could not open parameter file " << file << ".\n";
313            duchampError("Duchamp",errmsg.str());
314          }
315          else returnValue = SUCCESS;
316          break;
317        case 'f':
318          file = optarg;
319          this->imageFile = file;
320          returnValue = SUCCESS;
321          break;
322        case 'v':
323          std::cout << PROGNAME << " version " << VERSION << std::endl;
324          break;
325        case 'x':
326          changeX = true;
327          break;
328        case 'h':
329        default :
330          std::cout << ERR_USAGE_MSG;
331          break;
332        }
333      }
334      if(changeX){
335        if(returnValue == SUCCESS) this->setFlagXOutput(false);
336        else {
337          duchampError("Duchamp",
338                       "You need to specify either a parameter file or FITS image.\n");
339          std::cout << "\n" << ERR_USAGE_MSG;
340        }
341      }
342    }
343    return returnValue;
344  }
345  //--------------------------------------------------------------------
346
347  bool Param::isBlank(float &value)
348  {
349    /**
350     *  Tests whether the value passed as the argument is BLANK or not.
351     *  \param value Pixel value to be tested.
352     *  \return False if flagBlankPix is false. Else, compare to the
353     *  relevant FITS keywords, using integer comparison.
354     */
355    return this->flagBlankPix &&
356      (this->blankKeyword == int((value-this->bzeroKeyword)/this->bscaleKeyword));
357  }
358
359  bool *Param::makeBlankMask(float *array, int size)
360  {
361    /**
362     *  This returns an array of bools, saying whether each pixel in the
363     *  given array is BLANK or not. If the pixel is BLANK, set mask to
364     *  false, else set to true. The array is allocated by the function.
365     */
366    bool *mask = new bool[size];
367    for(int i=0;i<size;i++) mask[i] = !this->isBlank(array[i]);
368    return mask;
369  }
370
371
372  bool Param::isInMW(int z)
373  {
374    /**
375     *  Tests whether we are flagging Milky Way channels, and if so
376     * whether the given channel number is in the Milky Way range. The
377     * channels are assumed to start at number 0. 
378     * \param z The channel number
379     * \return True if we are flagging Milky Way channels and z is in
380     *  the range.
381     */
382    return ( flagMW && (z>=minMW) && (z<=maxMW) );
383  }
384
385  bool Param::isStatOK(int x, int y, int z)
386  {
387    /**
388     * Test whether a given pixel position lies within the subsection
389     * given by the statSec parameter. Only tested if the flagSubsection
390     * parameter is true -- if it isn't, we just return true since all
391     * pixels are therefore available for statstical calculations.
392     * \param x X-value of pixel being tested.
393     * \param y Y-value of pixel being tested.
394     * \param z Z-value of pixel being tested.
395     * \return True if pixel is able to be used for statistical
396     * calculations. False otherwise.
397     */
398    int xval=x,yval=y,zval=z;
399    if(flagSubsection){
400      xval += pixelSec.getStart(0);
401      yval += pixelSec.getStart(1);
402      zval += pixelSec.getStart(2);
403    }
404    return !flagStatSec || statSec.isInside(xval,yval,zval);
405  }
406
407  /****************************************************************/
408  ///////////////////////////////////////////////////
409  //// Other Functions using the  Parameter class:
410  ///////////////////////////////////////////////////
411
412  std::string makelower( std::string s )
413  {
414    // "borrowed" from Matt Howlett's 'fred'
415    std::string out = "";
416    for( int i=0; i<s.size(); ++i ) {
417      out += tolower(s[i]);
418    }
419    return out;
420  }
421
422  inline std::string stringize(bool b)
423  {
424    /**
425     * Convert a bool variable to the textual equivalent.
426     * \return A std::string with the english equivalent of the bool.
427     */
428    std::string output;
429    if(b) output="true";
430    else output="false";
431    return output;
432  }
433
434  inline bool boolify( std::string s )
435  {
436    /**
437     *  Convert a std::string to a bool variable:
438     *  "1" and "true" get converted to true;
439     *  "0" and "false" (and anything else) get converted to false.
440     * \return The bool equivalent of the string.
441     */
442    if((s=="1") || (makelower(s)=="true")) return true;
443    else if((s=="0") || (makelower(s)=="false")) return false;
444    else return false;
445  }
446
447  inline std::string readSval(std::stringstream& ss)
448  {
449    std::string val; ss >> val; return val;
450  }
451
452  inline bool readFlag(std::stringstream& ss)
453  {
454    std::string val; ss >> val; return boolify(val);
455  }
456
457  inline float readFval(std::stringstream& ss)
458  {
459    float val; ss >> val; return val;
460  }
461
462  inline int readIval(std::stringstream& ss)
463  {
464    int val; ss >> val; return val;
465  }
466
467  int Param::readParams(std::string paramfile)
468  {
469    /**
470     * The parameters are read in from a disk file, on the assumption that each
471     *  line of the file has the format "parameter value" (eg. alphafdr 0.1)
472     *
473     * The case of the parameter name does not matter, nor does the
474     * formatting of the spaces (it can be any amount of whitespace or
475     * tabs).
476     *
477     * \param paramfile A std::string containing the parameter filename.
478     *
479     * \return FAILURE if the parameter file does not exist. SUCCESS if
480     * it is able to read it.
481     */
482    std::ifstream fin(paramfile.c_str());
483    if(!fin.is_open()) return FAILURE;
484    std::string line;
485    while( !std::getline(fin,line,'\n').eof()){
486
487      if(line[0]!='#'){
488        std::stringstream ss;
489        ss.str(line);
490        std::string arg;
491        ss >> arg;
492        arg = makelower(arg);
493        if(arg=="imagefile")       this->imageFile = readSval(ss);
494        if(arg=="flagsubsection")  this->flagSubsection = readFlag(ss);
495        if(arg=="subsection")      this->pixelSec.setSection(readSval(ss));
496        if(arg=="flagreconexists") this->flagReconExists = readFlag(ss);
497        if(arg=="reconfile")       this->reconFile = readSval(ss);
498        if(arg=="flagsmoothexists")this->flagSmoothExists = readFlag(ss);
499        if(arg=="smoothfile")      this->smoothFile = readSval(ss);
500        if(arg=="beamsize")        this->numPixBeam = readFval(ss);
501
502        if(arg=="flaglog")         this->flagLog = readFlag(ss);
503        if(arg=="logfile")         this->logFile = readSval(ss);
504        if(arg=="outfile")         this->outFile = readSval(ss);
505        if(arg=="flagseparateheader") this->flagSeparateHeader = readFlag(ss);
506        if(arg=="headerfile")      this->headerFile = readSval(ss);
507        if(arg=="spectrafile")     this->spectraFile = readSval(ss);
508        if(arg=="flagtextspectra") this->flagTextSpectra = readFlag(ss);
509        if(arg=="spectraTextfile") this->spectraTextFile = readSval(ss);
510        if(arg=="flagoutputmask")  this->flagOutputMask = readFlag(ss);
511        if(arg=="flagoutputsmooth")this->flagOutputSmooth = readFlag(ss);
512        if(arg=="flagoutputrecon") this->flagOutputRecon = readFlag(ss);
513        if(arg=="flagoutputresid") this->flagOutputResid = readFlag(ss);
514        if(arg=="flagvot")         this->flagVOT = readFlag(ss);
515        if(arg=="votfile")         this->votFile = readSval(ss);
516        if(arg=="flagkarma")       this->flagKarma = readFlag(ss);
517        if(arg=="karmafile")       this->karmaFile = readSval(ss);
518        if(arg=="annotationtype")  this->annotationType = readSval(ss);
519        if(arg=="flagmaps")        this->flagMaps = readFlag(ss);
520        if(arg=="detectionmap")    this->detectionMap = readSval(ss);
521        if(arg=="momentmap")       this->momentMap = readSval(ss);
522        if(arg=="flagxoutput")     this->flagXOutput = readFlag(ss);
523        if(arg=="newfluxunits")    this->newFluxUnits = readSval(ss);
524        if(arg=="precflux")        this->precFlux = readIval(ss);
525        if(arg=="precvel")         this->precVel = readIval(ss);
526        if(arg=="precsnr")         this->precSNR = readIval(ss);
527
528        if(arg=="flagtrim")        this->flagTrim = readFlag(ss);
529        if(arg=="flagmw")          this->flagMW = readFlag(ss);
530        if(arg=="maxmw")           this->maxMW = readIval(ss);
531        if(arg=="minmw")           this->minMW = readIval(ss);
532        if(arg=="flagbaseline")    this->flagBaseline = readFlag(ss);
533
534        if(arg=="flagnegative")    this->flagNegative = readFlag(ss);
535        if(arg=="minpix")          this->minPix = readIval(ss);
536        if(arg=="flaggrowth")      this->flagGrowth = readFlag(ss);
537        if(arg=="growthcut")       this->growthCut = readFval(ss);
538        if(arg=="growththreshold"){
539          this->growthThreshold = readFval(ss);
540          this->flagUserGrowthThreshold = true;
541        }
542
543        if(arg=="flagfdr")         this->flagFDR = readFlag(ss);
544        if(arg=="alphafdr")        this->alphaFDR = readFval(ss);
545
546        if(arg=="flagstatsec")     this->flagStatSec = readFlag(ss);
547        if(arg=="statsec")         this->statSec.setSection(readSval(ss));
548        if(arg=="flagrobuststats") this->flagRobustStats = readFlag(ss);
549        if(arg=="snrcut")          this->snrCut = readFval(ss);
550        if(arg=="threshold"){
551          this->threshold = readFval(ss);
552          this->flagUserThreshold = true;
553        }
554     
555        if(arg=="flagsmooth")      this->flagSmooth = readFlag(ss);
556        if(arg=="smoothtype")      this->smoothType = readSval(ss);
557        if(arg=="hanningwidth")    this->hanningWidth = readIval(ss);
558        if(arg=="kernmaj")         this->kernMaj = readFval(ss);
559        if(arg=="kernmin")         this->kernMin = readFval(ss);
560        if(arg=="kernpa")          this->kernPA = readFval(ss);
561
562        if(arg=="flagatrous")      this->flagATrous = readFlag(ss);
563        if(arg=="recondim")        this->reconDim = readIval(ss);
564        if(arg=="scalemin")        this->scaleMin = readIval(ss);
565        if(arg=="scalemax")        this->scaleMax = readIval(ss);
566        if(arg=="snrrecon")        this->snrRecon = readFval(ss);
567        if(arg=="filtercode"){
568          this->filterCode = readIval(ss);
569          this->reconFilter.define(this->filterCode);
570        }
571
572        if(arg=="flagadjacent")    this->flagAdjacent = readFlag(ss);
573        if(arg=="threshspatial")   this->threshSpatial = readFval(ss);
574        if(arg=="threshvelocity")  this->threshVelocity = readFval(ss);
575        if(arg=="minchannels")     this->minChannels = readIval(ss);
576
577        if(arg=="spectralmethod")  this->spectralMethod=makelower(readSval(ss));
578        if(arg=="spectralunits")   this->spectralUnits = makelower(readSval(ss));
579        if(arg=="pixelcentre")     this->pixelCentre = makelower(readSval(ss));
580        if(arg=="drawborders")     this->borders = readFlag(ss);
581        if(arg=="drawblankedges")  this->blankEdge = readFlag(ss);
582        if(arg=="verbose")         this->verbose = readFlag(ss);
583
584        // Dealing with deprecated parameters.
585        if(arg=="flagblankpix"){
586          this->flagTrim = readFlag(ss);
587          std::stringstream errmsg;
588          errmsg <<"The parameter flagBlankPix is deprecated. "
589                 <<"Please use the flagTrim parameter in future.\n"
590                 <<"Setting flagTrim = " << stringize(this->flagTrim) << ".\n";
591          duchampWarning("Reading parameters",errmsg.str());
592        }
593        if(arg=="blankpixvalue"){
594          std::stringstream errmsg;
595          errmsg <<"The parameter blankPixValue is deprecated.\n"
596                 <<"This value is only taken from the FITS header.\n";
597          duchampWarning("Reading parameters",errmsg.str());
598        }
599
600      }
601    }
602
603    // If pgplot was not included in the compilation, need to set flagXOutput to false
604    if(!USE_PGPLOT) this->flagXOutput = false;
605
606    // Correcting bad precision values -- if negative, set to 0
607    if(this->precFlux<0) this->precFlux = 0;
608    if(this->precVel<0)  this->precVel = 0;
609    if(this->precSNR<0)  this->precSNR = 0;
610
611    // The wavelet reconstruction takes precendence over the smoothing.
612    if(this->flagATrous) this->flagSmooth = false;
613
614    if(this->flagUserThreshold){
615
616      // If we specify a manual threshold, need to also specify a manual growth threshold
617      // If we haven't done so, turn growing off
618      if(this->flagGrowth && !this->flagUserGrowthThreshold){
619        std::stringstream errmsg;
620        errmsg << "You have specified a manual search threshold, but not a manual growth threshold.\n"
621               << "You need to do so using the \"growthThreshold\" parameter.\n"
622               << "The growth function is being turned off.\n";
623        duchampWarning("Reading parameters",errmsg.str());
624        this->flagGrowth = false;
625      }
626
627      // If we specify a manual threshold, we don't need the FDR method, so turn it off if requested.
628      if(this->flagFDR){
629        std::stringstream errmsg;
630        errmsg << "You have specified a manual search threshold, so we don't need to use the FDR method.\n"
631               << "Setting \"flagFDR=false\".\n";
632        duchampWarning("Reading parameters",errmsg.str());
633        this->flagFDR = false;
634      }
635
636    }   
637
638
639    // Make sure the annnotationType is an acceptable option -- default is "borders"
640    if((this->annotationType != "borders") && (this->annotationType!="circles")){
641      std::stringstream errmsg;
642      errmsg << "The requested value of the parameter annotationType, \""
643             << this->annotationType << "\" is invalid.\n"
644             << "Changing to \"borders\".\n";
645      duchampWarning("Reading parameters",errmsg.str());
646      this->annotationType = "borders";
647    }
648     
649    // Make sure smoothType is an acceptable type -- default is "spectral"
650    if((this->smoothType!="spectral")&&
651       (this->smoothType!="spatial")){
652      std::stringstream errmsg;
653      errmsg << "The requested value of the parameter smoothType, \""
654             << this->smoothType << "\" is invalid.\n"
655             << "Changing to \"spectral\".\n";
656      duchampWarning("Reading parameters",errmsg.str());
657      this->smoothType = "spectral";
658    }
659    // If kernMin has not been given, or is negative, make it equal to kernMaj
660    if(this->kernMin < 0) this->kernMin = this->kernMaj;
661
662    // Make sure spectralMethod is an acceptable type -- default is "peak"
663    if((this->spectralMethod!="peak")&&
664       (this->spectralMethod!="sum")){
665      std::stringstream errmsg;
666      errmsg << "The requested value of the parameter spectralMethod, \""
667             << this->spectralMethod << "\" is invalid.\n"
668             << "Changing to \"peak\".\n";
669      duchampWarning("Reading parameters",errmsg.str());
670      this->spectralMethod = "peak";
671    }
672
673    // Make sure pixelCentre is an acceptable type -- default is "peak"
674    if((this->pixelCentre!="centroid")&&
675       (this->pixelCentre!="average") &&
676       (this->pixelCentre!="peak")       ){
677      std::stringstream errmsg;
678      errmsg << "The requested value of the parameter pixelCentre, \""
679             << this->pixelCentre << "\" is invalid.\n"
680             << "Changing to \"centroid\".\n";
681      duchampWarning("Reading parameters",errmsg.str());
682      this->pixelCentre = "centroid";
683    }
684
685    return SUCCESS;
686  }
687
688
689  std::ostream& operator<< ( std::ostream& theStream, Param& par)
690  {
691    /**
692     * Print out the parameter set in a formatted, easy to read style.
693     * Lists the parameters, a description of them, and their value.
694     */
695
696    // Only show the [beamSize] bit if we are using the parameter
697    // otherwise we have read it from the FITS header.
698    std::string beamParam = "";
699    if(par.getFlagUsingBeam()) beamParam = "[beamSize]";
700
701    // BUG -- can get error: `boolalpha' is not a member of type `ios' -- old compilers: gcc 2.95.3?
702    //   theStream.setf(std::ios::boolalpha);
703    theStream.setf(std::ios::left);
704    theStream  <<"\n---- Parameters ----"<<std::endl;
705    theStream  << std::setfill('.');
706    const int widthText = 38;
707    const int widthPar  = 18;
708    if(par.getFlagSubsection())
709      theStream<<std::setw(widthText)<<"Image to be analysed"                 
710               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]"
711               <<"  =  " <<resetiosflags(std::ios::right)
712               <<(par.getImageFile()+par.getSubsection()) <<std::endl;
713    else
714      theStream<<std::setw(widthText)<<"Image to be analysed"                 
715               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]"
716               <<"  =  " <<resetiosflags(std::ios::right)
717               <<par.getImageFile()      <<std::endl;
718    if(par.getFlagReconExists() && par.getFlagATrous()){
719      theStream<<std::setw(widthText)<<"Reconstructed array exists?"         
720               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconExists]"
721               <<"  =  " <<resetiosflags(std::ios::right)
722               <<stringize(par.getFlagReconExists())<<std::endl;
723      theStream<<std::setw(widthText)<<"FITS file containing reconstruction" 
724               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconFile]"
725               <<"  =  " <<resetiosflags(std::ios::right)
726               <<par.getReconFile()      <<std::endl;
727    }
728    if(par.getFlagSmoothExists() && par.getFlagSmooth()){
729      theStream<<std::setw(widthText)<<"Smoothed array exists?"         
730               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothExists]"
731               <<"  =  " <<resetiosflags(std::ios::right)
732               <<stringize(par.getFlagSmoothExists())<<std::endl;
733      theStream<<std::setw(widthText)<<"FITS file containing smoothed array" 
734               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothFile]"
735               <<"  =  " <<resetiosflags(std::ios::right)
736               <<par.getSmoothFile()      <<std::endl;
737    }
738    theStream  <<std::setw(widthText)<<"Intermediate Logfile"
739               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[logFile]"
740               <<"  =  " <<resetiosflags(std::ios::right)
741               <<par.getLogFile()        <<std::endl;
742    theStream  <<std::setw(widthText)<<"Final Results file"                   
743               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[outFile]"
744               <<"  =  " <<resetiosflags(std::ios::right)
745               <<par.getOutFile()        <<std::endl;
746    if(par.getFlagSeparateHeader())
747      theStream <<std::setw(widthText)<<"Header for results file"
748                <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[headerFile]"
749                <<"  =  " <<resetiosflags(std::ios::right)
750                <<par.getHeaderFile()        <<std::endl;
751    theStream  <<std::setw(widthText)<<"Spectrum file"                       
752               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectraFile]"
753               <<"  =  " <<resetiosflags(std::ios::right)
754               <<par.getSpectraFile()    <<std::endl;
755    if(par.getFlagTextSpectra()){
756      theStream<<std::setw(widthText)<<"Text file with ascii spectral data"                         
757               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectraTextFile]"
758               <<"  =  " <<resetiosflags(std::ios::right)
759               <<par.getSpectraTextFile()<<std::endl;
760    }
761    if(par.getFlagVOT()){
762      theStream<<std::setw(widthText)<<"VOTable file"                         
763               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[votFile]"
764               <<"  =  " <<resetiosflags(std::ios::right)
765               <<par.getVOTFile()        <<std::endl;
766    }
767    if(par.getFlagKarma()){
768      theStream<<std::setw(widthText)<<"Karma annotation file"               
769               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[karmaFile]"
770               <<"  =  " <<resetiosflags(std::ios::right)
771             
772               <<par.getKarmaFile()      <<std::endl;
773    }
774    if(par.getFlagMaps()){
775      theStream<<std::setw(widthText)<<"0th Moment Map"                       
776               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[momentMap]"
777               <<"  =  " <<resetiosflags(std::ios::right)
778               <<par.getMomentMap()      <<std::endl;
779      theStream<<std::setw(widthText)<<"Detection Map"                       
780               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[detectionMap]"
781               <<"  =  " <<resetiosflags(std::ios::right)
782               <<par.getDetectionMap()   <<std::endl;
783    }
784    theStream  <<std::setw(widthText)<<"Display a map in a pgplot xwindow?"
785               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagXOutput]"
786               <<"  =  " <<resetiosflags(std::ios::right)
787               <<stringize(par.getFlagXOutput())     <<std::endl;
788    if(par.getFlagATrous()){                           
789      theStream<<std::setw(widthText)<<"Saving reconstructed cube?"           
790               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputRecon]"
791               <<"  =  " <<resetiosflags(std::ios::right)
792               <<stringize(par.getFlagOutputRecon())<<std::endl;
793      theStream<<std::setw(widthText)<<"Saving residuals from reconstruction?"
794               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputResid]"
795               <<"  =  " <<resetiosflags(std::ios::right)
796               <<stringize(par.getFlagOutputResid())<<std::endl;
797    }                                                 
798    if(par.getFlagSmooth()){                           
799      theStream<<std::setw(widthText)<<"Saving smoothed cube?"           
800               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputSmooth]"
801               <<"  =  " <<resetiosflags(std::ios::right)
802               <<stringize(par.getFlagOutputSmooth())<<std::endl;
803    }                                                 
804    theStream<<std::setw(widthText)<<"Saving mask cube?"           
805             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputMask]"
806             <<"  =  " <<resetiosflags(std::ios::right)
807             <<stringize(par.getFlagOutputMask())<<std::endl;
808    theStream  <<"------"<<std::endl;
809    if(par.getFlagBlankPix()){
810      theStream<<std::setw(widthText)<<"Blank Pixel Value"                   
811               <<std::setw(widthPar)<<setiosflags(std::ios::right)<< ""
812               <<"  =  " <<resetiosflags(std::ios::right)
813               <<par.getBlankPixVal()    <<std::endl;
814    }
815    theStream  <<std::setw(widthText)<<"Trimming Blank Pixels?"                 
816               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagTrim]"
817               <<"  =  " <<resetiosflags(std::ios::right)
818               <<stringize(par.getFlagTrim())   <<std::endl;
819    theStream  <<std::setw(widthText)<<"Searching for Negative features?"     
820               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagNegative]"
821               <<"  =  " <<resetiosflags(std::ios::right)
822               <<stringize(par.getFlagNegative())   <<std::endl;
823    theStream  <<std::setw(widthText)<<"Removing Milky Way channels?"         
824               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagMW]"
825               <<"  =  " <<resetiosflags(std::ios::right)
826               <<stringize(par.getFlagMW())         <<std::endl;
827    if(par.getFlagMW()){
828      theStream<<std::setw(widthText)<<"Milky Way Channels"                   
829               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minMW - maxMW]"
830               <<"  =  " <<resetiosflags(std::ios::right)
831               <<par.getMinMW()
832               <<"-" <<par.getMaxMW()          <<std::endl;
833    }
834    theStream  <<std::setw(widthText)<<"Beam Size (pixels)"                   
835               <<std::setw(widthPar)<<setiosflags(std::ios::right)<< beamParam
836               <<"  =  " <<resetiosflags(std::ios::right)
837               <<par.getBeamSize()       <<std::endl;
838    theStream  <<std::setw(widthText)<<"Removing baselines before search?"   
839               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBaseline]"
840               <<"  =  " <<resetiosflags(std::ios::right)
841               <<stringize(par.getFlagBaseline())   <<std::endl;
842    theStream  <<std::setw(widthText)<<"Smoothing each spectrum first?"       
843               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagSmooth]"
844               <<"  =  " <<resetiosflags(std::ios::right)
845               <<stringize(par.getFlagSmooth())     <<std::endl;
846    if(par.getFlagSmooth()){           
847      theStream<<std::setw(widthText)<<"Type of smoothing"     
848               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothType]"
849               <<"  =  " <<resetiosflags(std::ios::right)
850               <<par.getSmoothType()       <<std::endl;
851      if(par.getSmoothType()=="spectral")
852        theStream<<std::setw(widthText)<<"Width of hanning filter"     
853                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[hanningWidth]"
854                 <<"  =  " <<resetiosflags(std::ios::right)
855                 <<par.getHanningWidth()       <<std::endl;
856      else{
857        theStream<<std::setw(widthText)<<"Gaussian kernel semi-major axis [pix]"
858                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[kernMaj]"
859                 <<"  =  " <<resetiosflags(std::ios::right)
860                 <<par.getKernMaj() << std::endl;
861        theStream<<std::setw(widthText)<<"Gaussian kernel semi-minor axis [pix]"
862                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[kernMin]"
863                 <<"  =  " <<resetiosflags(std::ios::right)
864                 <<par.getKernMin() << std::endl;
865        theStream<<std::setw(widthText)<<"Gaussian kernel position angle [deg]"
866                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[kernPA]"
867                 <<"  =  " <<resetiosflags(std::ios::right)
868                 <<par.getKernPA() << std::endl;
869      }
870    }
871    theStream  <<std::setw(widthText)<<"Using A Trous reconstruction?"       
872               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagATrous]"
873               <<"  =  " <<resetiosflags(std::ios::right)
874               <<stringize(par.getFlagATrous())     <<std::endl;
875    if(par.getFlagATrous()){                           
876      theStream<<std::setw(widthText)<<"Number of dimensions in reconstruction"     
877               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconDim]"
878               <<"  =  " <<resetiosflags(std::ios::right)
879               <<par.getReconDim()       <<std::endl;
880      if(par.getMaxScale()>0){
881        theStream<<std::setw(widthText-1)<<"Scales used in reconstruction"     
882                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin-scaleMax]"
883                 <<"  =  " <<resetiosflags(std::ios::right)
884                 <<par.getMinScale() << "-" << par.getMaxScale()   <<std::endl;
885      }
886      else{
887        theStream<<std::setw(widthText)<<"Minimum scale in reconstruction"     
888                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin]"
889                 <<"  =  " <<resetiosflags(std::ios::right)
890                 <<par.getMinScale()      <<std::endl;
891      }
892      theStream<<std::setw(widthText)<<"SNR Threshold within reconstruction" 
893               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[snrRecon]"
894               <<"  =  " <<resetiosflags(std::ios::right)
895               <<par.getAtrousCut()      <<std::endl;
896      theStream<<std::setw(widthText)<<"Filter being used for reconstruction"
897               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[filterCode]"
898               <<"  =  " <<resetiosflags(std::ios::right)
899               <<par.getFilterCode()
900               << " (" << par.getFilterName()  << ")" <<std::endl;
901    }                                                 
902    theStream  <<std::setw(widthText)<<"Using Robust statistics?"                 
903               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagRobustStats]"
904               <<"  =  " <<resetiosflags(std::ios::right)
905               <<stringize(par.getFlagRobustStats()) <<std::endl;
906    if(par.getFlagStatSec()){
907      theStream<<std::setw(widthText)<<"Section used by statistics calculation"
908               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[statSec]"
909               <<"  =  " <<resetiosflags(std::ios::right)
910               <<par.statSec.getSection()          <<std::endl;
911    }
912    theStream  <<std::setw(widthText)<<"Using FDR analysis?"                 
913               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagFDR]"
914               <<"  =  " <<resetiosflags(std::ios::right)
915               <<stringize(par.getFlagFDR())        <<std::endl;
916    if(par.getFlagFDR()){                                     
917      theStream<<std::setw(widthText)<<"Alpha value for FDR analysis"         
918               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[alphaFDR]"
919               <<"  =  " <<resetiosflags(std::ios::right)
920               <<par.getAlpha()          <<std::endl;
921    }                                                 
922    else {
923      if(par.getFlagUserThreshold()){
924        theStream<<std::setw(widthText)<<"Detection Threshold"                       
925                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshold]"
926                 <<"  =  " <<resetiosflags(std::ios::right)
927                 <<par.getThreshold()            <<std::endl;
928      }
929      else{
930        theStream<<std::setw(widthText)<<"SNR Threshold (in sigma)"
931                 <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[snrCut]"
932                 <<"  =  " <<resetiosflags(std::ios::right)
933                 <<par.getCut()            <<std::endl;
934      }
935    }
936    theStream  <<std::setw(widthText)<<"Minimum # Pixels in a detection"     
937               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minPix]"
938               <<"  =  " <<resetiosflags(std::ios::right)
939               <<par.getMinPix()         <<std::endl;
940    theStream  <<std::setw(widthText)<<"Minimum # Channels in a detection"   
941               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minChannels]"
942               <<"  =  " <<resetiosflags(std::ios::right)
943               <<par.getMinChannels()    <<std::endl;
944    theStream  <<std::setw(widthText)<<"Growing objects after detection?"     
945               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagGrowth]"
946               <<"  =  " <<resetiosflags(std::ios::right)
947               <<stringize(par.getFlagGrowth())     <<std::endl;
948    if(par.getFlagGrowth()) {                         
949      theStream<<std::setw(widthText)<<"SNR Threshold for growth"             
950               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[growthCut]"
951               <<"  =  " <<resetiosflags(std::ios::right)
952               <<par.getGrowthCut()      <<std::endl;
953    }
954    theStream  <<std::setw(widthText)<<"Using Adjacent-pixel criterion?"     
955               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagAdjacent]"
956               <<"  =  " <<resetiosflags(std::ios::right)
957               <<stringize(par.getFlagAdjacent())   <<std::endl;
958    if(!par.getFlagAdjacent()){
959      theStream<<std::setw(widthText)<<"Max. spatial separation for merging" 
960               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshSpatial]"
961               <<"  =  " <<resetiosflags(std::ios::right)
962               <<par.getThreshS()        <<std::endl;
963    }
964    theStream  <<std::setw(widthText)<<"Max. velocity separation for merging"
965               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshVelocity]"
966               <<"  =  " <<resetiosflags(std::ios::right)
967               <<par.getThreshV()        <<std::endl;
968    theStream  <<std::setw(widthText)<<"Method of spectral plotting"         
969               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectralMethod]"
970               <<"  =  " <<resetiosflags(std::ios::right)
971               <<par.getSpectralMethod() <<std::endl;
972    theStream  <<std::setw(widthText)<<"Type of object centre used in results"
973               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[pixelCentre]"
974               <<"  =  " <<resetiosflags(std::ios::right)
975               <<par.getPixelCentre() <<std::endl;
976    theStream  <<"--------------------\n\n";
977    theStream  << std::setfill(' ');
978    theStream.unsetf(std::ios::left);
979    //  theStream.unsetf(std::ios::boolalpha);
980    return theStream;
981  }
982
983
984  void Param::copyHeaderInfo(FitsHeader &head)
985  {
986    /**
987     * A function to copy across relevant header keywords from the
988     *  FitsHeader class to the Param class, as they are needed by
989     *  functions in the Param class.
990     * The parameters are the keywords BLANK, BSCALE, BZERO, and the beam size.
991     */
992
993    this->blankKeyword  = head.getBlankKeyword();
994    this->bscaleKeyword = head.getBscaleKeyword();
995    this->bzeroKeyword  = head.getBzeroKeyword();
996    this->blankPixValue = this->blankKeyword * this->bscaleKeyword +
997      this->bzeroKeyword;
998
999    this->numPixBeam    = head.getBeamSize();
1000  }
1001
1002  std::string Param::outputMaskFile()
1003  {
1004    /**
1005     *  This function produces the required filename in which to save
1006     *  the mask image, indicating which pixels have been detected as
1007     *  part of an object. If the input image is image.fits, then the
1008     *  output will be image.MASK.fits.
1009     */
1010    std::string inputName = this->imageFile;
1011    std::stringstream ss;
1012    ss << inputName.substr(0,inputName.size()-5); 
1013    // remove the ".fits" on the end.
1014    ss << ".MASK.fits";
1015    return ss.str();
1016  }
1017
1018  std::string Param::outputSmoothFile()
1019  {
1020    /**
1021     * This function produces the required filename in which to save
1022     *  the smoothed array. If the input image is image.fits, then
1023     *  the output will be:
1024     *   <ul><li> Spectral smoothing: image.SMOOTH-1D-3.fits, where the
1025     *            width of the Hanning filter was 3 pixels.
1026     *       <li> Spatial smoothing : image.SMOOTH-2D-3-2-20.fits, where
1027     *            kernMaj=3, kernMin=2 and kernPA=20 degrees.
1028     *   </ul>
1029     */
1030    std::string inputName = this->imageFile;
1031    std::stringstream ss;
1032    ss << inputName.substr(0,inputName.size()-5); 
1033    // remove the ".fits" on the end.
1034    if(this->flagSubsection) ss<<".sub";
1035    if(this->smoothType=="spectral")
1036      ss << ".SMOOTH-1D-" << this->hanningWidth << ".fits";
1037    else if(this->smoothType=="spatial")
1038      ss << ".SMOOTH-2D-"
1039         << this->kernMaj << "-"
1040         << this->kernMin << "-"
1041         << this->kernPA  << ".fits";
1042    return ss.str();
1043  }
1044
1045  std::string Param::outputReconFile()
1046  {
1047    /**
1048     * This function produces the required filename in which to save
1049     *  the reconstructed array. If the input image is image.fits, then
1050     *  the output will be eg. image.RECON-3-2-4-1.fits, where the numbers are
1051     *  3=reconDim, 2=filterCode, 4=snrRecon, 1=minScale
1052     */
1053    std::string inputName = this->imageFile;
1054    std::stringstream ss;
1055    // First we remove the ".fits" from the end of the filename.
1056    ss << inputName.substr(0,inputName.size()-5); 
1057    if(this->flagSubsection) ss<<".sub";
1058    ss << ".RECON-" << this->reconDim
1059       << "-"       << this->filterCode
1060       << "-"       << this->snrRecon
1061       << "-"       << this->scaleMin
1062       << ".fits";
1063    return ss.str();
1064  }
1065
1066  std::string Param::outputResidFile()
1067  {
1068    /**
1069     * This function produces the required filename in which to save
1070     *  the reconstructed array. If the input image is image.fits, then
1071     *  the output will be eg. image.RESID-3-2-4-1.fits, where the numbers are
1072     *  3=reconDim, 2=filterCode, 4=snrRecon, 1=scaleMin
1073     */
1074    std::string inputName = this->imageFile;
1075    std::stringstream ss;
1076    // First we remove the ".fits" from the end of the filename.
1077    ss << inputName.substr(0,inputName.size()-5);
1078    if(this->flagSubsection) ss<<".sub";
1079    ss << ".RESID-" << this->reconDim
1080       << "-"       << this->filterCode
1081       << "-"       << this->snrRecon
1082       << "-"       << this->scaleMin
1083       << ".fits";
1084    return ss.str();
1085  }
1086
1087}
Note: See TracBrowser for help on using the repository browser.