Changeset 1679 in Sophya for trunk/SophyaExt/XAstroPack/xastropack.cc
- Timestamp:
- Oct 10, 2001, 11:55:10 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/XAstroPack/xastropack.cc
r1678 r1679 35 35 36 36 /*! \ingroup XAstroPack 37 \brief Compute true Julian day from MJD38 */39 double TrueJDfrMJD(double mjd)40 {41 return mjd + MJD0;42 }43 44 /*! \ingroup XAstroPack45 \brief Compute MJD from true Julian day46 */47 double MJDfrTrueJD(double jd)48 {49 return jd - MJD0;50 }51 52 /*! \ingroup XAstroPack53 \brief Compute MJD from date54 \verbatim55 MJD = modified Julian date (number of days elapsed since 1900 jan 0.5),56 \endverbatim57 */58 double MJDfrDate(double dy,int mn,int yr)59 {60 double mjd;61 cal_mjd(mn,dy,yr,&mjd);62 return mjd;63 }64 65 /*! \ingroup XAstroPack66 \brief Compute date from MJD67 */68 void DatefrMJD(double mjd,double *dy,int *mn,int *yr)69 {70 mjd_cal(mjd,mn,dy,yr);71 }72 73 /*! \ingroup XAstroPack74 \brief Given a mjd, return the year as a double.75 */76 double YearfrMJD(double mjd)77 {78 double yr;79 mjd_year(mjd,&yr);80 return yr;81 }82 83 /*! \ingroup XAstroPack84 \brief Given a decimal year, return mjd85 */86 double MJDfrYear(double yr)87 {88 double mjd;89 year_mjd(yr,&mjd);90 return mjd;91 }92 93 /*! \ingroup XAstroPack94 \brief Given a mjd, return the year and number of days since 00:00 Jan 195 \warning: if mjd = 2 January -> number of days = 196 */97 void YDfrMJD(double mjd,double *dy,int *yr)98 {99 mjd_dayno(mjd,yr,dy);100 }101 102 /*! \ingroup XAstroPack103 \brief Given a year,104 */105 int IsLeapYear(int y)106 {107 return isleapyear(y);108 }109 110 /*! \ingroup XAstroPack111 \brief given an mjd, set *dow to 0..6 according to which day of the week it falls on (0=sunday).112 \return return 0 if ok else -1 if can't figure it out.113 */114 int DayOrder(double mjd,int *dow)115 {116 return mjd_dow(mjd,dow);117 }118 119 /*! \ingroup XAstroPack120 \brief given a mjd, return the the number of days in the month.121 */122 int DaysInMonth(double mjd)123 {124 int ndays;125 mjd_dpm(mjd,&ndays);126 return ndays;127 }128 129 /*! \ingroup XAstroPack130 \brief Given a mjd, truncate it to the beginning of the whole day131 */132 double MJDat0hFrMJD(double mjd)133 {134 return mjd_day(mjd);135 }136 137 /*! \ingroup XAstroPack138 \brief Given a mjd, return the number of hours past midnight of the whole day139 */140 double HfrMJD(double mjd)141 {142 return mjd_hr(mjd);143 }144 145 /*! \ingroup XAstroPack146 \brief Give GST from UTC147 \verbatim148 Given a modified julian date, mjd, and a universally coordinated time, utc,149 return greenwich mean siderial time, *gst.150 N.B. mjd must be at the beginning of the day.151 \endverbatim152 */153 double GSTfrUTC(double mjd0,double utc)154 {155 double gst;156 utc_gst(mjd0,utc,&gst) ;157 return gst;158 }159 160 /*! \ingroup XAstroPack161 \brief Give UTC from GST162 \verbatim163 Given a modified julian date, mjd, and a greenwich mean siderial time, gst,164 return universally coordinated time, *utc.165 N.B. mjd must be at the beginning of the day.166 \endverbatim167 */168 double UTCfrGST(double mjd0,double gst)169 {170 double utc;171 gst_utc(mjd0,gst,&utc);172 return utc;173 }174 175 /*! \ingroup XAstroPack176 37 \brief gmst0() - return Greenwich Mean Sidereal Time at 0h UT 177 \param mjd = date at 0h UT in julian days since MJD038 \param mjd0 = date at 0h UT in julian days since MJD0 178 39 */ 179 40 double GST0(double mjd0) … … 190 51 191 52 /*! \ingroup XAstroPack 192 \brief return local sidereal time from greenwich mean siderial time and longitude 193 \param precis : if not zero, then correct for obliquity and nutation 194 \warning no nutation or obliquity correction are done. 195 */ 196 double LSTfrGST(double gst,double geolng) 197 { 198 double lst = gst + geolng *12./180.; 53 \brief return local sidereal time from modified julian day and longitude 54 \warning nutation or obliquity correction are taken into account. 55 */ 56 double LSTfrMJD(double mjd,double geolng) 57 { 58 double eps,lst,deps,dpsi; 59 utc_gst(mjd_day(mjd),mjd_hr(mjd),&lst); 60 lst += deghr(geolng); 61 obliquity(mjd,&eps); 62 nutation(mjd,&deps,&dpsi); 63 lst += radhr(dpsi*cos(eps+deps)); 199 64 InRange(&lst,24.); 200 65 return lst; 201 }202 203 /*! \ingroup XAstroPack204 \brief return local sidereal time from modified julian day and longitude205 \warning nutation or obliquity correction are taken into account.206 */207 double LSTfrMJD(double mjd,double geolng)208 {209 double eps,lst,deps,dpsi;210 utc_gst(mjd_day(mjd),mjd_hr(mjd),&lst);211 lst += geolng *12./180.;212 obliquity(mjd,&eps);213 nutation(mjd,&deps,&dpsi);214 lst += dpsi*cos(eps+deps) *12./M_PI;215 return lst;216 }217 218 /*! \ingroup XAstroPack219 \brief Compute precession between 2 dates.220 */221 void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2)222 {223 ra1 *= PI/12.; // radians224 dec1 *= PI/180.; // radians225 precess(mjd1,mjd2,&ra1,&dec1);226 *ra2 = ra1*12./PI; InRange(ra2,24.);227 *dec2 = dec1*180./PI;228 }229 230 /*! \ingroup XAstroPack231 \brief Given apparent altitude find airmass.232 */233 double AirmassfrAlt(double alt)234 {235 double x;236 alt *= PI/180.; // radians237 airmass(alt,&x);238 return x;239 }240 241 /*! \ingroup XAstroPack242 \brief Give the hour angle from local sideral time and right ascencion243 \warning right ascencion should be first precessed to date of interest244 \warning no nutation or obliquity correction are done.245 */246 double HafrRaTS(double lst,double ra)247 {248 double ha = lst - ra;249 // Attention au probleme de la discontinuite 0h <==> 24h250 // ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra)251 // ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra)252 InRange(&ha,24.,12.);253 return ha;254 }255 256 /*! \ingroup XAstroPack257 \brief Give the local sideral time and the hour angle return the right ascencion258 \warning right ascencion is the value precessed to date of interest259 \warning no nutation or obliquity correction are done.260 */261 double RafrHaTS(double lst,double ha)262 {263 double ra = lst - ha;264 InRange(&ra,24.);265 return ra;266 }267 268 /*! \ingroup XAstroPack269 \brief given geocentric time "jd" and coords of a distant object at "ra/dec" (J2000),270 find the difference "hcp" in time between light arriving at earth vs the sun.271 \return "hcp" must be subtracted from "geocentric jd" to get "heliocentric jd".272 \warning "jd" is the TRUE Julian day (jd = mjd+MJD0).273 */274 double HelioCorr(double jd,double ra,double dec)275 {276 double hcp;277 ra *= PI/12.; // radians278 dec *= PI/180.; // radians279 heliocorr(jd,ra,dec,&hcp);280 return hcp;281 66 } 282 67 … … 350 135 351 136 /*! \ingroup XAstroPack 137 \brief Compute precession between 2 dates. 138 */ 139 void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2) 140 { 141 ra1 = hrrad(ra1); // radians 142 dec1 = degrad(dec1); // radians 143 precess(mjd1,mjd2,&ra1,&dec1); 144 *ra2 = radhr(ra1); InRange(ra2,24.); 145 *dec2 = raddeg(dec1); 146 } 147 148 /*! \ingroup XAstroPack 352 149 \brief Convert equatorial coordinates for the given epoch into galactic coordinates 353 150 */ … … 355 152 // Coordonnees equatoriales -> Coordonnees galactiques 356 153 { 357 ra *= PI/12.; // radians358 dec *= PI/180.; // radians154 ra = hrrad(ra); // radians 155 dec = degrad(dec); // radians 359 156 eq_gal(mjd,ra,dec,glat,glng); 360 157 // Vraiment bizarre, sur Linux-g++ glng>=360 ne comprend pas glng==360 ! (CMV) 361 *glng *= 180./PI; InRange(glng,360.);362 *glat *= 180./PI;158 *glng = raddeg(*glng); InRange(glng,360.); 159 *glat = raddeg(*glat); 363 160 } 364 161 … … 369 166 // Coordonnees galactiques -> Coordonnees equatoriales 370 167 { 371 glng *= PI/180.; // radians372 glat *= PI/180.; // radians168 glng = degrad(glng); // radians 169 glat = degrad(glat); // radians 373 170 gal_eq (mjd,glat,glng,ra,dec); 374 *ra *= 12./PI; InRange(ra,24.);375 *dec *= 180./PI;171 *ra = radhr(*ra); InRange(ra,24.); 172 *dec = raddeg(*dec); 376 173 } 377 174 … … 382 179 // Coordonnees equatoriales -> Coordonnees horizontales 383 180 { 384 geolat *= PI/180.;385 ha *= PI/12.; // radians386 dec *= PI/180.; // radians181 geolat = degrad(geolat); // radians 182 ha = hrrad(ha); // radians 183 dec = degrad(dec); // radians 387 184 hadec_aa (geolat,ha,dec,alt,az); 388 *alt *= 180./PI;389 *az *= 180./PI; InRange(az,360.);185 *alt = raddeg(*alt); 186 *az = raddeg(*az); InRange(az,360.); 390 187 } 391 188 … … 396 193 // Coordonnees horizontales -> Coordonnees equatoriales 397 194 { 398 geolat *= PI/180.;399 alt *= PI/180.; // radians400 az *= PI/180.; // radians195 geolat = degrad(geolat); // radians 196 alt = degrad(alt); // radians 197 az = degrad(az); // radians 401 198 aa_hadec (geolat,alt,az,ha,dec); 402 *ha *= 12./PI; InRange(ha,24.,12.);403 *dec *= 180./PI;199 *ha = radhr(*ha); InRange(ha,24.,12.); 200 *dec = raddeg(*dec); 404 201 } 405 202 … … 410 207 // Coordonnees equatoriales -> Coordonnees horizontales 411 208 { 412 double ha = lst - ra; 413 if(ha==-12.) ha=12.; InRange(&ha,24.,12.); 414 geolat *= PI/180.; 415 ha *= PI/12.; // radians 416 dec *= PI/180.; // radians 209 double ha = lst - ra; InRange(&ha,24.,12.); 210 geolat = degrad(geolat); // radians 211 ha = hrrad(ha); // radians 212 dec = degrad(dec); // radians 417 213 hadec_aa (geolat,ha,dec,alt,az); 418 *alt *= 180./PI;419 *az *= 180./PI; InRange(az,360.);214 *alt = raddeg(*alt); 215 *az = raddeg(*az); InRange(az,360.); 420 216 } 421 217 … … 427 223 { 428 224 double ha; 429 geolat *= PI/180.;430 alt *= PI/180.; // radians431 az *= PI/180.; // radians225 geolat = degrad(geolat); // radians 226 alt = degrad(alt); // radians 227 az = degrad(az); // radians 432 228 aa_hadec (geolat,alt,az,&ha,dec); 433 ha *= 12./PI; 434 *ra = lst - ha; InRange(ra,24.); 435 *dec *= 180./PI; 229 *ra = lst - radhr(ha); InRange(ra,24.); 230 *dec = raddeg(*dec); 436 231 } 437 232 … … 447 242 // Coordonnees equatoriales -> Coordonnees ecliptiques 448 243 { 449 ra *= PI/12.; // radians450 dec *= PI/180.; // radians244 ra = hrrad(ra); // radians 245 dec = degrad(dec); // radians 451 246 eq_ecl(mjd,ra,dec,eclat,eclng); 452 *eclng *= 180./PI; InRange(eclng,360.);453 *eclat *= 180./PI;247 *eclng = raddeg(*eclng); InRange(eclng,360.); 248 *eclat = raddeg(*eclat); 454 249 } 455 250 … … 461 256 // Coordonnees ecliptiques -> Coordonnees equatoriales 462 257 { 463 eclat *= PI/180.; // radians464 eclng *= PI/180.; // radians258 eclat = degrad(eclat); // radians 259 eclng = degrad(eclng); // radians 465 260 ecl_eq(mjd,eclat,eclng,ra,dec); 466 *ra *= 12./PI; InRange(ra,24.);467 *dec *= 180./PI;261 *ra = radhr(*ra); InRange(ra,24.); 262 *dec = raddeg(*dec); 468 263 } 469 264 … … 472 267 \verbatim 473 268 given the modified JD, mjd, return the true geocentric ecliptic longitude 474 of the sun for the mean equinox of the date, * lsn, in radians, the475 sun-earth distance, *rsn, in AU, and the latitude * bsn, in radians269 of the sun for the mean equinox of the date, *eclsn, in degres, the 270 sun-earth distance, *rsn, in AU, and the latitude *ecbsn, in degres 476 271 (since this is always <= 1.2 arcseconds, in can be neglected by 477 calling with bsn = NULL). 478 \endverbatim 479 */ 480 void SunPos(double mjd,double *eclsn,double *ecbsn) 481 { 482 double rsn; 483 sunpos(mjd,eclsn,&rsn,ecbsn); 484 *eclsn *= 180./PI; InRange(eclsn,360.); 485 *ecbsn *= 180./PI; 272 calling with ecbsn = NULL). 273 - REMARQUE: 274 * if the APPARENT ecliptic longitude is required, correct the longitude for 275 * nutation to the true equinox of date and for aberration (light travel time, 276 * approximately -9.27e7/186000/(3600*24*365)*2*pi = -9.93e-5 radians). 277 \endverbatim 278 */ 279 void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn) 280 { 281 sunpos(mjd,eclsn,rsn,ecbsn); 282 *eclsn = raddeg(*eclsn); InRange(eclsn,360.); 283 if(ecbsn!=NULL) *ecbsn = raddeg(*ecbsn); 486 284 } 487 285 … … 495 293 \endverbatim 496 294 */ 497 void MoonPos(double mjd,double *eclmn,double *ecbmn )498 { 499 double rho,msp,mdp;500 moon(mjd,eclmn,ecbmn, &rho,&msp,&mdp);501 *eclmn *= 180./PI; InRange(eclmn,360.);502 *ecbmn *= 180./PI;295 void MoonPos(double mjd,double *eclmn,double *ecbmn,double *rho) 296 { 297 double msp,mdp; 298 moon(mjd,eclmn,ecbmn,rho,&msp,&mdp); 299 *eclmn = raddeg(*eclmn); InRange(eclmn,360.); 300 *ecbmn = raddeg(*ecbmn); 503 301 } 504 302 … … 507 305 \verbatim 508 306 * given a modified Julian date, mjd, and a planet, p, find: 509 * lpd0: heliocentric longitude,510 * psi0: heliocentric latitude,511 * rp0: distance from the sun to the planet,512 * rho0: distance from the Earth to the planet,307 * sunecl: heliocentric longitude, 308 * sunecb: heliocentric latitude, 309 * sundist: distance from the sun to the planet, 310 * geodist: distance from the Earth to the planet, 513 311 * none corrected for light time, ie, they are the true values for the 514 312 * given instant. 515 * lam: geocentric ecliptic longitude,516 * bet: geocentric ecliptic latitude,313 * geoecl: geocentric ecliptic longitude, 314 * geoecb: geocentric ecliptic latitude, 517 315 * each corrected for light time, ie, they are the apparent values as 518 316 * seen from the center of the Earth for the given instant. 519 * dia : angular diameter in arcsec at 1 AU,317 * diamang: angular diameter in arcsec at 1 AU, 520 318 * mag: visual magnitude when 1 AU from sun and earth at 0 phase angle. 521 319 * (for the mean equinox) 320 * all angles are in degres, all distances in AU. 321 * 322 * corrections for nutation and abberation must be made by the caller. The RA 323 * and DEC calculated from the fully-corrected ecliptic coordinates are then 324 * the apparent geocentric coordinates. Further corrections can be made, if 325 * required, for atmospheric refraction and geocentric parallax. 522 326 \endverbatim 523 327 */ 524 void PlanetPos(double mjd,int numplan,double *ecl,double *ecb,double *diamang) 525 { 526 double lpd0,psi0,rp0,rho0,mag; 527 plans(mjd,numplan,&lpd0,&psi0,&rp0,&rho0,ecl,ecb,diamang,&mag); 528 *ecl *= 180./PI; InRange(ecl,360.); 529 *ecb *= 180./PI; 530 } 531 532 /*! \ingroup XAstroPack 533 \brief Give Jupiter position 534 */ 535 void JupiterPos(double mjd,double *ecl,double *ecb,double *diamang) 536 { 537 PlanetPos(mjd,JUPITER,ecl,ecb,diamang); 538 } 539 540 /*! \ingroup XAstroPack 541 \brief Give Saturn position 542 */ 543 void SaturnPos(double mjd,double *ecl,double *ecb,double *diamang) 544 { 545 PlanetPos(mjd,SATURN,ecl,ecb,diamang); 328 void PlanetPos(double mjd,int numplan,double *sunecl,double *sunecb,double *sundist 329 ,double *geodist,double *geoecl,double *geoecb 330 ,double *diamang,double *mag) 331 { 332 plans(mjd,numplan,sunecl,sunecb,sundist,geodist,geoecl,geoecb,diamang,mag); 333 *geoecl = raddeg(*geoecl); InRange(geoecl,360.); 334 *geoecb = raddeg(*geoecb); 335 *sunecl = raddeg(*sunecl); InRange(sunecl,360.); 336 *sunecb = raddeg(*sunecb); 546 337 } 547 338 … … 564 355 if(typ&TypCoordEq) { 565 356 if(typ&TypCoordDD) { 566 coord1 = coord1 / 180. * 12.;357 coord1 = deghr(coord1); 567 358 } else if(typ&TypCoordRR) { 568 coord1 = coord1 / PI * 12.;569 coord2 = coord2 / PI * 180.;359 coord1 = radhr(coord1); 360 coord2 = raddeg(coord2); 570 361 } 571 362 if(coord1==24.) coord1 = 0.; … … 579 370 } else if( typ&TypCoordGal || typ&TypCoordHor || typ&TypCoordEcl) { 580 371 if(typ&TypCoordHD) { 581 coord1 = coord1 / 12. * 180.;372 coord1 = hrdeg(coord1); 582 373 } else if(typ&TypCoordRR) { 583 coord1 = coord1 / PI * 180.;584 coord2 = coord2 / PI * 180.;374 coord1 = raddeg(coord1); 375 coord2 = raddeg(coord2); 585 376 } 586 377 if(coord1==360.) coord1 = 0.;
Note:
See TracChangeset
for help on using the changeset viewer.