[74] | 1 | #include <iostream> |
---|
| 2 | #include <iomanip> |
---|
[175] | 3 | #include <param.hh> |
---|
[74] | 4 | #include <ATrous/atrous.hh> |
---|
| 5 | #include <Cubes/cubes.hh> |
---|
[213] | 6 | #include <Utils/feedback.hh> |
---|
[74] | 7 | |
---|
| 8 | void Cube::removeBaseline() |
---|
| 9 | { |
---|
| 10 | /** |
---|
[220] | 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. |
---|
[74] | 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 | |
---|
[187] | 23 | ProgressBar bar; |
---|
| 24 | if(this->par.isVerbose()) bar.init(numSpec); |
---|
[74] | 25 | for(int pix=0; pix<numSpec; pix++){ // for each spatial pixel... |
---|
| 26 | |
---|
[187] | 27 | if(this->par.isVerbose() ) bar.update(pix+1); |
---|
[74] | 28 | |
---|
[175] | 29 | for(int z=0; z<this->axisDim[2]; z++) |
---|
| 30 | spec[z] = this->array[z*numSpec + pix]; |
---|
[74] | 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 | } |
---|
[86] | 43 | |
---|
| 44 | delete [] spec; |
---|
| 45 | delete [] thisBaseline; |
---|
[74] | 46 | |
---|
[213] | 47 | if(this->par.isVerbose()) bar.remove(); |
---|
[74] | 48 | } |
---|
| 49 | |
---|
[86] | 50 | |
---|
| 51 | |
---|
[74] | 52 | void Cube::replaceBaseline() |
---|
| 53 | { |
---|
| 54 | /** |
---|
[220] | 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). |
---|
[74] | 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){ |
---|
[175] | 67 | // if we made a reconstruction, we need to add the baseline back in |
---|
| 68 | // for plotting purposes |
---|
[74] | 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 |
---|
[175] | 79 | for(int vox=0;vox<this->objectList[obj].getSize();vox++){ |
---|
| 80 | // for each of its voxels |
---|
[74] | 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 | } |
---|