// ----------------------------------------------------------------------- // ReadAndSearch.cc: Combining both the FITS reading and the searching. // ----------------------------------------------------------------------- // Copyright (C) 2006, Matthew Whiting, ATNF // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your // option) any later version. // // Duchamp is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License // along with Duchamp; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA // // Correspondence concerning Duchamp may be directed to: // Internet email: Matthew.Whiting [at] atnf.csiro.au // Postal address: Dr. Matthew Whiting // Australia Telescope National Facility, CSIRO // PO Box 76 // Epping NSW 1710 // AUSTRALIA // ----------------------------------------------------------------------- #include #include #include #include #include #include #include #include #define WCSLIB_GETWCSTAB // define this so that we don't try and // redefine wtbarr (this is a problem when // using gcc v.4+ #include #include #include #include #include #include #include #include std::string imageType[4] = {"point", "spectrum", "image", "cube"}; vector readAndSearch(Param &par) { vector outputList; short int maxdim=3; long *dimAxes = new long[maxdim]; for(int i=0;i1) std::cout << "x" << dimAxes[1]; if(numAxes>2) std::cout << "x" << dimAxes[2]; std::cout << std::endl; int anynul; long *fpixel = new long[numAxes]; long *lpixel = new long[numAxes]; long *inc = new long[numAxes]; // the data-sampling increment for(int i=0;isaveParam(par); spectrum->pars().setBeamSize(2.); // only neighbouring channels correlated for(int y=0;yclearDetectionList(); if(par.getFlagATrous()){ float *recon = new float[dimAxes[2]]; atrous1DReconstruct(dimAxes[2],array,recon,par); float *resid = new float[dimAxes[2]]; for(int i=0;isaveArray(recon,dimAxes[2]); delete [] recon; delete [] resid; spectrum->removeMW(); // only works if flagMW is true spectrum->setStats(median,sigma,par.getCut()); if(par.getFlagFDR()) spectrum->setupFDR(); spectrum->setMinSize(par.getMinChannels()); spectrum->findSources1D(); } else{ sigma = findMADFM(array,dimAxes[2])/correctionFactor; spectrum->saveArray(array,dimAxes[2]); spectrum->removeMW(); // only works if flagMW is true spectrum->setStats(median,sigma,par.getCut()); if(par.getFlagFDR()) spectrum->setupFDR(); spectrum->setMinSize(par.getMinChannels()); spectrum->findSources1D(); } numDetected += 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, x); object->setY(pix, y); object->setF(pix, array[object->getZ(pix)]); // NB: set F to the original value, not the recon value. } object->setOffsets(par); object->calcParams(); mergeIntoList(*object,outputList,par); delete object; } } // end of loop over y printBackSpace(6); std::cout << std::flush; } // end of loop over x delete spectrum; delete [] bigarray; delete [] array; delete [] fpixel; delete [] lpixel; delete [] inc; delete [] dimAxes; delete [] specdim; return outputList; }