source: trunk/src/param.cc @ 269

Last change on this file since 269 was 269, checked in by Matthew Whiting, 17 years ago
  • Main changed is to enable outputSpectra to plot the spectral baseline if that has been fitted. This is done in yellow.
  • This meant we had to add code to fix the baseline array in the unTrimCube() function.
  • The trimming threshold for the baseline determination has dropped to 5sigma.
  • changed calls to swap to std::swap in sort.cc
  • Other minor comments changes.
File size: 39.9 KB
RevLine 
[3]1#include <iostream>
2#include <iomanip>
3#include <fstream>
4#include <sstream>
5#include <string>
[205]6#include <stdlib.h>
[269]7#include <ctype.h>
[3]8#include <math.h>
[103]9#include <wcs.h>
10#include <wcsunits.h>
[3]11#include <param.hh>
[134]12#include <config.h>
[142]13#include <duchamp.hh>
[232]14#include <ATrous/filter.hh>
[103]15#include <Utils/utils.hh>
[258]16#include <Utils/Section.hh>
[3]17
[194]18// Define funtion to print bools as words, in case the compiler doesn't
19//  recognise the setf(ios::boolalpha) command...
[110]20#ifdef HAVE_STDBOOL_H
[232]21std::string stringize(bool b){
[110]22  std::stringstream ss;
23  ss.setf(std::ios::boolalpha);
24  ss << b;
25  return ss.str();
26}
27#else
[232]28std::string stringize(bool b){
[110]29  std::string output;
30  if(b) output="true";
31  else output="false";
32  return output;
33}
34#endif
35
[3]36/****************************************************************/
37///////////////////////////////////////////////////
[103]38//// Functions for FitsHeader class:
39///////////////////////////////////////////////////
40
[204]41FitsHeader::FitsHeader()
42{
[205]43  this->wcs = (struct wcsprm *)calloc(1,sizeof(struct wcsprm));
[103]44  this->wcs->flag=-1;
[204]45  wcsini(true, 3, this->wcs);
[103]46  this->wcsIsGood = false;
47  this->nwcs = 0;
48  this->scale=1.;
49  this->offset=0.;
50  this->power=1.;
51  this->fluxUnits="counts";
52}
53
[204]54FitsHeader::FitsHeader(const FitsHeader& h)
55{
[205]56  this->wcs = (struct wcsprm *)calloc(1,sizeof(struct wcsprm));
[103]57  this->wcs->flag=-1;
[204]58  wcsini(true, h.wcs->naxis, this->wcs);
59  wcscopy(true, h.wcs, this->wcs);
[103]60  wcsset(this->wcs);
[137]61  this->nwcs = h.nwcs;
62  this->wcsIsGood = h.wcsIsGood;
63  this->spectralUnits = h.spectralUnits;
64  this->fluxUnits = h.fluxUnits;
65  this->intFluxUnits = h.intFluxUnits;
66  this->beamSize = h.beamSize;
67  this->bmajKeyword = h.bmajKeyword;
68  this->bminKeyword = h.bminKeyword;
69  this->blankKeyword = h.blankKeyword;
70  this->bzeroKeyword = h.bzeroKeyword;
71  this->bscaleKeyword = h.bscaleKeyword;
72  this->scale = h.scale;
73  this->offset = h.offset;
74  this->power = h.power;
[103]75}
76
[204]77FitsHeader& FitsHeader::operator= (const FitsHeader& h)
78{
[205]79  this->wcs = (struct wcsprm *)calloc(1,sizeof(struct wcsprm));
[103]80  this->wcs->flag=-1;
[204]81  wcsini(true, h.wcs->naxis, this->wcs);
82  wcscopy(true, h.wcs, this->wcs);
[103]83  wcsset(this->wcs);
[137]84  this->nwcs = h.nwcs;
85  this->wcsIsGood = h.wcsIsGood;
86  this->spectralUnits = h.spectralUnits;
87  this->fluxUnits = h.fluxUnits;
88  this->intFluxUnits = h.intFluxUnits;
89  this->beamSize = h.beamSize;
90  this->bmajKeyword = h.bmajKeyword;
91  this->bminKeyword = h.bminKeyword;
92  this->blankKeyword = h.blankKeyword;
93  this->bzeroKeyword = h.bzeroKeyword;
94  this->bscaleKeyword = h.bscaleKeyword;
95  this->scale = h.scale;
96  this->offset = h.offset;
97  this->power = h.power;
[103]98}
99
[204]100void FitsHeader::setWCS(struct wcsprm *w)
[103]101{
102  /**
103   *  A function that assigns the wcs parameters, and runs
104   *   wcsset to set it up correctly.
105   *  Performs a check to see if the WCS is good (by looking at
106   *   the lng and lat wcsprm parameters), and sets the wcsIsGood
107   *   flag accordingly.
[221]108   * \param w A WCSLIB wcsprm struct with the correct parameters.
[103]109   */
[204]110  wcscopy(true, w, this->wcs);
[103]111  wcsset(this->wcs);
112  if( (w->lng!=-1) && (w->lat!=-1) ) this->wcsIsGood = true;
113}
114
[204]115struct wcsprm *FitsHeader::getWCS()
[103]116{
117  /**
[221]118   *  A function that returns a properly initilized wcsprm object
119   *  corresponding to the WCS.
[103]120   */
[205]121  struct wcsprm *wNew = (struct wcsprm *)calloc(1,sizeof(struct wcsprm));
[103]122  wNew->flag=-1;
[204]123  wcsini(true, this->wcs->naxis, wNew);
124  wcscopy(true, this->wcs, wNew);
[103]125  wcsset(wNew);
126  return wNew;
127}
128
[222]129int FitsHeader::wcsToPix(const double *world, double *pix){     
130  return wcsToPixSingle(this->wcs, world, pix); 
131};
132int FitsHeader::wcsToPix(const double *world, double *pix, const int npts){
133  return wcsToPixMulti(this->wcs, world, pix, npts); 
134};
135int FitsHeader::pixToWCS(const double *pix, double *world){   
136  return pixToWCSSingle(this->wcs, pix, world); 
137};
138int FitsHeader::pixToWCS(const double *pix, double *world, const int npts){
139  return pixToWCSMulti(this->wcs, pix,world, npts); 
140};
141
142
[204]143double FitsHeader::pixToVel(double &x, double &y, double &z)
[103]144{
[186]145  double vel;
146  if(this->wcsIsGood){
147    double *pix   = new double[3];
148    double *world = new double[3];
149    pix[0] = x; pix[1] = y; pix[2] = z;
150    pixToWCSSingle(this->wcs,pix,world);
151    vel = this->specToVel(world[2]);
152    delete [] pix;
153    delete [] world;
154  }
155  else vel = z;
[103]156  return vel;
157}
158
159double* FitsHeader::pixToVel(double &x, double &y, double *zarray, int size)
160{
[186]161  double *newzarray = new double[size];
162  if(this->wcsIsGood){
163    double *pix   = new double[size*3];
164    for(int i=0;i<size;i++){
[187]165      pix[3*i]   = x;
166      pix[3*i+1] = y;
167      pix[3*i+2] = zarray[i];
[186]168    }
169    double *world = new double[size*3];
170    pixToWCSMulti(this->wcs,pix,world,size);
171    delete [] pix;
172    for(int i=0;i<size;i++) newzarray[i] = this->specToVel(world[3*i+2]);
173    delete [] world;
[103]174  }
[186]175  else{
176    for(int i=0;i<size;i++) newzarray[i] = zarray[i];
177  }
[103]178  return newzarray;
179}
180
181double  FitsHeader::specToVel(const double &coord)
182{
183  double vel;
[139]184  if(power==1.0) vel =  coord*this->scale + this->offset;
[103]185  else vel = pow( (coord*this->scale + this->offset), this->power);
186  return vel;
187}
188
189double  FitsHeader::velToSpec(const float &velocity)
190{
191//   return velToCoord(this->wcs,velocity,this->spectralUnits);};
192  return (pow(velocity, 1./this->power) - this->offset) / this->scale;}
193
[232]194std::string  FitsHeader::getIAUName(double ra, double dec)
[103]195{
[201]196  if(strcmp(this->wcs->lngtyp,"RA")==0)
197    return getIAUNameEQ(ra, dec, this->wcs->equinox);
198  else
199    return getIAUNameGAL(ra, dec);
[103]200}
201
202void FitsHeader::fixUnits(Param &par)
203{
204  // define spectral units from the param set
205  this->spectralUnits = par.getSpectralUnits();
206
207  double sc=1.;
208  double of=0.;
[224]209  double po=1.;
[103]210  if(this->wcsIsGood){
[205]211    int status = wcsunits( this->wcs->cunit[this->wcs->spec],
[223]212                           this->spectralUnits.c_str(),
213                           &sc, &of, &po);
[205]214    if(status > 0){
[120]215      std::stringstream errmsg;
[205]216      errmsg << "WCSUNITS Error, Code = " << status
217             << ": " << wcsunits_errmsg[status];
[224]218      if(status == 10) errmsg << "\nTried to get conversion from \""
219                              << this->wcs->cunit[this->wcs->spec] << "\" to \""
220                              << this->spectralUnits.c_str() << "\".\n";
[204]221      this->spectralUnits = this->wcs->cunit[this->wcs->spec];
[103]222      if(this->spectralUnits==""){
[224]223        errmsg << "Spectral units not specified. "
224               << "For data presentation, we will use dummy units of \"SPC\".\n"
225               << "Please report this occurence -- it should not happen now!"
226               << "In the meantime, you may want to set the CUNIT"
227               << this->wcs->spec + 1 <<" keyword to make this work.\n";
[219]228        this->spectralUnits = "SPC";
[103]229      }
[120]230      duchampError("fixUnits", errmsg.str());
231     
[103]232    }
233  }
234  this->scale = sc;
235  this->offset= of;
236  this->power = po;
237
[142]238  // Work out the integrated flux units, based on the spectral units.
239  // If flux is per beam, trim the /beam from the flux units and multiply
240  //  by the spectral units.
241  // Otherwise, just muliply by the spectral units.
[103]242  if(this->fluxUnits.size()>0){
[142]243    if(this->fluxUnits.substr(this->fluxUnits.size()-5,
244                              this->fluxUnits.size()   ) == "/beam"){
[103]245      this->intFluxUnits = this->fluxUnits.substr(0,this->fluxUnits.size()-5)
246        +" " +this->spectralUnits;
247    }
[159]248    else this->intFluxUnits = this->fluxUnits + " " + this->spectralUnits;
[103]249  }
250
251}
252
253/****************************************************************/
254///////////////////////////////////////////////////
[3]255//// Accessor Functions for Parameter class:
256///////////////////////////////////////////////////
257Param::Param(){
258  /**
259   * Param()
260   *  Default intial values for the parameters.
261   * imageFile has no default value!
262   */
[258]263  std::string baseSection = "[*,*,*]";
[3]264  // Input files
[190]265  this->imageFile         = "";
266  this->flagSubsection    = false;
[258]267  this->pixelSec.setSection(baseSection);
[190]268  this->flagReconExists   = false;
269  this->reconFile         = "";
[208]270  this->flagSmoothExists  = false;
271  this->smoothFile        = "";
[3]272  // Output files
[190]273  this->flagLog           = true;
274  this->logFile           = "duchamp-Logfile.txt";
275  this->outFile           = "duchamp-Results.txt";
276  this->spectraFile       = "duchamp-Spectra.ps";
[208]277  this->flagOutputSmooth  = false;
[190]278  this->flagOutputRecon   = false;
279  this->flagOutputResid   = false;
280  this->flagVOT           = false;
281  this->votFile           = "duchamp-Results.xml";
282  this->flagKarma         = false;
283  this->karmaFile         = "duchamp-Results.ann";
284  this->flagMaps          = true;
285  this->detectionMap      = "duchamp-DetectionMap.ps";
286  this->momentMap         = "duchamp-MomentMap.ps";
[195]287  this->flagXOutput       = true;
[3]288  // Cube related parameters
[190]289  this->flagBlankPix      = true;
290  this->blankPixValue     = -8.00061;
291  this->blankKeyword      = 1;
292  this->bscaleKeyword     = -8.00061;
293  this->bzeroKeyword      = 0.;
294  this->flagUsingBlank    = false;
295  this->flagMW            = false;
296  this->maxMW             = 112;
297  this->minMW             = 75;
298  this->numPixBeam        = 10.;
299  this->flagUsingBeam     = false;
[3]300  // Trim-related         
[190]301  this->flagTrimmed       = false;
302  this->borderLeft        = 0;
303  this->borderRight       = 0;
304  this->borderBottom      = 0;
305  this->borderTop         = 0;
[3]306  // Subsection offsets
[204]307  this->sizeOffsets       = 0;
[190]308  this->xSubOffset        = 0;
309  this->ySubOffset        = 0;
310  this->zSubOffset        = 0;
[3]311  // Baseline related
[190]312  this->flagBaseline      = false;
[3]313  // Detection-related   
[190]314  this->flagNegative      = false;
[3]315  // Object growth       
[190]316  this->flagGrowth        = false;
317  this->growthCut         = 2.;
[3]318  // FDR analysis         
[190]319  this->flagFDR           = false;
320  this->alphaFDR          = 0.01;
[3]321  // Other detection     
[258]322  this->flagStatSec       = false;
323  this->statSec.setSection(baseSection);
[190]324  this->snrCut            = 3.;
325  this->threshold         = 0.;
326  this->flagUserThreshold = false;
[201]327  // Hanning Smoothing
328  this->flagSmooth        = false;
329  this->hanningWidth      = 5;
[3]330  // A trous reconstruction parameters
[190]331  this->flagATrous        = true;
[258]332  this->reconDim          = 1;
[190]333  this->scaleMin          = 1;
334  this->snrRecon          = 4.;
335  this->filterCode        = 1;
[232]336  this->reconFilter.define(this->filterCode);
[3]337  // Volume-merging parameters
[190]338  this->flagAdjacent      = true;
339  this->threshSpatial     = 3.;
340  this->threshVelocity    = 7.;
341  this->minChannels       = 3;
342  this->minPix            = 2;
[3]343  // Input-Output related
[190]344  this->spectralMethod    = "peak";
[265]345  this->spectralUnits     = "km/s";
346  this->pixelCentre       = "centroid";
[190]347  this->borders           = true;
348  this->blankEdge         = true;
349  this->verbose           = true;
[3]350};
351
[204]352Param::Param (const Param& p)
353{
354  this->imageFile         = p.imageFile;
355  this->flagSubsection    = p.flagSubsection;
[258]356  this->pixelSec          = p.pixelSec;
[204]357  this->flagReconExists   = p.flagReconExists;
358  this->reconFile         = p.reconFile;     
[208]359  this->flagSmoothExists  = p.flagSmoothExists;
360  this->smoothFile        = p.smoothFile;     
[204]361  this->flagLog           = p.flagLog;       
362  this->logFile           = p.logFile;       
363  this->outFile           = p.outFile;       
364  this->spectraFile       = p.spectraFile;   
[208]365  this->flagOutputSmooth  = p.flagOutputSmooth;
[204]366  this->flagOutputRecon   = p.flagOutputRecon;
367  this->flagOutputResid   = p.flagOutputResid;
368  this->flagVOT           = p.flagVOT;         
369  this->votFile           = p.votFile;       
370  this->flagKarma         = p.flagKarma;     
371  this->karmaFile         = p.karmaFile;     
372  this->flagMaps          = p.flagMaps;       
373  this->detectionMap      = p.detectionMap;   
374  this->momentMap         = p.momentMap;     
375  this->flagXOutput       = p.flagXOutput;       
376  this->flagBlankPix      = p.flagBlankPix;   
377  this->blankPixValue     = p.blankPixValue; 
378  this->blankKeyword      = p.blankKeyword;   
379  this->bscaleKeyword     = p.bscaleKeyword; 
380  this->bzeroKeyword      = p.bzeroKeyword;   
381  this->flagUsingBlank    = p.flagUsingBlank;
382  this->flagMW            = p.flagMW;         
383  this->maxMW             = p.maxMW;         
384  this->minMW             = p.minMW;         
385  this->numPixBeam        = p.numPixBeam;     
386  this->flagTrimmed       = p.flagTrimmed;   
387  this->borderLeft        = p.borderLeft;     
388  this->borderRight       = p.borderRight;   
389  this->borderBottom      = p.borderBottom;   
390  this->borderTop         = p.borderTop;     
391  this->sizeOffsets       = p.sizeOffsets;
[213]392  this->offsets           = new long[this->sizeOffsets];
[204]393  if(this->sizeOffsets>0)
394    for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i];
395  this->xSubOffset        = p.xSubOffset;     
396  this->ySubOffset        = p.ySubOffset;     
397  this->zSubOffset        = p.zSubOffset;
398  this->flagBaseline      = p.flagBaseline;
399  this->flagNegative      = p.flagNegative;
400  this->flagGrowth        = p.flagGrowth;
401  this->growthCut         = p.growthCut;
402  this->flagFDR           = p.flagFDR;
403  this->alphaFDR          = p.alphaFDR;
[258]404  this->flagStatSec       = p.flagStatSec;
405  this->statSec           = p.statSec;
[204]406  this->snrCut            = p.snrCut;
407  this->threshold         = p.threshold;
[205]408  this->flagUserThreshold = p.flagUserThreshold;
[204]409  this->flagSmooth        = p.flagSmooth;
410  this->hanningWidth      = p.hanningWidth;
411  this->flagATrous        = p.flagATrous;
412  this->reconDim          = p.reconDim;
413  this->scaleMin          = p.scaleMin;
414  this->snrRecon          = p.snrRecon;
415  this->filterCode        = p.filterCode;
[232]416  this->reconFilter       = p.reconFilter;
[204]417  this->flagAdjacent      = p.flagAdjacent;
418  this->threshSpatial     = p.threshSpatial;
419  this->threshVelocity    = p.threshVelocity;
420  this->minChannels       = p.minChannels;
421  this->minPix            = p.minPix;
422  this->spectralMethod    = p.spectralMethod;
[265]423  this->spectralUnits     = p.spectralUnits;
424  this->pixelCentre       = p.pixelCentre;
[204]425  this->borders           = p.borders;
426  this->verbose           = p.verbose;
427}
428
[137]429Param& Param::operator= (const Param& p)
430{
[190]431  this->imageFile         = p.imageFile;
432  this->flagSubsection    = p.flagSubsection;
[258]433  this->pixelSec          = p.pixelSec;
[190]434  this->flagReconExists   = p.flagReconExists;
435  this->reconFile         = p.reconFile;     
[208]436  this->flagSmoothExists  = p.flagSmoothExists;
437  this->smoothFile        = p.smoothFile;     
[190]438  this->flagLog           = p.flagLog;       
439  this->logFile           = p.logFile;       
440  this->outFile           = p.outFile;       
441  this->spectraFile       = p.spectraFile;   
[208]442  this->flagOutputSmooth  = p.flagOutputSmooth;
[190]443  this->flagOutputRecon   = p.flagOutputRecon;
444  this->flagOutputResid   = p.flagOutputResid;
445  this->flagVOT           = p.flagVOT;         
446  this->votFile           = p.votFile;       
447  this->flagKarma         = p.flagKarma;     
448  this->karmaFile         = p.karmaFile;     
449  this->flagMaps          = p.flagMaps;       
450  this->detectionMap      = p.detectionMap;   
451  this->momentMap         = p.momentMap;     
[195]452  this->flagXOutput       = p.flagXOutput;       
[190]453  this->flagBlankPix      = p.flagBlankPix;   
454  this->blankPixValue     = p.blankPixValue; 
455  this->blankKeyword      = p.blankKeyword;   
456  this->bscaleKeyword     = p.bscaleKeyword; 
457  this->bzeroKeyword      = p.bzeroKeyword;   
458  this->flagUsingBlank    = p.flagUsingBlank;
459  this->flagMW            = p.flagMW;         
460  this->maxMW             = p.maxMW;         
461  this->minMW             = p.minMW;         
462  this->numPixBeam        = p.numPixBeam;     
463  this->flagTrimmed       = p.flagTrimmed;   
464  this->borderLeft        = p.borderLeft;     
465  this->borderRight       = p.borderRight;   
466  this->borderBottom      = p.borderBottom;   
467  this->borderTop         = p.borderTop;     
[204]468  this->sizeOffsets       = p.sizeOffsets;
[213]469  this->offsets           = new long[this->sizeOffsets];
[204]470  if(this->sizeOffsets>0)
471    for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i];
[190]472  this->xSubOffset        = p.xSubOffset;     
473  this->ySubOffset        = p.ySubOffset;     
474  this->zSubOffset        = p.zSubOffset;
475  this->flagBaseline      = p.flagBaseline;
476  this->flagNegative      = p.flagNegative;
477  this->flagGrowth        = p.flagGrowth;
478  this->growthCut         = p.growthCut;
479  this->flagFDR           = p.flagFDR;
480  this->alphaFDR          = p.alphaFDR;
[258]481  this->flagStatSec       = p.flagStatSec;
482  this->statSec           = p.statSec;
[190]483  this->snrCut            = p.snrCut;
484  this->threshold         = p.threshold;
[205]485  this->flagUserThreshold = p.flagUserThreshold;
[201]486  this->flagSmooth        = p.flagSmooth;
487  this->hanningWidth      = p.hanningWidth;
[190]488  this->flagATrous        = p.flagATrous;
489  this->reconDim          = p.reconDim;
490  this->scaleMin          = p.scaleMin;
491  this->snrRecon          = p.snrRecon;
492  this->filterCode        = p.filterCode;
[232]493  this->reconFilter       = p.reconFilter;
[190]494  this->flagAdjacent      = p.flagAdjacent;
495  this->threshSpatial     = p.threshSpatial;
496  this->threshVelocity    = p.threshVelocity;
497  this->minChannels       = p.minChannels;
498  this->minPix            = p.minPix;
499  this->spectralMethod    = p.spectralMethod;
[265]500  this->spectralUnits     = p.spectralUnits;
501  this->pixelCentre       = p.pixelCentre;
[190]502  this->borders           = p.borders;
503  this->verbose           = p.verbose;
[137]504}
[266]505//--------------------------------------------------------------------
[137]506
[266]507int Param::getopts(int argc, char ** argv)
508{
509  /** 
510   *   A function that reads in the command-line options, in a manner
511   *    tailored for use with the main Duchamp program.
512   *
513   *   \param argc The number of command line arguments.
514   *   \param argv The array of command line arguments.
515   */
516
517  int returnValue;
518  if(argc==1){
519    std::cout << ERR_USAGE_MSG;
520    returnValue = FAILURE;
521  }
522  else {
523    std::string file;
524    Param *newpars = new Param;
525    *this = *newpars;
526    delete newpars;
527    char c;
528    while( ( c = getopt(argc,argv,"p:f:hv") )!=-1){
529      switch(c) {
530      case 'p':
531        file = optarg;
532        if(this->readParams(file)==FAILURE){
533          std::stringstream errmsg;
534          errmsg << "Could not open parameter file " << file << ".\n";
535          duchampError("Duchamp",errmsg.str());
536          returnValue = FAILURE;
537        }
538        else returnValue = SUCCESS;
539        break;
540      case 'f':
541        file = optarg;
542        this->imageFile = file;
543        returnValue = SUCCESS;
544        break;
545      case 'v':
546        std::cout << PROGNAME << " version " << VERSION << std::endl;
547        returnValue = FAILURE;
548        break;
549      case 'h':
550      default :
551        std::cout << ERR_USAGE_MSG;
552        returnValue = FAILURE;
553        break;
554      }
555    }
556  }
557  return returnValue;
558}
559//--------------------------------------------------------------------
560
561
562
563
[3]564/****************************************************************/
565///////////////////////////////////////////////////
566//// Other Functions using the  Parameter class:
567///////////////////////////////////////////////////
568
[232]569inline std::string makelower( std::string s )
[3]570{
571  // "borrowed" from Matt Howlett's 'fred'
[232]572  std::string out = "";
[3]573  for( int i=0; i<s.size(); ++i ) {
574    out += tolower(s[i]);
575  }
576  return out;
577}
578
[232]579inline bool boolify( std::string s )
[132]580{
581  /**
[133]582   * bool boolify(string)
[232]583   *  Convert a std::string to a bool variable
[132]584   *  "1" and "true" get converted to true
585   *  "0" and "false" (and anything else) get converted to false
586   */
587  if((s=="1") || (makelower(s)=="true")) return true;
588  else if((s=="0") || (makelower(s)=="false")) return false;
589  else return false;
590}
591
[232]592inline std::string readSval(std::stringstream& ss)
[163]593{
[232]594  std::string val; ss >> val; return val;
[163]595}
596
597inline bool readFlag(std::stringstream& ss)
598{
[232]599  std::string val; ss >> val; return boolify(val);
[163]600}
601
602inline float readFval(std::stringstream& ss)
603{
604  float val; ss >> val; return val;
605}
606
607inline int readIval(std::stringstream& ss)
608{
609  int val; ss >> val; return val;
610}
611
[232]612int Param::readParams(std::string paramfile)
[3]613{
[221]614  /**
615   * The parameters are read in from a disk file, on the assumption that each
616   *  line of the file has the format "parameter value" (eg. alphafdr 0.1)
617   *
618   * The case of the parameter name does not matter, nor does the
619   * formatting of the spaces (it can be any amount of whitespace or
620   * tabs).
621   *
622   * \param paramfile A std::string containing the parameter filename.
623   */
[3]624  std::ifstream fin(paramfile.c_str());
[160]625  if(!fin.is_open()) return FAILURE;
[232]626  std::string line;
[3]627  while( !std::getline(fin,line,'\n').eof()){
628
629    if(line[0]!='#'){
630      std::stringstream ss;
631      ss.str(line);
[232]632      std::string arg;
[163]633      ss >> arg;
634      arg = makelower(arg);
635      if(arg=="imagefile")       this->imageFile = readSval(ss);
636      if(arg=="flagsubsection")  this->flagSubsection = readFlag(ss);
[258]637      if(arg=="subsection")      this->pixelSec.setSection(readSval(ss));
[163]638      if(arg=="flagreconexists") this->flagReconExists = readFlag(ss);
639      if(arg=="reconfile")       this->reconFile = readSval(ss);
[208]640      if(arg=="flagsmoothexists")this->flagSmoothExists = readFlag(ss);
641      if(arg=="smoothfile")      this->smoothFile = readSval(ss);
[71]642
[163]643      if(arg=="flaglog")         this->flagLog = readFlag(ss);
644      if(arg=="logfile")         this->logFile = readSval(ss);
645      if(arg=="outfile")         this->outFile = readSval(ss);
646      if(arg=="spectrafile")     this->spectraFile = readSval(ss);
[208]647      if(arg=="flagoutputsmooth")this->flagOutputSmooth = readFlag(ss);
[163]648      if(arg=="flagoutputrecon") this->flagOutputRecon = readFlag(ss);
649      if(arg=="flagoutputresid") this->flagOutputResid = readFlag(ss);
650      if(arg=="flagvot")         this->flagVOT = readFlag(ss);
651      if(arg=="votfile")         this->votFile = readSval(ss);
652      if(arg=="flagkarma")       this->flagKarma = readFlag(ss);
653      if(arg=="karmafile")       this->karmaFile = readSval(ss);
654      if(arg=="flagmaps")        this->flagMaps = readFlag(ss);
655      if(arg=="detectionmap")    this->detectionMap = readSval(ss);
656      if(arg=="momentmap")       this->momentMap = readSval(ss);
[195]657      if(arg=="flagxoutput")     this->flagXOutput = readFlag(ss);
[3]658
[163]659      if(arg=="flagnegative")    this->flagNegative = readFlag(ss);
660      if(arg=="flagblankpix")    this->flagBlankPix = readFlag(ss);
661      if(arg=="blankpixvalue")   this->blankPixValue = readFval(ss);
662      if(arg=="flagmw")          this->flagMW = readFlag(ss);
663      if(arg=="maxmw")           this->maxMW = readIval(ss);
664      if(arg=="minmw")           this->minMW = readIval(ss);
665      if(arg=="beamsize")        this->numPixBeam = readFval(ss);
[71]666
[163]667      if(arg=="flagbaseline")    this->flagBaseline = readFlag(ss);
668      if(arg=="minpix")          this->minPix = readIval(ss);
669      if(arg=="flaggrowth")      this->flagGrowth = readFlag(ss);
670      if(arg=="growthcut")       this->growthCut = readFval(ss);
[71]671
[163]672      if(arg=="flagfdr")         this->flagFDR = readFlag(ss);
673      if(arg=="alphafdr")        this->alphaFDR = readFval(ss);
[103]674
[258]675      if(arg=="flagstatsec")     this->flagStatSec = readFlag(ss);
676      if(arg=="statsec")         this->statSec.setSection(readSval(ss));
[163]677      if(arg=="snrcut")          this->snrCut = readFval(ss);
[190]678      if(arg=="threshold"){
679                                 this->threshold = readFval(ss);
680                                 this->flagUserThreshold = true;
681      }
[201]682     
683      if(arg=="flagsmooth")      this->flagSmooth = readFlag(ss);
684      if(arg=="hanningwidth")    this->hanningWidth = readIval(ss);
[103]685
[163]686      if(arg=="flagatrous")      this->flagATrous = readFlag(ss);
687      if(arg=="recondim")        this->reconDim = readIval(ss);
688      if(arg=="scalemin")        this->scaleMin = readIval(ss);
689      if(arg=="snrrecon")        this->snrRecon = readFval(ss);
[232]690      if(arg=="filtercode"){
691                                 this->filterCode = readIval(ss);
692                                 this->reconFilter.define(this->filterCode);
693      }
[71]694
[163]695      if(arg=="flagadjacent")    this->flagAdjacent = readFlag(ss);
696      if(arg=="threshspatial")   this->threshSpatial = readFval(ss);
697      if(arg=="threshvelocity")  this->threshVelocity = readFval(ss);
698      if(arg=="minchannels")     this->minChannels = readIval(ss);
[71]699
[265]700      if(arg=="spectralmethod")  this->spectralMethod = makelower(readSval(ss));
701      if(arg=="spectralunits")   this->spectralUnits = makelower(readSval(ss));
702      if(arg=="pixelcentre")     this->pixelCentre = makelower(readSval(ss));
[163]703      if(arg=="drawborders")     this->borders = readFlag(ss);
704      if(arg=="drawblankedges")  this->blankEdge = readFlag(ss);
705      if(arg=="verbose")         this->verbose = readFlag(ss);
[3]706    }
707  }
[208]708  if(this->flagATrous) this->flagSmooth = false;
[232]709
[265]710  // Make sure spectralMethod is an acceptable type -- default is "peak"
711  if((this->spectralMethod!="peak")&&(this->spectralMethod!="sum")){
712    duchampWarning("readParams","Changing spectralMethod to \"peak\".\n");
713    this->spectralMethod = "peak";
714  }
715
716  // Make sure pixelCentre is an acceptable type -- default is "peak"
717  if((this->pixelCentre!="centroid")&&
718     (this->pixelCentre!="average") &&
719     (this->pixelCentre!="peak")       ){
720    duchampWarning("readParams","Changing pixelCentre to \"centroid\".\n");
721    this->pixelCentre = "centroid";
722  }
723
[160]724  return SUCCESS;
[3]725}
726
727
728std::ostream& operator<< ( std::ostream& theStream, Param& par)
729{
[221]730  /**
731   * Print out the parameter set in a formatted, easy to read style.
732   * Lists the parameters, a description of them, and their value.
733   */
734
[103]735  // Only show the [blankPixValue] bit if we are using the parameter
736  // otherwise we have read it from the FITS header.
[232]737  std::string blankParam = "";
[103]738  if(par.getFlagUsingBlank()) blankParam = "[blankPixValue]";
[232]739  std::string beamParam = "";
[172]740  if(par.getFlagUsingBeam()) beamParam = "[beamSize]";
[103]741
[107]742  // BUG -- can get error: `boolalpha' is not a member of type `ios' -- old compilers: gcc 2.95.3?
[172]743  //   theStream.setf(std::ios::boolalpha);
[3]744  theStream.setf(std::ios::left);
[232]745  theStream  <<"\n---- Parameters ----"<<std::endl;
[103]746  theStream  << std::setfill('.');
[187]747  const int widthText = 38;
748  const int widthPar  = 18;
[3]749  if(par.getFlagSubsection())
[232]750    theStream<<std::setw(widthText)<<"Image to be analysed"                 
751             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]"
[103]752             <<"  =  " <<resetiosflags(std::ios::right)
[232]753             <<(par.getImageFile()+par.getSubsection()) <<std::endl;
[3]754  else
[232]755    theStream<<std::setw(widthText)<<"Image to be analysed"                 
756             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]"
[172]757             <<"  =  " <<resetiosflags(std::ios::right)
[232]758             <<par.getImageFile()      <<std::endl;
[81]759  if(par.getFlagReconExists() && par.getFlagATrous()){
[232]760    theStream<<std::setw(widthText)<<"Reconstructed array exists?"         
761             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconExists]"
[172]762             <<"  =  " <<resetiosflags(std::ios::right)
[232]763             <<stringize(par.getFlagReconExists())<<std::endl;
764    theStream<<std::setw(widthText)<<"FITS file containing reconstruction" 
765             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconFile]"
[172]766             <<"  =  " <<resetiosflags(std::ios::right)
[232]767             <<par.getReconFile()      <<std::endl;
[71]768  }
[208]769  if(par.getFlagSmoothExists() && par.getFlagSmooth()){
[232]770    theStream<<std::setw(widthText)<<"Hanning-smoothed array exists?"         
771             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothExists]"
[208]772             <<"  =  " <<resetiosflags(std::ios::right)
[232]773             <<stringize(par.getFlagSmoothExists())<<std::endl;
774    theStream<<std::setw(widthText)<<"FITS file containing smoothed array" 
775             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothFile]"
[208]776             <<"  =  " <<resetiosflags(std::ios::right)
[232]777             <<par.getSmoothFile()      <<std::endl;
[208]778  }
[232]779  theStream  <<std::setw(widthText)<<"Intermediate Logfile"
780             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[logFile]"
[172]781             <<"  =  " <<resetiosflags(std::ios::right)
[232]782             <<par.getLogFile()        <<std::endl;
783  theStream  <<std::setw(widthText)<<"Final Results file"                   
784             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[outFile]"
[172]785             <<"  =  " <<resetiosflags(std::ios::right)
[232]786             <<par.getOutFile()        <<std::endl;
787  theStream  <<std::setw(widthText)<<"Spectrum file"                       
788             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectraFile]"
[172]789             <<"  =  " <<resetiosflags(std::ios::right)
[232]790             <<par.getSpectraFile()    <<std::endl;
[3]791  if(par.getFlagVOT()){
[232]792    theStream<<std::setw(widthText)<<"VOTable file"                         
793             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[votFile]"
[172]794             <<"  =  " <<resetiosflags(std::ios::right)
[232]795             <<par.getVOTFile()        <<std::endl;
[3]796  }
[20]797  if(par.getFlagKarma()){
[232]798    theStream<<std::setw(widthText)<<"Karma annotation file"               
799             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[karmaFile]"
[172]800             <<"  =  " <<resetiosflags(std::ios::right)
801             
[232]802             <<par.getKarmaFile()      <<std::endl;
[20]803  }
[3]804  if(par.getFlagMaps()){
[232]805    theStream<<std::setw(widthText)<<"0th Moment Map"                       
806             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[momentMap]"
[172]807             <<"  =  " <<resetiosflags(std::ios::right)
[232]808             <<par.getMomentMap()      <<std::endl;
809    theStream<<std::setw(widthText)<<"Detection Map"                       
810             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[detectionMap]"
[172]811             <<"  =  " <<resetiosflags(std::ios::right)
[232]812             <<par.getDetectionMap()   <<std::endl;
[3]813  }
[232]814  theStream  <<std::setw(widthText)<<"Display a map in a pgplot xwindow?"
815             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagXOutput]"
[195]816             <<"  =  " <<resetiosflags(std::ios::right)
[232]817             <<stringize(par.getFlagXOutput())     <<std::endl;
[3]818  if(par.getFlagATrous()){                             
[232]819    theStream<<std::setw(widthText)<<"Saving reconstructed cube?"           
820             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputrecon]"
[172]821             <<"  =  " <<resetiosflags(std::ios::right)
[232]822             <<stringize(par.getFlagOutputRecon())<<std::endl;
823    theStream<<std::setw(widthText)<<"Saving residuals from reconstruction?"
824             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputresid]"
[172]825             <<"  =  " <<resetiosflags(std::ios::right)
[232]826             <<stringize(par.getFlagOutputResid())<<std::endl;
[3]827  }                                                   
[208]828  if(par.getFlagSmooth()){                             
[232]829    theStream<<std::setw(widthText)<<"Saving Hanning-smoothed cube?"           
830             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputsmooth]"
[208]831             <<"  =  " <<resetiosflags(std::ios::right)
[232]832             <<stringize(par.getFlagOutputSmooth())<<std::endl;
[208]833  }                                                   
[232]834  theStream  <<"------"<<std::endl;
835  theStream  <<std::setw(widthText)<<"Searching for Negative features?"     
836             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagNegative]"
[172]837             <<"  =  " <<resetiosflags(std::ios::right)
[232]838             <<stringize(par.getFlagNegative())   <<std::endl;
839  theStream  <<std::setw(widthText)<<"Fixing Blank Pixels?"                 
840             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBlankPix]"
[172]841             <<"  =  " <<resetiosflags(std::ios::right)
[232]842             <<stringize(par.getFlagBlankPix())   <<std::endl;
[3]843  if(par.getFlagBlankPix()){
[232]844    theStream<<std::setw(widthText)<<"Blank Pixel Value"                   
845             <<std::setw(widthPar)<<setiosflags(std::ios::right)<< blankParam
[172]846             <<"  =  " <<resetiosflags(std::ios::right)
[232]847             <<par.getBlankPixVal()    <<std::endl;
[3]848  }
[232]849  theStream  <<std::setw(widthText)<<"Removing Milky Way channels?"         
850             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagMW]"
[172]851             <<"  =  " <<resetiosflags(std::ios::right)
[232]852             <<stringize(par.getFlagMW())         <<std::endl;
[3]853  if(par.getFlagMW()){
[232]854    theStream<<std::setw(widthText)<<"Milky Way Channels"                   
855             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minMW - maxMW]"
[172]856             <<"  =  " <<resetiosflags(std::ios::right)
857             <<par.getMinMW()
[232]858             <<"-" <<par.getMaxMW()          <<std::endl;
[3]859  }
[232]860  theStream  <<std::setw(widthText)<<"Beam Size (pixels)"                   
861             <<std::setw(widthPar)<<setiosflags(std::ios::right)<< beamParam
[172]862             <<"  =  " <<resetiosflags(std::ios::right)
[232]863             <<par.getBeamSize()       <<std::endl;
864  theStream  <<std::setw(widthText)<<"Removing baselines before search?"   
865             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBaseline]"
[172]866             <<"  =  " <<resetiosflags(std::ios::right)
[232]867             <<stringize(par.getFlagBaseline())   <<std::endl;
868  theStream  <<std::setw(widthText)<<"Minimum # Pixels in a detection"     
869             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minPix]"
[172]870             <<"  =  " <<resetiosflags(std::ios::right)
[232]871             <<par.getMinPix()         <<std::endl;
872  theStream  <<std::setw(widthText)<<"Minimum # Channels in a detection"   
873             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minChannels]"
[172]874             <<"  =  " <<resetiosflags(std::ios::right)
[232]875             <<par.getMinChannels()    <<std::endl;
876  theStream  <<std::setw(widthText)<<"Growing objects after detection?"     
877             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagGrowth]"
[172]878             <<"  =  " <<resetiosflags(std::ios::right)
[232]879             <<stringize(par.getFlagGrowth())     <<std::endl;
[3]880  if(par.getFlagGrowth()) {                           
[232]881    theStream<<std::setw(widthText)<<"SNR Threshold for growth"             
882             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[growthCut]"
[172]883             <<"  =  " <<resetiosflags(std::ios::right)
[232]884             <<par.getGrowthCut()      <<std::endl;
[3]885  }
[232]886  theStream  <<std::setw(widthText)<<"Hanning-smoothing each spectrum first?"       
887             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagSmooth]"
[201]888             <<"  =  " <<resetiosflags(std::ios::right)
[232]889             <<stringize(par.getFlagSmooth())     <<std::endl;
[201]890  if(par.getFlagSmooth())                             
[232]891    theStream<<std::setw(widthText)<<"Width of hanning filter"     
892             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[hanningWidth]"
[201]893             <<"  =  " <<resetiosflags(std::ios::right)
[232]894             <<par.getHanningWidth()       <<std::endl;
895  theStream  <<std::setw(widthText)<<"Using A Trous reconstruction?"       
896             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagATrous]"
[172]897             <<"  =  " <<resetiosflags(std::ios::right)
[232]898             <<stringize(par.getFlagATrous())     <<std::endl;
[3]899  if(par.getFlagATrous()){                             
[232]900    theStream<<std::setw(widthText)<<"Number of dimensions in reconstruction"     
901             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconDim]"
[172]902             <<"  =  " <<resetiosflags(std::ios::right)
[232]903             <<par.getReconDim()       <<std::endl;
904    theStream<<std::setw(widthText)<<"Minimum scale in reconstruction"     
905             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin]"
[172]906             <<"  =  " <<resetiosflags(std::ios::right)
[232]907             <<par.getMinScale()       <<std::endl;
908    theStream<<std::setw(widthText)<<"SNR Threshold within reconstruction" 
909             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[snrRecon]"
[172]910             <<"  =  " <<resetiosflags(std::ios::right)
[232]911             <<par.getAtrousCut()      <<std::endl;
912    theStream<<std::setw(widthText)<<"Filter being used for reconstruction"
913             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[filterCode]"
[172]914             <<"  =  " <<resetiosflags(std::ios::right)
915             <<par.getFilterCode()
[232]916             << " (" << par.getFilterName()  << ")" <<std::endl;
[3]917  }                                                   
[258]918  if(par.getFlagStatSec()){
919    theStream<<std::setw(widthText)<<"Section used by statistics calculation"
920             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[statSec]"
921             <<"  =  " <<resetiosflags(std::ios::right)
922             <<par.statSec.getSection()          <<std::endl;
923  }
[232]924  theStream  <<std::setw(widthText)<<"Using FDR analysis?"                 
925             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagFDR]"
[172]926             <<"  =  " <<resetiosflags(std::ios::right)
[232]927             <<stringize(par.getFlagFDR())        <<std::endl;
[3]928  if(par.getFlagFDR()){                               
[232]929    theStream<<std::setw(widthText)<<"Alpha value for FDR analysis"         
930             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[alphaFDR]"
[172]931             <<"  =  " <<resetiosflags(std::ios::right)
[232]932             <<par.getAlpha()          <<std::endl;
[3]933  }                                                   
934  else {
[190]935    if(par.getFlagUserThreshold()){
[232]936      theStream<<std::setw(widthText)<<"Detection Threshold"                       
937               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshold]"
[189]938               <<"  =  " <<resetiosflags(std::ios::right)
[232]939               <<par.getThreshold()            <<std::endl;
[189]940    }
941    else{
[232]942      theStream<<std::setw(widthText)<<"SNR Threshold (in sigma)"
943               <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[snrCut]"
[189]944               <<"  =  " <<resetiosflags(std::ios::right)
[232]945               <<par.getCut()            <<std::endl;
[189]946    }
[3]947  }
[232]948  theStream  <<std::setw(widthText)<<"Using Adjacent-pixel criterion?"     
949             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagAdjacent]"
[172]950             <<"  =  " <<resetiosflags(std::ios::right)
[232]951             <<stringize(par.getFlagAdjacent())   <<std::endl;
[3]952  if(!par.getFlagAdjacent()){
[232]953    theStream<<std::setw(widthText)<<"Max. spatial separation for merging" 
954             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshSpatial]"
[172]955             <<"  =  " <<resetiosflags(std::ios::right)
[232]956             <<par.getThreshS()        <<std::endl;
[3]957  }
[232]958  theStream  <<std::setw(widthText)<<"Max. velocity separation for merging"
959             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshVelocity]"
[172]960             <<"  =  " <<resetiosflags(std::ios::right)
[232]961             <<par.getThreshV()        <<std::endl;
962  theStream  <<std::setw(widthText)<<"Method of spectral plotting"         
963             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectralMethod]"
[172]964             <<"  =  " <<resetiosflags(std::ios::right)
[232]965             <<par.getSpectralMethod() <<std::endl;
[265]966  theStream  <<std::setw(widthText)<<"Type of object centre used in results"
967             <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[pixelCentre]"
968             <<"  =  " <<resetiosflags(std::ios::right)
969             <<par.getPixelCentre() <<std::endl;
[219]970  theStream  <<"--------------------\n\n";
[103]971  theStream  << std::setfill(' ');
[3]972  theStream.unsetf(std::ios::left);
[110]973  //  theStream.unsetf(std::ios::boolalpha);
[3]974}
975
[120]976
[112]977void Param::copyHeaderInfo(FitsHeader &head)
978{
979  /**
980   * A function to copy across relevant header keywords from the
981   *  FitsHeader class to the Param class, as they are needed by
982   *  functions in the Param class.
[221]983   * The parameters are the keywords BLANK, BSCALE, BZERO, and the beam size.
[112]984   */
985
986  this->blankKeyword  = head.getBlankKeyword();
987  this->bscaleKeyword = head.getBscaleKeyword();
988  this->bzeroKeyword  = head.getBzeroKeyword();
[159]989  this->blankPixValue = this->blankKeyword * this->bscaleKeyword +
990    this->bzeroKeyword;
[112]991
992  this->numPixBeam    = head.getBeamSize();
993}
994
[232]995std::string Param::outputSmoothFile()
[208]996{
997  /**
[221]998   * This function produces the required filename in which to save
999   *  the Hanning-smoothed array. If the input image is image.fits, then
1000   *  the output will be eg. image.SMOOTH-3.fits, where the width of the
1001   *  Hanning filter was 3 pixels.
[208]1002   */
[232]1003  std::string inputName = this->imageFile;
[208]1004  std::stringstream ss;
1005  ss << inputName.substr(0,inputName.size()-5); 
1006                          // remove the ".fits" on the end.
1007  if(this->flagSubsection) ss<<".sub";
1008  ss << ".SMOOTH-" << this->hanningWidth
1009     << ".fits";
1010  return ss.str();
1011}
1012
[232]1013std::string Param::outputReconFile()
[103]1014{
1015  /**
[221]1016   * This function produces the required filename in which to save
1017   *  the reconstructed array. If the input image is image.fits, then
1018   *  the output will be eg. image.RECON-3-2-4-1.fits, where the numbers are
1019   *  3=reconDim, 2=filterCode, 4=snrRecon, 1=minScale
[103]1020   */
[232]1021  std::string inputName = this->imageFile;
[103]1022  std::stringstream ss;
1023  ss << inputName.substr(0,inputName.size()-5);  // remove the ".fits" on the end.
[106]1024  if(this->flagSubsection) ss<<".sub";
[103]1025  ss << ".RECON-" << this->reconDim
1026     << "-"       << this->filterCode
1027     << "-"       << this->snrRecon
1028     << "-"       << this->scaleMin
1029     << ".fits";
1030  return ss.str();
1031}
1032
[232]1033std::string Param::outputResidFile()
[103]1034{
1035  /**
[221]1036   * This function produces the required filename in which to save
1037   *  the reconstructed array. If the input image is image.fits, then
1038   *  the output will be eg. image.RESID-3-2-4-1.fits, where the numbers are
1039   *  3=reconDim, 2=filterCode, 4=snrRecon, 1=scaleMin
[103]1040   */
[232]1041  std::string inputName = this->imageFile;
[103]1042  std::stringstream ss;
1043  ss << inputName.substr(0,inputName.size()-5);  // remove the ".fits" on the end.
[106]1044  if(this->flagSubsection) ss<<".sub";
[103]1045  ss << ".RESID-" << this->reconDim
1046     << "-"       << this->filterCode
1047     << "-"       << this->snrRecon
1048     << "-"       << this->scaleMin
1049     << ".fits";
1050  return ss.str();
1051}
Note: See TracBrowser for help on using the repository browser.