#include #include #include #include #include void baselineSubtract(long numSpec, long specLength, float *originalCube, float *baselineValues, Param &par) { /** * baselineSubtract(long numSpec, long specLength, float *originalCube, float *baselineValues, Param &par) * * A routine to find the baseline of spectra in a cube (spectral direction assumed * to be the third dimension) and subtract it off the original. * The original cube has numSpec spatial pixels, each containing a spectrum of length specLength. * The original cube is read in, and returned with the baseline removed. * This baseline is stored in the array baselineValues. * The Param variable par is needed to test for blank pixels -- these are kept as blank. */ extern Filter reconFilter; float *spec = new float[specLength]; float *thisBaseline = new float[specLength]; int minscale = par.getMinScale(); par.setMinScale(reconFilter.getNumScales(specLength)); float atrouscut = par.getAtrousCut(); par.setAtrousCut(1); bool flagVerb = par.isVerbose(); par.setVerbosity(false); std::cout << "| |" << std::flush; for(int pix=0; pixarray and the baseline is in this->baseline. */ baselineSubtract(this->axisDim[0]*this->axisDim[1], this->axisDim[2], this->array, this->baseline, this->par); } void Cube::replaceBaseline() { /** * Cube::replaceBaseline() * A routine to replace the baseline flux on the reconstructed array (if it exists) * and the fluxes of each of the detected objects (if any). */ if(this->par.getFlagBaseline()){ for(int i=0;inumPixels;i++){ if(!(this->par.isBlank(this->array[i]))) this->array[i] += this->baseline[i]; } if(this->reconExists){ // if we made a reconstruction, we need to add the baseline back in for plotting purposes for(int i=0;inumPixels;i++){ if(!(this->par.isBlank(this->array[i]))) this->recon[i] += this->baseline[i]; } } int pos; float flux; // Now add the baseline to the flux for all the objects. for(int obj=0;objobjectList.size();obj++){ // for each detection for(int vox=0;voxobjectList[obj].getSize();vox++){ // for each of its voxels pos = this->objectList[obj].getX(vox) + this->axisDim[0]*this->objectList[obj].getY(vox) + this->axisDim[0]*this->axisDim[1]*this->objectList[obj].getZ(vox); flux = this->objectList[obj].getF(vox) + this->baseline[pos]; this->objectList[obj].setF(vox, flux); } this->objectList[obj].calcParams(); // correct the flux calculations. } } }