// ----------------------------------------------------------------------- // spectralSelection.cc: A text-based menu to select a particular 1D // spectrum. // ----------------------------------------------------------------------- // 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 #include using namespace duchamp; void spectralSelection(std::vector &xvalues, std::vector &yvalues, long &zdim) { std::cout << "Do you want:\t 1) HI Cubes?\n"; std::cout << "\t\t 2) PHFS quasar spectra?\n"; std::cout << "\t\t 3) Orion Chandra time series?\n"; std::cout << "\t\t 4) 2BL spectra?\n"; std::cout << "\t\t 5) Gaussian noise?\n"; std::cout << "\t\t 6) Gaussian noise with a single Gaussian source?\n"; std::cout << "\t\t 7) As for 6) but with absorption as well?"<10)){ std::cout << "Enter choice (1 -- 10) : "; std::cin >> choice; } std::string fname; zdim=0; std::vector specx,specy; if(choice==1){ fname=menu(); std::cerr << fname <> ans; par.setFlagMW(ans=='y'); par.setImageFile(fname); par.setVerbosity(false); cube->saveParam(par); if(cube->getCube()==FAILURE) std::cerr << "Cannot read cube!"; zdim = cube->getDimZ(); if(par.getFlagMW()) cube->removeMW(); zdim = cube->getDimZ(); long xpos,ypos; std::cout << "Enter x (1--"<getDimX() << ") and y (1--"<getDimY() << ") positions: "; std::cin >> xpos >> ypos; xpos -= cube->pars().getXOffset(); ypos -= cube->pars().getYOffset(); float *array = new float[cube->getSize()]; cube->getArray(array); specx.resize(zdim); specy.resize(zdim); const int offset = 0; int ct=0; for(int zpos=0;zposgetDimX() + x + zpos * cube->getDimX() * cube->getDimY(); specy[ct] += array[cubepos]; } } specy[ct] /= (2*offset+1)*(2*offset+1); ct++; } delete cube; delete [] array; } else if((choice==7)||(choice==6)||(choice==5)){ zdim=1024; specx.resize(zdim); specy.resize(zdim); float *tempx = new float[zdim]; float *tempy = new float[zdim]; getRandomSpectrum(zdim,tempx,tempy); for(int i=0;i> snr; while((loc<0)||(loc>=zdim)){ std::cout << "Enter location of source (0 -- "<> loc >> fwhm; } for(int i=0;i=fwhm && snrAbs>=snr){ std::cout << "Enter SNR (<" << snr << ") and FWHM (<" << fwhm << ") of absorption line: "; std::cin >> snrAbs >> fwhmAbs; } for(int i=0;i> fname; } std::ifstream fin(fname.c_str()); float a; float b; specx.resize(0); specy.resize(0); while(fin>>a>>b){ specx.push_back(a); specy.push_back(b); zdim++; } } xvalues = specx; yvalues = specy; }