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

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