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