1 | #include <iostream> |
---|
2 | #include <iomanip> |
---|
3 | #include <ATrous/atrous.hh> |
---|
4 | #include <Cubes/cubes.hh> |
---|
5 | #include <param.hh> |
---|
6 | |
---|
7 | void Cube::removeBaseline() |
---|
8 | { |
---|
9 | /** |
---|
10 | * Cube::removeBaseline() |
---|
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 | * If the reconstructed array exists, the baseline is subtracted from it as well. |
---|
15 | * in this->array and the baseline is in this->baseline. |
---|
16 | */ |
---|
17 | |
---|
18 | float *spec = new float[this->axisDim[2]]; |
---|
19 | float *thisBaseline = new float[this->axisDim[2]]; |
---|
20 | int numSpec = this->axisDim[0]*this->axisDim[1]; |
---|
21 | |
---|
22 | std::cout << "| |" << std::flush; |
---|
23 | for(int pix=0; pix<numSpec; pix++){ // for each spatial pixel... |
---|
24 | |
---|
25 | if(this->par.isVerbose() && ((100*(pix+1)/numSpec)%5 == 0) ){ |
---|
26 | std::cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b|"; |
---|
27 | for(int i=0;i<(100*(pix+1)/numSpec)/5;i++) std::cout << "#"; |
---|
28 | for(int i=(100*(pix+1)/numSpec)/5;i<20;i++) std::cout << " "; |
---|
29 | std::cout << "|" << std::flush; |
---|
30 | } |
---|
31 | |
---|
32 | for(int z=0; z<this->axisDim[2]; z++) spec[z] = this->array[z*numSpec + pix]; |
---|
33 | |
---|
34 | getBaseline(this->axisDim[2], spec, thisBaseline, this->par); |
---|
35 | |
---|
36 | for(int z=0; z<this->axisDim[2]; z++) { |
---|
37 | this->baseline[z*numSpec+pix] = thisBaseline[z]; |
---|
38 | if(!par.isBlank(this->array[z*numSpec+pix])){ |
---|
39 | this->array[z*numSpec+pix] -= thisBaseline[z]; |
---|
40 | if(this->reconExists) this->recon[z*numSpec+pix] -= thisBaseline[z]; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | } |
---|
45 | |
---|
46 | delete [] spec; |
---|
47 | delete [] thisBaseline; |
---|
48 | |
---|
49 | if(this->par.isVerbose()) std::cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | void Cube::replaceBaseline() |
---|
55 | { |
---|
56 | /** |
---|
57 | * Cube::replaceBaseline() |
---|
58 | * A routine to replace the baseline flux on the reconstructed array (if it exists) |
---|
59 | * and the fluxes of each of the detected objects (if any). |
---|
60 | */ |
---|
61 | |
---|
62 | if(this->par.getFlagBaseline()){ |
---|
63 | |
---|
64 | for(int i=0;i<this->numPixels;i++){ |
---|
65 | if(!(this->par.isBlank(this->array[i]))) |
---|
66 | this->array[i] += this->baseline[i]; |
---|
67 | } |
---|
68 | |
---|
69 | if(this->reconExists){ |
---|
70 | // if we made a reconstruction, we need to add the baseline back in 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++){ // for each of its voxels |
---|
82 | |
---|
83 | pos = this->objectList[obj].getX(vox) + |
---|
84 | this->axisDim[0]*this->objectList[obj].getY(vox) + |
---|
85 | this->axisDim[0]*this->axisDim[1]*this->objectList[obj].getZ(vox); |
---|
86 | |
---|
87 | flux = this->objectList[obj].getF(vox) + this->baseline[pos]; |
---|
88 | |
---|
89 | this->objectList[obj].setF(vox, flux); |
---|
90 | |
---|
91 | } |
---|
92 | this->objectList[obj].calcParams(); // correct the flux calculations. |
---|
93 | |
---|
94 | } |
---|
95 | |
---|
96 | } |
---|
97 | |
---|
98 | } |
---|