source: tags/release-1.0.5/src/param.cc @ 1455

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

Fixed a minor bug from the previous commit.

File size: 27.5 KB
Line 
1#include <iostream>
2#include <iomanip>
3#include <fstream>
4#include <sstream>
5#include <string>
6#include <math.h>
7#include <wcs.h>
8#include <wcsunits.h>
9#include <param.hh>
10#include <config.h>
11#include <duchamp.hh>
12#include <Utils/utils.hh>
13
14// Define funtion to print bools as words, in case the compiler doesn't recognise
15// the setf(ios::boolalpha) command...
16#ifdef HAVE_STDBOOL_H
17string stringize(bool b){
18  std::stringstream ss;
19  ss.setf(std::ios::boolalpha);
20  ss << b;
21  return ss.str();
22}
23#else
24string stringize(bool b){
25  std::string output;
26  if(b) output="true";
27  else output="false";
28  return output;
29}
30#endif
31
32using std::setw;
33using std::endl;
34
35/****************************************************************/
36///////////////////////////////////////////////////
37//// Functions for FitsHeader class:
38///////////////////////////////////////////////////
39
40FitsHeader::FitsHeader(){
41  this->wcs = new wcsprm;
42  this->wcs->flag=-1;
43  wcsini(true,3,this->wcs);
44  this->wcsIsGood = false;
45  this->nwcs = 0;
46  this->scale=1.;
47  this->offset=0.;
48  this->power=1.;
49  this->fluxUnits="counts";
50}
51
52FitsHeader::FitsHeader(const FitsHeader& h){
53  this->wcs = new wcsprm;
54  this->wcs->flag=-1;
55  wcsini(true,h.wcs->naxis,this->wcs);
56  wcscopy(true,h.wcs,this->wcs);
57  wcsset(this->wcs);
58  this->nwcs = h.nwcs;
59  this->wcsIsGood = h.wcsIsGood;
60  this->spectralUnits = h.spectralUnits;
61  this->fluxUnits = h.fluxUnits;
62  this->intFluxUnits = h.intFluxUnits;
63  this->beamSize = h.beamSize;
64  this->bmajKeyword = h.bmajKeyword;
65  this->bminKeyword = h.bminKeyword;
66  this->blankKeyword = h.blankKeyword;
67  this->bzeroKeyword = h.bzeroKeyword;
68  this->bscaleKeyword = h.bscaleKeyword;
69  this->scale = h.scale;
70  this->offset = h.offset;
71  this->power = h.power;
72}
73
74FitsHeader& FitsHeader::operator= (const FitsHeader& h){
75  this->wcs = new wcsprm;
76  this->wcs->flag=-1;
77  wcsini(true,h.wcs->naxis,this->wcs);
78  wcscopy(true,h.wcs,this->wcs);
79  wcsset(this->wcs);
80  this->nwcs = h.nwcs;
81  this->wcsIsGood = h.wcsIsGood;
82  this->spectralUnits = h.spectralUnits;
83  this->fluxUnits = h.fluxUnits;
84  this->intFluxUnits = h.intFluxUnits;
85  this->beamSize = h.beamSize;
86  this->bmajKeyword = h.bmajKeyword;
87  this->bminKeyword = h.bminKeyword;
88  this->blankKeyword = h.blankKeyword;
89  this->bzeroKeyword = h.bzeroKeyword;
90  this->bscaleKeyword = h.bscaleKeyword;
91  this->scale = h.scale;
92  this->offset = h.offset;
93  this->power = h.power;
94}
95
96void FitsHeader::setWCS(wcsprm *w)
97{
98  /**
99   * FitsHeader::setWCS(wcsprm *)
100   *  A function that assigns the wcs parameters, and runs
101   *   wcsset to set it up correctly.
102   *  Performs a check to see if the WCS is good (by looking at
103   *   the lng and lat wcsprm parameters), and sets the wcsIsGood
104   *   flag accordingly.
105   */
106  wcscopy(true,w,this->wcs);
107  wcsset(this->wcs);
108  if( (w->lng!=-1) && (w->lat!=-1) ) this->wcsIsGood = true;
109}
110
111wcsprm *FitsHeader::getWCS()
112{
113  /**
114   * FitsHeader::getWCS()
115   *  A function that returns a wcsprm object corresponding to the WCS.
116   */
117  wcsprm *wNew = new wcsprm;
118  wNew->flag=-1;
119  wcsini(true,this->wcs->naxis,wNew);
120  wcscopy(true,this->wcs,wNew);
121  wcsset(wNew);
122  return wNew;
123}
124
125int     FitsHeader::wcsToPix(const double *world, double *pix){
126  return wcsToPixSingle(this->wcs,world,pix);}
127int     FitsHeader::wcsToPix(const double *world, double *pix, const int npts){
128  return wcsToPixMulti(this->wcs,world,pix,npts);}
129int     FitsHeader::pixToWCS(const double *pix, double *world){
130  return pixToWCSSingle(this->wcs,pix,world);}
131int     FitsHeader::pixToWCS(const double *pix, double *world, const int npts){
132  return pixToWCSMulti(this->wcs,pix,world,npts);}
133
134double  FitsHeader::pixToVel(double &x, double &y, double &z)
135{
136  double vel;
137  if(this->wcsIsGood){
138    double *pix   = new double[3];
139    double *world = new double[3];
140    pix[0] = x; pix[1] = y; pix[2] = z;
141    pixToWCSSingle(this->wcs,pix,world);
142    vel = this->specToVel(world[2]);
143    delete [] pix;
144    delete [] world;
145  }
146  else vel = z;
147  return vel;
148}
149
150double* FitsHeader::pixToVel(double &x, double &y, double *zarray, int size)
151{
152  double *newzarray = new double[size];
153  if(this->wcsIsGood){
154    double *pix   = new double[size*3];
155    for(int i=0;i<size;i++){
156      pix[3*i] = x; pix[3*i+1] = y; pix[3*i+2] = zarray[i];
157    }
158    double *world = new double[size*3];
159    pixToWCSMulti(this->wcs,pix,world,size);
160    delete [] pix;
161    for(int i=0;i<size;i++) newzarray[i] = this->specToVel(world[3*i+2]);
162    delete [] world;
163  }
164  else{
165    for(int i=0;i<size;i++) newzarray[i] = zarray[i];
166  }
167  return newzarray;
168}
169
170double  FitsHeader::specToVel(const double &coord)
171{
172  double vel;
173  if(power==1.0) vel =  coord*this->scale + this->offset;
174  else vel = pow( (coord*this->scale + this->offset), this->power);
175  return vel;
176}
177
178double  FitsHeader::velToSpec(const float &velocity)
179{
180//   return velToCoord(this->wcs,velocity,this->spectralUnits);};
181  return (pow(velocity, 1./this->power) - this->offset) / this->scale;}
182
183string  FitsHeader::getIAUName(double ra, double dec)
184{
185  if(strcmp(this->wcs->lngtyp,"RA")==0) return getIAUNameEQ(ra, dec, this->wcs->equinox);
186  else return getIAUNameGAL(ra, dec);
187}
188
189void FitsHeader::fixUnits(Param &par)
190{
191  // define spectral units from the param set
192  this->spectralUnits = par.getSpectralUnits();
193
194  double sc=1.;
195  double of=0.;
196  double po=1.;;
197  if(this->wcsIsGood){
198    int flag = wcsunits( this->wcs->cunit[wcs->spec],
199                         this->spectralUnits.c_str(),
200                         &sc, &of, &po);
201    if(flag>0){
202      std::stringstream errmsg;
203      errmsg << "WCSUNITS Error, Code = " << flag
204             << ": "<< wcsunits_errmsg[flag];
205      if(flag==10) errmsg << "\nTried to get conversion from '"
206                          << wcs->cunit[wcs->spec] << "' to '"
207                          << this->spectralUnits.c_str() << "'\n";
208      this->spectralUnits = this->wcs->cunit[wcs->spec];
209      if(this->spectralUnits==""){
210        errmsg << "Setting coordinates to 'XX' for clarity.\n";
211        this->spectralUnits = "XX";
212      }
213      duchampError("fixUnits", errmsg.str());
214     
215    }
216  }
217  this->scale = sc;
218  this->offset= of;
219  this->power = po;
220
221  // Work out the integrated flux units, based on the spectral units.
222  // If flux is per beam, trim the /beam from the flux units and multiply
223  //  by the spectral units.
224  // Otherwise, just muliply by the spectral units.
225  if(this->fluxUnits.size()>0){
226    if(this->fluxUnits.substr(this->fluxUnits.size()-5,
227                              this->fluxUnits.size()   ) == "/beam"){
228      this->intFluxUnits = this->fluxUnits.substr(0,this->fluxUnits.size()-5)
229        +" " +this->spectralUnits;
230    }
231    else this->intFluxUnits = this->fluxUnits + " " + this->spectralUnits;
232  }
233
234}
235
236/****************************************************************/
237///////////////////////////////////////////////////
238//// Accessor Functions for Parameter class:
239///////////////////////////////////////////////////
240Param::Param(){
241  /**
242   * Param()
243   *  Default intial values for the parameters.
244   * imageFile has no default value!
245   */
246  // Input files
247  this->imageFile       = "";
248  this->flagSubsection  = false;
249  this->subsection      = "[*,*,*]";
250  this->flagReconExists = false;
251  this->reconFile       = "";
252  // Output files
253  this->flagLog         = true;
254  this->logFile         = "duchamp-Logfile.txt";
255  this->outFile         = "duchamp-Results.txt";
256  this->spectraFile     = "duchamp-Spectra.ps";
257  this->flagOutputRecon = false;
258  this->flagOutputResid = false;
259  this->flagVOT         = false;
260  this->votFile         = "duchamp-Results.xml";
261  this->flagKarma       = false;
262  this->karmaFile       = "duchamp-Results.ann";
263  this->flagMaps        = true;
264  this->detectionMap    = "duchamp-DetectionMap.ps";
265  this->momentMap       = "duchamp-MomentMap.ps";
266  // Cube related parameters
267  this->flagBlankPix    = true;
268  this->blankPixValue   = -8.00061;
269  this->blankKeyword    = 1;
270  this->bscaleKeyword   = -8.00061;
271  this->bzeroKeyword    = 0.;
272  this->flagUsingBlank  = false;
273  this->flagMW          = false;
274  this->maxMW           = 112;
275  this->minMW           = 75;
276  this->numPixBeam      = 10.;
277  this->flagUsingBeam   = false;
278  // Trim-related         
279  this->flagTrimmed     = false;
280  this->borderLeft      = 0;
281  this->borderRight     = 0;
282  this->borderBottom    = 0;
283  this->borderTop       = 0;
284  // Subsection offsets
285  this->xSubOffset      = 0;
286  this->ySubOffset      = 0;
287  this->zSubOffset      = 0;
288  // Baseline related
289  this->flagBaseline    = false;
290  // Detection-related   
291  this->flagNegative    = false;
292  // Object growth       
293  this->flagGrowth      = false;
294  this->growthCut       = 2.;
295  // FDR analysis         
296  this->flagFDR         = false;
297  this->alphaFDR        = 0.01;
298  // Other detection     
299  this->snrCut          = 3.;
300  // A trous reconstruction parameters
301  this->flagATrous      = true;
302  this->reconDim        = 3;
303  this->scaleMin        = 1;
304  this->snrRecon        = 4.;
305  this->filterCode      = 1;
306  // Volume-merging parameters
307  this->flagAdjacent    = true;
308  this->threshSpatial   = 3.;
309  this->threshVelocity  = 7.;
310  this->minChannels     = 3;
311  this->minPix          = 2;
312  // Input-Output related
313  this->spectralMethod  = "peak";
314  this->borders         = true;
315  this->blankEdge       = true;
316  this->verbose         = true;
317  this->spectralUnits   = "km/s";
318};
319
320Param& Param::operator= (const Param& p)
321{
322  this->imageFile       = p.imageFile;
323  this->flagSubsection  = p.flagSubsection;
324  this->subsection      = p.subsection;     
325  this->flagReconExists = p.flagReconExists;
326  this->reconFile       = p.reconFile;     
327  this->flagLog         = p.flagLog;       
328  this->logFile         = p.logFile;       
329  this->outFile         = p.outFile;       
330  this->spectraFile     = p.spectraFile;   
331  this->flagOutputRecon = p.flagOutputRecon;
332  this->flagOutputResid = p.flagOutputResid;
333  this->flagVOT         = p.flagVOT;         
334  this->votFile         = p.votFile;       
335  this->flagKarma       = p.flagKarma;     
336  this->karmaFile       = p.karmaFile;     
337  this->flagMaps        = p.flagMaps;       
338  this->detectionMap    = p.detectionMap;   
339  this->momentMap       = p.momentMap;     
340  this->flagBlankPix    = p.flagBlankPix;   
341  this->blankPixValue   = p.blankPixValue; 
342  this->blankKeyword    = p.blankKeyword;   
343  this->bscaleKeyword   = p.bscaleKeyword; 
344  this->bzeroKeyword    = p.bzeroKeyword;   
345  this->flagUsingBlank  = p.flagUsingBlank;
346  this->flagMW          = p.flagMW;         
347  this->maxMW           = p.maxMW;         
348  this->minMW           = p.minMW;         
349  this->numPixBeam      = p.numPixBeam;     
350  this->flagTrimmed     = p.flagTrimmed;   
351  this->borderLeft      = p.borderLeft;     
352  this->borderRight     = p.borderRight;   
353  this->borderBottom    = p.borderBottom;   
354  this->borderTop       = p.borderTop;     
355  this->xSubOffset      = p.xSubOffset;     
356  this->ySubOffset      = p.ySubOffset;     
357  this->zSubOffset      = p.zSubOffset;
358  this->flagBaseline    = p.flagBaseline;
359  this->flagNegative    = p.flagNegative;
360  this->flagGrowth      = p.flagGrowth;
361  this->growthCut       = p.growthCut;
362  this->flagFDR         = p.flagFDR;
363  this->alphaFDR        = p.alphaFDR;
364  this->snrCut          = p.snrCut;
365  this->flagATrous      = p.flagATrous;
366  this->reconDim        = p.reconDim;
367  this->scaleMin        = p.scaleMin;
368  this->snrRecon        = p.snrRecon;
369  this->filterCode      = p.filterCode;
370  this->flagAdjacent    = p.flagAdjacent;
371  this->threshSpatial   = p.threshSpatial;
372  this->threshVelocity  = p.threshVelocity;
373  this->minChannels     = p.minChannels;
374  this->minPix          = p.minPix;
375  this->spectralMethod  = p.spectralMethod;
376  this->borders         = p.borders;
377  this->verbose         = p.verbose;
378  this->spectralUnits   = p.spectralUnits;
379}
380
381/****************************************************************/
382///////////////////////////////////////////////////
383//// Other Functions using the  Parameter class:
384///////////////////////////////////////////////////
385
386inline string makelower( string s )
387{
388  // "borrowed" from Matt Howlett's 'fred'
389  string out = "";
390  for( int i=0; i<s.size(); ++i ) {
391    out += tolower(s[i]);
392  }
393  return out;
394}
395
396inline bool boolify( string s )
397{
398  /**
399   * bool boolify(string)
400   *  Convert a string to a bool variable
401   *  "1" and "true" get converted to true
402   *  "0" and "false" (and anything else) get converted to false
403   */
404  if((s=="1") || (makelower(s)=="true")) return true;
405  else if((s=="0") || (makelower(s)=="false")) return false;
406  else return false;
407}
408
409inline string readSval(std::stringstream& ss)
410{
411  string val; ss >> val; return val;
412}
413
414inline bool readFlag(std::stringstream& ss)
415{
416  string val; ss >> val; return boolify(val);
417}
418
419inline float readFval(std::stringstream& ss)
420{
421  float val; ss >> val; return val;
422}
423
424inline int readIval(std::stringstream& ss)
425{
426  int val; ss >> val; return val;
427}
428
429int Param::readParams(string paramfile)
430{
431
432  std::ifstream fin(paramfile.c_str());
433  if(!fin.is_open()) return FAILURE;
434  string line;
435  while( !std::getline(fin,line,'\n').eof()){
436
437    if(line[0]!='#'){
438      std::stringstream ss;
439      ss.str(line);
440      string arg;
441      ss >> arg;
442      arg = makelower(arg);
443      if(arg=="imagefile")       this->imageFile = readSval(ss);
444      if(arg=="flagsubsection")  this->flagSubsection = readFlag(ss);
445      if(arg=="subsection")      this->subsection = readSval(ss);
446      if(arg=="flagreconexists") this->flagReconExists = readFlag(ss);
447      if(arg=="reconfile")       this->reconFile = readSval(ss);
448
449      if(arg=="flaglog")         this->flagLog = readFlag(ss);
450      if(arg=="logfile")         this->logFile = readSval(ss);
451      if(arg=="outfile")         this->outFile = readSval(ss);
452      if(arg=="spectrafile")     this->spectraFile = readSval(ss);
453      if(arg=="flagoutputrecon") this->flagOutputRecon = readFlag(ss);
454      if(arg=="flagoutputresid") this->flagOutputResid = readFlag(ss);
455      if(arg=="flagvot")         this->flagVOT = readFlag(ss);
456      if(arg=="votfile")         this->votFile = readSval(ss);
457      if(arg=="flagkarma")       this->flagKarma = readFlag(ss);
458      if(arg=="karmafile")       this->karmaFile = readSval(ss);
459      if(arg=="flagmaps")        this->flagMaps = readFlag(ss);
460      if(arg=="detectionmap")    this->detectionMap = readSval(ss);
461      if(arg=="momentmap")       this->momentMap = readSval(ss);
462
463      if(arg=="flagnegative")    this->flagNegative = readFlag(ss);
464      if(arg=="flagblankpix")    this->flagBlankPix = readFlag(ss);
465      if(arg=="blankpixvalue")   this->blankPixValue = readFval(ss);
466      if(arg=="flagmw")          this->flagMW = readFlag(ss);
467      if(arg=="maxmw")           this->maxMW = readIval(ss);
468      if(arg=="minmw")           this->minMW = readIval(ss);
469      if(arg=="beamsize")        this->numPixBeam = readFval(ss);
470
471      if(arg=="flagbaseline")    this->flagBaseline = readFlag(ss);
472      if(arg=="minpix")          this->minPix = readIval(ss);
473      if(arg=="flaggrowth")      this->flagGrowth = readFlag(ss);
474      if(arg=="growthcut")       this->growthCut = readFval(ss);
475
476      if(arg=="flagfdr")         this->flagFDR = readFlag(ss);
477      if(arg=="alphafdr")        this->alphaFDR = readFval(ss);
478
479      if(arg=="snrcut")          this->snrCut = readFval(ss);
480
481      if(arg=="flagatrous")      this->flagATrous = readFlag(ss);
482      if(arg=="recondim")        this->reconDim = readIval(ss);
483      if(arg=="scalemin")        this->scaleMin = readIval(ss);
484      if(arg=="snrrecon")        this->snrRecon = readFval(ss);
485      if(arg=="filtercode")      this->filterCode = readIval(ss);
486
487      if(arg=="flagadjacent")    this->flagAdjacent = readFlag(ss);
488      if(arg=="threshspatial")   this->threshSpatial = readFval(ss);
489      if(arg=="threshvelocity")  this->threshVelocity = readFval(ss);
490      if(arg=="minchannels")     this->minChannels = readIval(ss);
491
492      if(arg=="spectralmethod")  this->spectralMethod=makelower(readSval(ss));
493      if(arg=="spectralunits")   this->spectralUnits=makelower(readSval(ss));
494      if(arg=="drawborders")     this->borders = readFlag(ss);
495      if(arg=="drawblankedges")  this->blankEdge = readFlag(ss);
496      if(arg=="verbose")         this->verbose = readFlag(ss);
497    }
498  }
499  return SUCCESS;
500}
501
502
503std::ostream& operator<< ( std::ostream& theStream, Param& par)
504{
505  // Only show the [blankPixValue] bit if we are using the parameter
506  // otherwise we have read it from the FITS header.
507  string blankParam = "";
508  if(par.getFlagUsingBlank()) blankParam = "[blankPixValue]";
509  string beamParam = "";
510  if(par.getFlagUsingBeam()) beamParam = "[beamSize]";
511
512  // BUG -- can get error: `boolalpha' is not a member of type `ios' -- old compilers: gcc 2.95.3?
513  //   theStream.setf(std::ios::boolalpha);
514  theStream.setf(std::ios::left);
515  theStream  <<"---- Parameters ----"<<endl;
516  theStream  << std::setfill('.');
517  if(par.getFlagSubsection())
518    theStream<<setw(38)<<"Image to be analysed"                 
519             <<setw(18)<<setiosflags(std::ios::right)  <<"[imageFile]"
520             <<"  =  " <<resetiosflags(std::ios::right)
521             <<(par.getImageFile()+par.getSubsection()) <<endl;
522  else
523    theStream<<setw(38)<<"Image to be analysed"                 
524             <<setw(18)<<setiosflags(std::ios::right)  <<"[imageFile]"
525             <<"  =  " <<resetiosflags(std::ios::right)
526             <<par.getImageFile()      <<endl;
527  if(par.getFlagReconExists() && par.getFlagATrous()){
528    theStream<<setw(38)<<"Reconstructed array exists?"         
529             <<setw(18)<<setiosflags(std::ios::right)  <<"[reconExists]"
530             <<"  =  " <<resetiosflags(std::ios::right)
531             <<stringize(par.getFlagReconExists())<<endl;
532    theStream<<setw(38)<<"FITS file containing reconstruction" 
533             <<setw(18)<<setiosflags(std::ios::right)  <<"[reconFile]"
534             <<"  =  " <<resetiosflags(std::ios::right)
535             <<par.getReconFile()      <<endl;
536  }
537  theStream  <<setw(38)<<"Intermediate Logfile"
538             <<setw(18)<<setiosflags(std::ios::right)  <<"[logFile]"
539             <<"  =  " <<resetiosflags(std::ios::right)
540             <<par.getLogFile()        <<endl;
541  theStream  <<setw(38)<<"Final Results file"                   
542             <<setw(18)<<setiosflags(std::ios::right)  <<"[outFile]"
543             <<"  =  " <<resetiosflags(std::ios::right)
544             <<par.getOutFile()        <<endl;
545  theStream  <<setw(38)<<"Spectrum file"                       
546             <<setw(18)<<setiosflags(std::ios::right)  <<"[spectraFile]"
547             <<"  =  " <<resetiosflags(std::ios::right)
548             <<par.getSpectraFile()    <<endl;
549  if(par.getFlagVOT()){
550    theStream<<setw(38)<<"VOTable file"                         
551             <<setw(18)<<setiosflags(std::ios::right)  <<"[votFile]"
552             <<"  =  " <<resetiosflags(std::ios::right)
553             <<par.getVOTFile()        <<endl;
554  }
555  if(par.getFlagKarma()){
556    theStream<<setw(38)<<"Karma annotation file"               
557             <<setw(18)<<setiosflags(std::ios::right)  <<"[karmaFile]"
558             <<"  =  " <<resetiosflags(std::ios::right)
559             
560             <<par.getKarmaFile()      <<endl;
561  }
562  if(par.getFlagMaps()){
563    theStream<<setw(38)<<"0th Moment Map"                       
564             <<setw(18)<<setiosflags(std::ios::right)  <<"[momentMap]"
565             <<"  =  " <<resetiosflags(std::ios::right)
566             <<par.getMomentMap()      <<endl;
567    theStream<<setw(38)<<"Detection Map"                       
568             <<setw(18)<<setiosflags(std::ios::right)  <<"[detectionMap]"
569             <<"  =  " <<resetiosflags(std::ios::right)
570             <<par.getDetectionMap()   <<endl;
571  }
572  if(par.getFlagATrous()){                             
573    theStream<<setw(38)<<"Saving reconstructed cube?"           
574             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagoutputrecon]"
575             <<"  =  " <<resetiosflags(std::ios::right)
576             <<stringize(par.getFlagOutputRecon())<<endl;
577    theStream<<setw(38)<<"Saving residuals from reconstruction?"
578             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagoutputresid]"
579             <<"  =  " <<resetiosflags(std::ios::right)
580             <<stringize(par.getFlagOutputResid())<<endl;
581  }                                                   
582  theStream  <<"------"<<endl;
583  theStream  <<setw(38)<<"Searching for Negative features?"     
584             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagNegative]"
585             <<"  =  " <<resetiosflags(std::ios::right)
586             <<stringize(par.getFlagNegative())   <<endl;
587  theStream  <<setw(38)<<"Fixing Blank Pixels?"                 
588             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagBlankPix]"
589             <<"  =  " <<resetiosflags(std::ios::right)
590             <<stringize(par.getFlagBlankPix())   <<endl;
591  if(par.getFlagBlankPix()){
592    theStream<<setw(38)<<"Blank Pixel Value"                   
593             <<setw(18)<<setiosflags(std::ios::right)  << blankParam
594             <<"  =  " <<resetiosflags(std::ios::right)
595             <<par.getBlankPixVal()    <<endl;
596  }
597  theStream  <<setw(38)<<"Removing Milky Way channels?"         
598             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagMW]"
599             <<"  =  " <<resetiosflags(std::ios::right)
600             <<stringize(par.getFlagMW())         <<endl;
601  if(par.getFlagMW()){
602    theStream<<setw(38)<<"Milky Way Channels"                   
603             <<setw(18)<<setiosflags(std::ios::right)  <<"[minMW - maxMW]"
604             <<"  =  " <<resetiosflags(std::ios::right)
605             <<par.getMinMW()
606             <<"-" <<par.getMaxMW()          <<endl;
607  }
608  theStream  <<setw(38)<<"Beam Size (pixels)"                   
609             <<setw(18)<<setiosflags(std::ios::right)  << beamParam
610             <<"  =  " <<resetiosflags(std::ios::right)
611             <<par.getBeamSize()       <<endl;
612  theStream  <<setw(38)<<"Removing baselines before search?"   
613             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagBaseline]"
614             <<"  =  " <<resetiosflags(std::ios::right)
615             <<stringize(par.getFlagBaseline())   <<endl;
616  theStream  <<setw(38)<<"Minimum # Pixels in a detection"     
617             <<setw(18)<<setiosflags(std::ios::right)  <<"[minPix]"
618             <<"  =  " <<resetiosflags(std::ios::right)
619             <<par.getMinPix()         <<endl;
620  theStream  <<setw(38)<<"Minimum # Channels in a detection"   
621             <<setw(18)<<setiosflags(std::ios::right)  <<"[minChannels]"
622             <<"  =  " <<resetiosflags(std::ios::right)
623             <<par.getMinChannels()    <<endl;
624  theStream  <<setw(38)<<"Growing objects after detection?"     
625             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagGrowth]"
626             <<"  =  " <<resetiosflags(std::ios::right)
627             <<stringize(par.getFlagGrowth())     <<endl;
628  if(par.getFlagGrowth()) {                           
629    theStream<<setw(38)<<"SNR Threshold for growth"             
630             <<setw(18)<<setiosflags(std::ios::right)  <<"[growthCut]"
631             <<"  =  " <<resetiosflags(std::ios::right)
632             <<par.getGrowthCut()      <<endl;
633  }
634  theStream  <<setw(38)<<"Using A Trous reconstruction?"       
635             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagATrous]"
636             <<"  =  " <<resetiosflags(std::ios::right)
637             <<stringize(par.getFlagATrous())     <<endl;
638  if(par.getFlagATrous()){                             
639    theStream<<setw(38)<<"Number of dimensions in reconstruction"     
640             <<setw(18)<<setiosflags(std::ios::right)  <<"[reconDim]"
641             <<"  =  " <<resetiosflags(std::ios::right)
642             <<par.getReconDim()       <<endl;
643    theStream<<setw(38)<<"Minimum scale in reconstruction"     
644             <<setw(18)<<setiosflags(std::ios::right)  <<"[scaleMin]"
645             <<"  =  " <<resetiosflags(std::ios::right)
646             <<par.getMinScale()       <<endl;
647    theStream<<setw(38)<<"SNR Threshold within reconstruction" 
648             <<setw(18)<<setiosflags(std::ios::right)  <<"[snrRecon]"
649             <<"  =  " <<resetiosflags(std::ios::right)
650             <<par.getAtrousCut()      <<endl;
651    theStream<<setw(38)<<"Filter being used for reconstruction"
652             <<setw(18)<<setiosflags(std::ios::right)  <<"[filterCode]"
653             <<"  =  " <<resetiosflags(std::ios::right)
654             <<par.getFilterCode()
655             << " (" << par.getFilterName()  << ")" <<endl;
656  }                                                   
657  theStream  <<setw(38)<<"Using FDR analysis?"                 
658             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagFDR]"
659             <<"  =  " <<resetiosflags(std::ios::right)
660             <<stringize(par.getFlagFDR())        <<endl;
661  if(par.getFlagFDR()){                               
662    theStream<<setw(38)<<"Alpha value for FDR analysis"         
663             <<setw(18)<<setiosflags(std::ios::right)  <<"[alphaFDR]"
664             <<"  =  " <<resetiosflags(std::ios::right)
665             <<par.getAlpha()          <<endl;
666  }                                                   
667  else {
668    theStream<<setw(38)<<"SNR Threshold"                       
669             <<setw(18)<<setiosflags(std::ios::right)  <<"[snrCut]"
670             <<"  =  " <<resetiosflags(std::ios::right)
671             <<par.getCut()            <<endl;
672  }
673  theStream  <<setw(38)<<"Using Adjacent-pixel criterion?"     
674             <<setw(18)<<setiosflags(std::ios::right)  <<"[flagAdjacent]"
675             <<"  =  " <<resetiosflags(std::ios::right)
676             <<stringize(par.getFlagAdjacent())   <<endl;
677  if(!par.getFlagAdjacent()){
678    theStream<<setw(38)<<"Max. spatial separation for merging" 
679             <<setw(18)<<setiosflags(std::ios::right)  <<"[threshSpatial]"
680             <<"  =  " <<resetiosflags(std::ios::right)
681             <<par.getThreshS()        <<endl;
682  }
683  theStream  <<setw(38)<<"Max. velocity separation for merging"
684             <<setw(18)<<setiosflags(std::ios::right)  <<"[threshVelocity]"
685             <<"  =  " <<resetiosflags(std::ios::right)
686             <<par.getThreshV()        <<endl;
687  theStream  <<setw(38)<<"Method of spectral plotting"         
688             <<setw(18)<<setiosflags(std::ios::right)  <<"[spectralMethod]"
689             <<"  =  " <<resetiosflags(std::ios::right)
690             <<par.getSpectralMethod() <<endl;
691  theStream  <<"--------------------"<<endl;
692  theStream  << std::setfill(' ');
693  theStream.unsetf(std::ios::left);
694  //  theStream.unsetf(std::ios::boolalpha);
695}
696
697
698void Param::copyHeaderInfo(FitsHeader &head)
699{
700  /**
701   *  Param::copyHeaderInfo(FitsHeader &head)
702   * A function to copy across relevant header keywords from the
703   *  FitsHeader class to the Param class, as they are needed by
704   *  functions in the Param class.
705   */
706
707  this->blankKeyword  = head.getBlankKeyword();
708  this->bscaleKeyword = head.getBscaleKeyword();
709  this->bzeroKeyword  = head.getBzeroKeyword();
710  this->blankPixValue = this->blankKeyword * this->bscaleKeyword +
711    this->bzeroKeyword;
712
713  this->numPixBeam    = head.getBeamSize();
714}
715
716bool Param::isBlank(float &value)
717{
718  /**
719   *  Param::isBlank(float)
720   *   Tests whether the value passed as the argument is BLANK or not.
721   *   If flagBlankPix is false, return false.
722   *   Otherwise, compare to the relevant FITS keywords, using integer
723   *     comparison.
724   *   Return a bool.
725   */
726
727  return this->flagBlankPix &&
728    (this->blankKeyword == int((value-this->bzeroKeyword)/this->bscaleKeyword));
729}
730
731string Param::outputReconFile()
732{
733  /**
734   *  outputReconFile()
735   *
736   *   This function produces the required filename in which to save
737   *    the reconstructed array. If the input image is image.fits, then
738   *    the output will be eg. image.RECON-3-2-4-1.fits, where the numbers are
739   *    3=reconDim, 2=filterCode, 4=snrRecon, 1=minScale
740   */
741  string inputName = this->imageFile;
742  std::stringstream ss;
743  ss << inputName.substr(0,inputName.size()-5);  // remove the ".fits" on the end.
744  if(this->flagSubsection) ss<<".sub";
745  ss << ".RECON-" << this->reconDim
746     << "-"       << this->filterCode
747     << "-"       << this->snrRecon
748     << "-"       << this->scaleMin
749     << ".fits";
750  return ss.str();
751}
752
753string Param::outputResidFile()
754{
755  /**
756   *  outputResidFile()
757   *
758   *   This function produces the required filename in which to save
759   *    the reconstructed array. If the input image is image.fits, then
760   *    the output will be eg. image.RESID-3-2-4-1.fits, where the numbers are
761   *    3=reconDim, 2=filterCode, 4=snrRecon, 1=scaleMin
762   */
763  string inputName = this->imageFile;
764  std::stringstream ss;
765  ss << inputName.substr(0,inputName.size()-5);  // remove the ".fits" on the end.
766  if(this->flagSubsection) ss<<".sub";
767  ss << ".RESID-" << this->reconDim
768     << "-"       << this->filterCode
769     << "-"       << this->snrRecon
770     << "-"       << this->scaleMin
771     << ".fits";
772  return ss.str();
773}
Note: See TracBrowser for help on using the repository browser.