#include #include #include #include #include #include #include #include using std::setw; using std::setfill; using std::setprecision; string getIAUName(double ra, double dec, FitsHeader head) { /** * string getIAUName(double, double, FitsHeader) * front end to the two getIAUName tasks. It parses the FitsHeader * object and works out the coord type and, if necessary, the * equinox. */ string longitudeType = head.getWCS()->lngtyp; if(longitudeType=="RA") return getIAUNameEQ(ra, dec, head.getWCS()->equinox); else return getIAUNameGAL(ra, dec); } string getIAUNameEQ(double ra, double dec, float equinox) { /** * 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< hh:mm:ss.ss, with dec made modulo 360. (or 24hrs) * DEC (declination) --> sdd:mm:ss.ss (with sign, either + or -) * GLON (galactic longitude) --> ddd:mm:ss.ss, with dec made modulo 360. * GLAT (galactic latitude) --> sdd:mm:ss.ss (with sign, either + or -) * Any other type defaults to RA, and prints warning. */ double dec_abs,sec; int deg,min; const double onemin=1./60.; double thisDec = dec; string sign=""; int degSize = 2; // number of figures in the degrees part of the output. if((type=="RA")||(type=="GLON")){ if(type=="GLON") degSize = 3; // three figures in degrees when doing longitude. // Make these modulo 360.; while (thisDec < 0.) { thisDec += 360.; } while (thisDec >= 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. duchampWarning("decToDMS", "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);//floor(d) 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)<