Changeset 1678 in Sophya for trunk/SophyaExt
- Timestamp:
- Oct 9, 2001, 11:47:57 PM (24 years ago)
- Location:
- trunk/SophyaExt/XAstroPack
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/XAstroPack/xastropack.cc
r1628 r1678 18 18 // EQUATORIALE: ascension droite en heures [0,24[ (ra) 19 19 // declinaison en degres [-90,90] (dec) 20 // angle horaire en heures [-12,12] (-12=12) (ha) tsid=ha+ra 20 // angle horaire en heures [-12,12] (-12=12) (ha) 21 // temps sideral du lieu: tsid=ha+ra (ou lst) 21 22 // GALACTIQUE: longitude en degres [0,360[ (glng) 22 23 // latitude en degres [-90,90] (glat) … … 51 52 /*! \ingroup XAstroPack 52 53 \brief Compute MJD from date 54 \verbatim 55 MJD = modified Julian date (number of days elapsed since 1900 jan 0.5), 56 \endverbatim 53 57 */ 54 58 double MJDfrDate(double dy,int mn,int yr) … … 97 101 98 102 /*! \ingroup XAstroPack 103 \brief Given a year, 104 */ 105 int IsLeapYear(int y) 106 { 107 return isleapyear(y); 108 } 109 110 /*! \ingroup XAstroPack 111 \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 XAstroPack 120 \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 XAstroPack 130 \brief Given a mjd, truncate it to the beginning of the whole day 131 */ 132 double MJDat0hFrMJD(double mjd) 133 { 134 return mjd_day(mjd); 135 } 136 137 /*! \ingroup XAstroPack 138 \brief Given a mjd, return the number of hours past midnight of the whole day 139 */ 140 double HfrMJD(double mjd) 141 { 142 return mjd_hr(mjd); 143 } 144 145 /*! \ingroup XAstroPack 99 146 \brief Give GST from UTC 100 147 \verbatim … … 131 178 */ 132 179 double GST0(double mjd0) 133 /* Copie depuis le code de Xephem car pas prototype*/180 /* Copie depuis le code de Xephem (utc_gst.c) car pas prototype*/ 134 181 { 135 182 double T, x; … … 143 190 144 191 /*! \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.; 199 InRange(&lst,24.); 200 return lst; 201 } 202 203 /*! \ingroup XAstroPack 204 \brief return local sidereal time from modified julian day and longitude 205 \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 XAstroPack 145 219 \brief Compute precession between 2 dates. 146 220 */ … … 150 224 dec1 *= PI/180.; // radians 151 225 precess(mjd1,mjd2,&ra1,&dec1); 152 *ra2 = ra1*12./PI; if(*ra2>24.) *ra2 -= 24.; if(*ra2==24.) *ra2 = 0.;226 *ra2 = ra1*12./PI; InRange(ra2,24.); 153 227 *dec2 = dec1*180./PI; 154 228 } … … 166 240 167 241 /*! \ingroup XAstroPack 168 \brief Give the hour angle from sideral time and right ascencion 169 */ 170 double HafrRaTS(double gst,double ra) 171 { 172 double ha = gst - ra; 242 \brief Give the hour angle from local sideral time and right ascencion 243 \warning right ascencion should be first precessed to date of interest 244 \warning no nutation or obliquity correction are done. 245 */ 246 double HafrRaTS(double lst,double ra) 247 { 248 double ha = lst - ra; 173 249 // Attention au probleme de la discontinuite 0h <==> 24h 174 250 // ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra) 175 251 // ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra) 176 if(ha==-12.) ha = 12.; if(ha<-12.) ha += 24.; if(ha>12.) ha -= 24.;252 InRange(&ha,24.,12.); 177 253 return ha; 254 } 255 256 /*! \ingroup XAstroPack 257 \brief Give the local sideral time and the hour angle return the right ascencion 258 \warning right ascencion is the value precessed to date of interest 259 \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 XAstroPack 269 \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.; // radians 278 dec *= PI/180.; // radians 279 heliocorr(jd,ra,dec,&hcp); 280 return hcp; 178 281 } 179 282 … … 247 350 248 351 /*! \ingroup XAstroPack 249 \brief Convert equatorial coordinates into galactic coordinates352 \brief Convert equatorial coordinates for the given epoch into galactic coordinates 250 353 */ 251 354 void EqtoGal(double mjd,double ra,double dec, double *glng,double *glat) … … 256 359 eq_gal(mjd,ra,dec,glat,glng); 257 360 // Vraiment bizarre, sur Linux-g++ glng>=360 ne comprend pas glng==360 ! (CMV) 258 *glng *= 180./PI; if(*glng>360.) *glng -= 360.; if(*glng==360.) *glng = 0.;361 *glng *= 180./PI; InRange(glng,360.); 259 362 *glat *= 180./PI; 260 363 } 261 364 262 365 /*! \ingroup XAstroPack 263 \brief Convert galactic coordinates into equatorial coordinates 366 \brief Convert galactic coordinates into equatorial coordinates at the given epoch 264 367 */ 265 368 void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec) … … 269 372 glat *= PI/180.; // radians 270 373 gal_eq (mjd,glat,glng,ra,dec); 271 *ra *= 12./PI; if(*ra>24.) *ra -= 24.; if(*ra==24.) *ra = 0.;374 *ra *= 12./PI; InRange(ra,24.); 272 375 *dec *= 180./PI; 273 376 } 274 377 275 378 /*! \ingroup XAstroPack 276 \brief Convert equatorial coordinates into horizontal coordinates277 */ 278 void Eq toHor(double geolat,double ha,double dec,double *az,double *alt)379 \brief Convert equatorial coordinates (with hour angle instead of right ascension) into horizontal coordinates. 380 */ 381 void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt) 279 382 // Coordonnees equatoriales -> Coordonnees horizontales 280 383 { … … 284 387 hadec_aa (geolat,ha,dec,alt,az); 285 388 *alt *= 180./PI; 286 *az *= 180./PI; if(*az>360.) *az -= 360.; if(*az==360.) *az = 0.;287 } 288 289 /*! \ingroup XAstroPack 290 Convert horizontal coordinates into equatorial coordinates 291 */ 292 void HortoEq (double geolat,double az,double alt,double *ha,double *dec)389 *az *= 180./PI; InRange(az,360.); 390 } 391 392 /*! \ingroup XAstroPack 393 Convert horizontal coordinates into equatorial coordinates (with hour angle instead of right ascension). 394 */ 395 void HortoEqH(double geolat,double az,double alt,double *ha,double *dec) 293 396 // Coordonnees horizontales -> Coordonnees equatoriales 294 397 { … … 297 400 az *= PI/180.; // radians 298 401 aa_hadec (geolat,alt,az,ha,dec); 299 *ha *= 12./PI; 300 if(*ha==-12.) *ha = 12.; if(*ha<-12.) *ha += 24.; if(*ha>12.) *ha -= 24.; 402 *ha *= 12./PI; InRange(ha,24.,12.); 301 403 *dec *= 180./PI; 302 404 } 303 405 304 406 /*! \ingroup XAstroPack 305 \brief Convert equatorial coordinates into ecliptic coordinates 407 \brief Convert equatorial coordinates into horizontal coordinates. 408 */ 409 void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt) 410 // Coordonnees equatoriales -> Coordonnees horizontales 411 { 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 417 hadec_aa (geolat,ha,dec,alt,az); 418 *alt *= 180./PI; 419 *az *= 180./PI; InRange(az,360.); 420 } 421 422 /*! \ingroup XAstroPack 423 Convert horizontal coordinates into equatorial coordinates. 424 */ 425 void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec) 426 // Coordonnees horizontales -> Coordonnees equatoriales 427 { 428 double ha; 429 geolat *= PI/180.; 430 alt *= PI/180.; // radians 431 az *= PI/180.; // radians 432 aa_hadec (geolat,alt,az,&ha,dec); 433 ha *= 12./PI; 434 *ra = lst - ha; InRange(ra,24.); 435 *dec *= 180./PI; 436 } 437 438 /*! \ingroup XAstroPack 439 \brief Convert equatorial coordinates into geocentric ecliptic coordinates given the modified Julian date. 440 \warning Correction for the effect on the angle of the obliquity due to nutation is not included. 306 441 */ 307 442 // Attention, j'ai modifie eq_ecl.c pour proteger NaN … … 315 450 dec *= PI/180.; // radians 316 451 eq_ecl(mjd,ra,dec,eclat,eclng); 317 *eclng *= 180./PI; if(*eclng>360.) *eclng -= 360.; if(*eclng==360.) *eclng = 0.;452 *eclng *= 180./PI; InRange(eclng,360.); 318 453 *eclat *= 180./PI; 319 454 } 320 455 321 456 /*! \ingroup XAstroPack 322 \brief Convert ecliptic coordinates into equatorial coordinates 457 \brief Convert geocentric ecliptic coordinates into equatorial coordinates given the modified Julian date. 458 \warning Correction for the effect on the angle of the obliquity due to nutation is not included. 323 459 */ 324 460 void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec) … … 328 464 eclng *= PI/180.; // radians 329 465 ecl_eq(mjd,eclat,eclng,ra,dec); 330 *ra *= 12./PI; if(*ra>24.) *ra -= 24.; if(*ra==24.) *ra = 0.;466 *ra *= 12./PI; InRange(ra,24.); 331 467 *dec *= 180./PI; 332 468 } … … 344 480 void SunPos(double mjd,double *eclsn,double *ecbsn) 345 481 { 346 347 348 *eclsn *= 180./PI; if(*eclsn>360.) *eclsn -= 360.; if(*eclsn==360.) *eclsn = 0.;482 double rsn; 483 sunpos(mjd,eclsn,&rsn,ecbsn); 484 *eclsn *= 180./PI; InRange(eclsn,360.); 349 485 *ecbsn *= 180./PI; 350 486 } … … 363 499 double rho,msp,mdp; 364 500 moon(mjd,eclmn,ecbmn,&rho,&msp,&mdp); 365 *eclmn *= 180./PI; if(*eclmn>360.) *eclmn -= 360.; if(*eclmn==360.) *eclmn = 0.;501 *eclmn *= 180./PI; InRange(eclmn,360.); 366 502 *ecbmn *= 180./PI; 367 503 } … … 388 524 void PlanetPos(double mjd,int numplan,double *ecl,double *ecb,double *diamang) 389 525 { 390 391 392 *ecl *= 180./PI; if(*ecl>360.) *ecl -= 360.; if(*ecl==360.) *ecl = 0.;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.); 393 529 *ecb *= 180./PI; 394 530 } -
trunk/SophyaExt/XAstroPack/xastropack.h
r1515 r1678 46 46 double MJDfrYear(double yr); 47 47 void YDfrMJD(double mjd,double *dy,int *yr); 48 int IsLeapYear(int y); 49 int DayOrder(double mjd,int *dow); 50 int DaysInMonth(double mjd); 51 double MJDat0hFrMJD(double mjd); 52 double HfrMJD(double mjd); 48 53 double GSTfrUTC(double mjd0,double utc); 49 54 double UTCfrGST(double mjd0,double gst); 50 55 double GST0(double mjd0); 56 double LSTfrGST(double gst,double geolng); 57 double LSTfrMJD(double mjd,double geolng); 51 58 void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2); 52 59 double AirmassfrAlt(double alt); 53 double HafrRaTS(double gst,double ra); 60 double HafrRaTS(double lst,double ra); 61 double RafrHaTS(double lst,double ha); 62 double HelioCorr(double jd,double ra,double dec); 54 63 void HMSfrHdec(double hd,int *h,int *mn,double *s); 55 64 double HdecfrHMS(int h,int mn,double s); … … 58 67 void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat); 59 68 void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec); 60 void EqtoHor(double geolat,double ha,double dec,double *az,double *alt); 61 void HortoEq(double geolat,double az,double alt,double *ha,double *dec); 69 void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt); 70 void HortoEqH(double geolat,double az,double alt,double *ha,double *dec); 71 void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt); 72 void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec); 62 73 void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat); 63 74 void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec); … … 69 80 int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2); 70 81 82 /*! 83 \brief Pour remettre la valeur "val" dans la dynamique [0.,range[. 84 Si "vmax" different de "range", c'est la borne superieure 85 qui peut etre atteinte 86 (si elle est depassee, on soustrait "range"). 87 \verbatim 88 r>0 vmax>0 89 r=24. vmax=24. -> mets dans [ 0,+24[ borne sup exclue 90 r=24. vmax=12. -> mets dans ]-12,+12] borne inf exclue 91 \endverbatim 92 */ 93 inline void InRange(double *val,double range) 94 {*val-=range*floor(*val/range);} 95 inline void InRange(double *val,double range,double vmax) 96 {InRange(val,range); if(*val>vmax) *val-=range;} 97 71 98 #endif
Note:
See TracChangeset
for help on using the changeset viewer.