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 | |
---|
8 | void 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 | |
---|
52 | void 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 | for(int obj=0;obj<this->objectList.size();obj++){ |
---|
76 | // for each detection, correct the flux calculations. |
---|
77 | this->objectList[obj].calcParams(this->array, this->axisDim); |
---|
78 | |
---|
79 | } |
---|
80 | |
---|
81 | } |
---|
82 | |
---|
83 | } |
---|