source: tags/release-1.0.7/src/Cubes/baseline.cc @ 1455

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

Summary:

  • Fixed the scale bar plotting for the spectral output, so that it can deal properly with very fine angular scales.
    • Improved the loop in Cube::drawScale
    • Included code in angularSeparation to deal with finely-separated positions.
  • Moved the ProgressBar? class to a new header file Utils/feedback.hh from duchamp.hh
    • Updated #include statements in many files
  • Fixed allocation bug in param copy constructor (related to offsets array).
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   *  Cube::removeBaseline()
12   *   A front-end to the getBaseline routine, specialised for the
13   *   Cube data structure. Calls getBaseline on each spectrum individually.
14   *   Upon exit, the original array minus its spectral baseline is stored
15   *    in this->array and the baseline is in this->baseline.
16   *   If the reconstructed array exists, the baseline is subtracted from
17   *    it as well.
18   */
19
20  float *spec     = new float[this->axisDim[2]];
21  float *thisBaseline = new float[this->axisDim[2]];
22  int numSpec = this->axisDim[0]*this->axisDim[1];
23
24  ProgressBar bar;
25  if(this->par.isVerbose()) bar.init(numSpec);
26  for(int pix=0; pix<numSpec; pix++){ // for each spatial pixel...
27
28    if(this->par.isVerbose() ) bar.update(pix+1);
29
30    for(int z=0; z<this->axisDim[2]; z++) 
31      spec[z] = this->array[z*numSpec + pix];
32
33    getBaseline(this->axisDim[2], spec, thisBaseline, this->par);
34
35    for(int z=0; z<this->axisDim[2]; z++) {
36      this->baseline[z*numSpec+pix] = thisBaseline[z];
37      if(!par.isBlank(this->array[z*numSpec+pix])){
38        this->array[z*numSpec+pix] -= thisBaseline[z];
39        if(this->reconExists) this->recon[z*numSpec+pix] -= thisBaseline[z];
40      }     
41    }
42
43  } 
44
45  delete [] spec;
46  delete [] thisBaseline;
47 
48  if(this->par.isVerbose()) bar.remove();
49}
50
51
52
53void Cube::replaceBaseline()
54{
55  /**
56   *  Cube::replaceBaseline()
57   *   A routine to replace the baseline flux on the reconstructed array
58   *    (if it exists) and the fluxes of each of the detected objects (if any).
59   */
60
61  if(this->par.getFlagBaseline()){
62
63    for(int i=0;i<this->numPixels;i++){
64      if(!(this->par.isBlank(this->array[i])))
65        this->array[i] += this->baseline[i];
66    }
67
68    if(this->reconExists){
69      // if we made a reconstruction, we need to add the baseline back in
70      //   for plotting purposes
71      for(int i=0;i<this->numPixels;i++){
72        if(!(this->par.isBlank(this->array[i])))
73          this->recon[i] += this->baseline[i];
74      }
75    }
76 
77    int pos;
78    float flux;
79    // Now add the baseline to the flux for all the objects.
80    for(int obj=0;obj<this->objectList.size();obj++){ // for each detection
81      for(int vox=0;vox<this->objectList[obj].getSize();vox++){
82        // for each of its voxels
83
84        pos = this->objectList[obj].getX(vox) +
85          this->axisDim[0]*this->objectList[obj].getY(vox) +
86          this->axisDim[0]*this->axisDim[1]*this->objectList[obj].getZ(vox);
87
88        flux = this->objectList[obj].getF(vox) + this->baseline[pos];
89
90        this->objectList[obj].setF(vox, flux);
91
92      }
93      this->objectList[obj].calcParams();  // correct the flux calculations.
94
95    }
96 
97  }
98
99}
Note: See TracBrowser for help on using the repository browser.