// ----------------------------------------------------------------------- // position_related.cc: General utility functions related to WCS positions // ----------------------------------------------------------------------- // 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 using std::setw; using std::setfill; using std::setprecision; std::string getIAUNameEQ(double ra, double dec, float equinox) { /** * std::string getIAUNameEQ(double, double, float) * both ra and dec are assumed to be in degrees. * returns name of the form J1234-4321 for equinox = 2000, * and B1234-4321 otherwise */ double raHrs = ra / 15.; int h = int(raHrs); int m = (int)(fmod(raHrs,1.)*60.); int s = (int)(fmod(raHrs,1./60.)*3600.); std::stringstream ss(std::stringstream::out); ss.setf(std::ios::showpoint); ss.setf(std::ios::fixed); if(equinox==2000.) ss << "J"; else ss << "B"; ss<= 360.) { thisDec -= 360.; } if(type=="RA") thisDec /= 15.; // Convert to hours. } else if((type=="DEC")||(type=="GLAT")){ if(thisDec<0.) sign = "-"; else sign = "+"; } else { // UNKNOWN TYPE -- DEFAULT TO RA. std::cerr << "WARNING : Unknown axis type (" << type << "). Defaulting to using RA.\n"; while (thisDec < 0.) { thisDec += 360.; } while (thisDec >= 360.) { thisDec -= 360.; } thisDec /= 15.; } dec_abs = fabs(thisDec); deg = int(dec_abs); min = int(fmod(dec_abs,1.)*60.); sec = fmod(dec_abs,onemin)*3600.; if(fabs(sec-60.)<1.e-10){ // to prevent rounding errors stuffing things up sec=0.; min++; } std::stringstream ss(std::stringstream::out); ss.setf(std::ios::showpoint); ss.setf(std::ios::fixed); ss << sign; ss << setw(degSize)<