#include #include #include #include #include #include #include void Cube::CubicSearch() { /** * Cube::SimpleSearch3D() * A front end to the cubic searching routine that does not * involve any wavelet reconstruction. * If baseline-removal is required that is done prior to searching. * Once searching is complete, the detection map is updated and * the intermediate detections are logged in the log file. */ this->objectList = search3DArray(this->axisDim,this->array,this->par); this->updateDetectMap(); if(this->par.getFlagLog()) this->logDetectionList(); } vector search3DArray(long *dim, float *Array, Param &par) { /** * cubicSearch * Takes a dimension array and data array as input (and Parameter set) * and searches for detections in a combination of 1D and 2D searches. * Returns a vector list of Detections. * No reconstruction is assumed to have taken place, so statistics are * calculated (using robust methods) from the data array itself. */ vector outputList; long zdim = dim[2]; long xySize = dim[0] * dim[1]; long fullSize = zdim * xySize; int num = 0; float blankPixValue = par.getBlankPixVal(); bool *isGood = new bool[fullSize]; for(int pos=0;pos1){ if(par.isVerbose()) { std::cout << " 1D: "; initialiseMeter(); } for(int npix=0; npixsaveParam(par); spectrum->pars().setBeamSize(2.); // beam size: for spectrum, only neighbouring channels correlated spectrum->extractSpectrum(Array,dim,npix); spectrum->removeMW(); // only works if flagMW is true spectrum->setStats(specMedian,specSigma,par.getCut()); if(par.getFlagFDR()) spectrum->setupFDR(); spectrum->setMinSize(par.getMinChannels()); spectrum->spectrumDetect(); num += spectrum->getNumObj(); for(int obj=0;objgetNumObj();obj++){ Detection *object = new Detection; *object = spectrum->getObject(obj); for(int pix=0;pixgetSize();pix++) { // Fix up coordinates of each pixel to match original array object->setZ(pix, object->getX(pix)); object->setX(pix, npix%dim[0]); object->setY(pix, npix/dim[0]); } object->addOffsets(par); object->calcParams(); mergeIntoList(*object,outputList,par); delete object; } delete spectrum; } } // num = outputList.size(); if(par.isVerbose()) { printBackSpace(22); std::cout <<"Found " << num <<";" << std::flush; } } // SECOND SEARCH -- IN EACH CHANNEL if(par.isVerbose()){ std::cout << " 2D: "; initialiseMeter(); } num = 0; for(int z=0; zsaveParam(par); channelImage->extractImage(Array,dim,z); channelImage->setStats(imageMedian,imageSigma,par.getCut()); if(par.getFlagFDR()) channelImage->setupFDR(); channelImage->setMinSize(par.getMinPix()); channelImage->lutz_detect(); num += channelImage->getNumObj(); for(int obj=0;objgetNumObj();obj++){ Detection *object = new Detection; *object = channelImage->getObject(obj); // Fix up coordinates of each pixel to match original array for(int pix=0;pixgetSize();pix++) object->setZ(pix, z); object->addOffsets(par); object->calcParams(); mergeIntoList(*object,outputList,par); delete object; } delete channelImage; } } if(par.isVerbose()){ printBackSpace(22); std::cout << "Found " << num << "."; printSpace(44); std::cout << std::endl << std::flush; } delete [] isGood; delete [] doChannel; return outputList; }