source: trunk/src/Cubes/baseline.cc @ 221

Last change on this file since 221 was 220, checked in by Matthew Whiting, 17 years ago
  • Two new files: plots.cc and feedback.cc. Introduced to separate the declarations and definitions for various classes.
  • Mostly just improving the documentation for use with Doxygen.
File size: 2.7 KB
Line 
1#include <iostream>
2#include <iomanip>
3#include <param.hh>
4#include <ATrous/atrous.hh>
5#include <Cubes/cubes.hh>
6#include <Utils/feedback.hh>
7
8void Cube::removeBaseline()
9{
10  /**
11   *  A front-end to the getBaseline routine, specialised for the
12   *  Cube data structure. Calls getBaseline on each spectrum individually.
13   *  Upon exit, the original array minus its spectral baseline is stored
14   *   in this->array and the baseline is in this->baseline.
15   *  If the reconstructed array exists, the baseline is subtracted from
16   *   it as well.
17   */
18
19  float *spec     = new float[this->axisDim[2]];
20  float *thisBaseline = new float[this->axisDim[2]];
21  int numSpec = this->axisDim[0]*this->axisDim[1];
22
23  ProgressBar bar;
24  if(this->par.isVerbose()) bar.init(numSpec);
25  for(int pix=0; pix<numSpec; pix++){ // for each spatial pixel...
26
27    if(this->par.isVerbose() ) bar.update(pix+1);
28
29    for(int z=0; z<this->axisDim[2]; z++) 
30      spec[z] = this->array[z*numSpec + pix];
31
32    getBaseline(this->axisDim[2], spec, thisBaseline, this->par);
33
34    for(int z=0; z<this->axisDim[2]; z++) {
35      this->baseline[z*numSpec+pix] = thisBaseline[z];
36      if(!par.isBlank(this->array[z*numSpec+pix])){
37        this->array[z*numSpec+pix] -= thisBaseline[z];
38        if(this->reconExists) this->recon[z*numSpec+pix] -= thisBaseline[z];
39      }     
40    }
41
42  } 
43
44  delete [] spec;
45  delete [] thisBaseline;
46 
47  if(this->par.isVerbose()) bar.remove();
48}
49
50
51
52void Cube::replaceBaseline()
53{
54  /**
55   *  A routine to replace the baseline flux on the reconstructed array
56   *   (if it exists) and the fluxes of each of the detected objects (if any).
57   */
58
59  if(this->par.getFlagBaseline()){
60
61    for(int i=0;i<this->numPixels;i++){
62      if(!(this->par.isBlank(this->array[i])))
63        this->array[i] += this->baseline[i];
64    }
65
66    if(this->reconExists){
67      // if we made a reconstruction, we need to add the baseline back in
68      //   for plotting purposes
69      for(int i=0;i<this->numPixels;i++){
70        if(!(this->par.isBlank(this->array[i])))
71          this->recon[i] += this->baseline[i];
72      }
73    }
74 
75    int pos;
76    float flux;
77    // Now add the baseline to the flux for all the objects.
78    for(int obj=0;obj<this->objectList.size();obj++){ // for each detection
79      for(int vox=0;vox<this->objectList[obj].getSize();vox++){
80        // for each of its voxels
81
82        pos = this->objectList[obj].getX(vox) +
83          this->axisDim[0]*this->objectList[obj].getY(vox) +
84          this->axisDim[0]*this->axisDim[1]*this->objectList[obj].getZ(vox);
85
86        flux = this->objectList[obj].getF(vox) + this->baseline[pos];
87
88        this->objectList[obj].setF(vox, flux);
89
90      }
91      this->objectList[obj].calcParams();  // correct the flux calculations.
92
93    }
94 
95  }
96
97}
Note: See TracBrowser for help on using the repository browser.