#include #include #include #include #include #include void Cube::SimpleSearch3D() { /** * Cube::SimpleSearch3D() * A front end to the cubic searching routine that does not * involve any wavelet reconstruction. * Although 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 = cubicSearch(this->axisDim,this->array,this->par); this->updateDetectMap(); if(this->par.getFlagLog()) this->logDetectionList(); } vector cubicSearch(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; int zdim = dim[2]; int xySize = dim[0] * dim[1]; int 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: | |" << std::flush; // if(par.isVerbose()) std::cout << "Done 0%" << "\b\b\b\b\b\b\b\b" << std::flush; float *specMedian = new float[xySize]; float *specSigma = new float[xySize]; for(int npix=0; npix0) findMedianStats(spec,goodSize,specMedian[npix],dud); else specMedian[npix] = blankPixValue; // if(goodSize>0) findNormalStats(spec,goodSize,dud,specSigma[npix]); if(goodSize>0){ findMedianStats(spec,goodSize,dud,specSigma[npix]); specSigma[npix] /= correctionFactor; } else specSigma[npix] = 1.; delete spec; } // NEXT, DO SOURCE FINDING int numSearches = xySize + zdim; for(int npix=0; npixsaveParam(par); spectrum->pars().setBeamSize(2.); // for spectrum, only neighbouring channels correlated spectrum->saveArray(spec,zdim); spectrum->setStats(specMedian[npix],specSigma[npix],par.getCut()); if(par.getFlagFDR()) spectrum->setupFDR(); spectrum->setMinSize(par.getMinChannels()); spectrum->lutz_detect(); for(int obj=0;objgetNumObj();obj++){ Detection *object = new Detection; *object = spectrum->getObject(obj); // if(par.getFlagGrowth()) growObject(*object,*spectrum); 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(); // outputList.push_back(*object); mergeIntoList(*object,outputList,par); delete object; } delete spectrum; delete spec; delete specdim; } delete [] specMedian; delete [] specSigma; num = outputList.size(); if(par.isVerbose()) std::cout <<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bFound " << num <<";" << std::flush; } // SECOND SEARCH -- IN EACH CHANNEL // FIRST, GET STATS if(par.isVerbose()) std::cout << " 2D: | |" << std::flush; // if(par.isVerbose()) std::cout << "Done 0%" << "\b\b\b\b\b\b\b\b" << std::flush; float *imageMedian = new float[zdim]; float *imageSigma = new float[zdim]; for(int z=0; z0) findMedianStats(image,goodSize,imageMedian[z],dud); else imageMedian[z] = blankPixValue; if(goodSize>0) findNormalStats(image,goodSize,dud,imageSigma[z]); else imageSigma[z] = 1.; delete image; } // NEXT, DO SOURCE FINDING bool *doChannel = new bool[zdim]; for(int z=0;z=par.getMinMW()) && (z<=par.getMaxMW()) ); for(int z=0; zsaveParam(par); channelImage->saveArray(image,xySize); channelImage->setStats(imageMedian[z],imageSigma[z],par.getCut()); if(par.getFlagFDR()) channelImage->setupFDR(); channelImage->setMinSize(par.getMinPix()); channelImage->lutz_detect(); for(int obj=0;objgetNumObj();obj++){ Detection *object = new Detection; *object = channelImage->getObject(obj); // if(par.getFlagGrowth()) growObject(*object,*channelImage); // 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(); // outputList.push_back(*object); mergeIntoList(*object,outputList,par); delete object; } delete image; delete channelImage; delete imdim; } } if(par.isVerbose()) std::cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bFound " << outputList.size() - num << ". " << std::endl << std::flush; delete [] imageMedian; delete [] imageSigma; delete [] isGood; delete [] doChannel; return outputList; }