Changeset 1682 in Sophya for trunk/SophyaExt/XAstroPack/xastropack.cc
- Timestamp:
- Oct 11, 2001, 2:42:00 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/XAstroPack/xastropack.cc
r1679 r1682 2 2 #include <stdio.h> 3 3 #include "xastropack.h" 4 5 // BUGS BUGS BUGS BUGS BUGS BUGS BUGS BUGS BUGS BUGS 6 // Corrections de divers bugs trouve dans libastro (CMV) 7 // 1******* In the file vsop87.c line 154: 8 // p = q/(t_abs[alpha] + alpha * t_abs[alpha-1] * 1e-4 + 1e-35); 9 // - to avoid t_abs[-1] when alpha=0, replaced by : 10 // if(alpha>0) p = t_abs[alpha-1]; else p=0; 11 // p = q/(t_abs[alpha] + alpha * p * 1e-4 + 1e-35); 12 // Mail envoye a ecdowney@ClearSkyInstitute.com 13 // 2******* In the file eq_ecl.c line 69: 14 // *q = asin((sy*ceps)-(cy*seps*sx*sw)); 15 // eq_ecl.c Protection NaN dans ecleq_aux, replaced by : 16 // *q = (sy*ceps)-(cy*seps*sx*sw); 17 // if(*q<-1.) *q = -PI/2.; else if(*q>1.) *q = PI/2.; else *q = asin(*q); 18 // Mail envoye a ecdowney@ClearSkyInstitute.com 19 4 20 5 21 /*! … … 18 34 // EQUATORIALE: ascension droite en heures [0,24[ (ra) 19 35 // declinaison en degres [-90,90] (dec) 20 // angle horaire en heures [-12,12] (-12=12) (ha)36 // angle horaire en heures ]-12,12] (-12=12) (ha) 21 37 // temps sideral du lieu: tsid=ha+ra (ou lst) 22 38 // GALACTIQUE: longitude en degres [0,360[ (glng) … … 35 51 36 52 /*! \ingroup XAstroPack 53 \brief Given a coordinate type "typ", convert to standard for astropack. 54 \verbatim 55 La routine convertit (in place) les coordonnees "coord1","coord2" 56 definies par le type "typ" dans les unites standard de ce systeme 57 de coordonnees. 58 "typ" code le systeme de coordonnees astronomiques et les unites utilisees 59 60 - Return : 0 = OK 61 1 = Unknown type of coordinates 62 2 = bad range for coord1 63 4 = bad range for coord2 64 6 = bad range for coord1 et coord2 65 66 Les types de coordonnees sont definies dans le enum TypAstroCoord: 67 La premiere coordonnee est de type "longitude" (alpha,longitude) 68 La deuxieme coordonnee est de type "latidude" (delta,latitude) 69 *** Definitions des unites des coordonnees et de leurs dynamiques 70 - TypCoordH0 : heure=[0,24[ 71 - TypCoordH1 : heure=]-12,12] 72 - TypCoordD0 : degre=[0,360[ 73 - TypCoordD1 : degre=]-180,180] 74 - TypCoordD2 : degre=[-90,90] 75 - TypCoordR0 : degre=[0,2Pi[ 76 - TypCoordR1 : degre=]-Pi,Pi] 77 - TypCoordR2 : degre=[-Pi/2,Pi/2] 78 *** Definitions des combinaisons unites des coordonnees 79 - TypCoordHD : coordonnees en (heure=[0,24[,degre=[-90,90]) 80 - TypCoordDD : coordonnees en (degre=[0,360[,degre=[-90,90]) 81 - TypCoordRR : coordonnees en (radian=[0,2Pi[,radian=[-Pi/2,Pi/2]) 82 - TypCoordH1D : coordonnees en (heure=]-12,12],degre=[-90,90]) 83 - TypCoordD1D : coordonnees en (degre=]-180,180],degre=[-90,90]) 84 - TypCoordR1R : coordonnees en (radian=]-Pi,Pi],radian=[-Pi/2,Pi/2]) 85 *** Definitions des types de systemes de coordonnees astronomiques. 86 - TypCoordEq : Coordonnees Equatoriales alpha,delta 87 - TypCoordGal : Coordonnees Galactiques gLong, gLat 88 - TypCoordHor : Coordonnees Horizontales azimuth,altitude 89 - TypCoordEcl : Coordonnees Ecliptiques EclLong,EclLat 90 *** Definitions des unites par defaut pour les divers systemes de coordonnees. 91 - TypCoordEqStd : heure=[0,24[, degre=[-90,90] 92 - TypCoordGalStd : degre=[0,360[,degre=[-90,90] 93 - TypCoordHorStd : degre=[0,360[,degre=[-90,90] 94 - TypCoordEclStd : degre=[0,360[,degre=[-90,90] 95 \endverbatim 96 */ 97 int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2) 98 { 99 int rc = 0; 100 101 // ---- Equatoriales alpha,delta 102 // - standard = [0,24[ , [-90,90] 103 if(typ&TypCoordEq) { 104 if(typ&TypCoordDD) { 105 coord1 = deghr(coord1); 106 } else if(typ&TypCoordRR) { 107 coord1 = radhr(coord1); 108 coord2 = raddeg(coord2); 109 } 110 if(coord1==24.) coord1 = 0.; 111 if(coord1<0. || coord1>=24.) rc+= 2; 112 if(coord2<-90. || coord2>90. ) rc+= 4; 113 114 // ---- Galactiques gLong, gLat 115 // ---- Horizontales azimuth,altitude 116 // ---- Ecliptiques EclLong,EclLat 117 // - standard = [0,360[ , [-90,90] 118 } else if( typ&TypCoordGal || typ&TypCoordHor || typ&TypCoordEcl) { 119 if(typ&TypCoordHD) { 120 coord1 = hrdeg(coord1); 121 } else if(typ&TypCoordRR) { 122 coord1 = raddeg(coord1); 123 coord2 = raddeg(coord2); 124 } 125 if(coord1==360.) coord1 = 0.; 126 if(coord1<0. || coord1>=360.) rc+= 2; 127 if(coord2<-90. || coord2>90. ) rc+= 4; 128 129 } else { // Coordonnees non-connues 130 rc= 1; 131 } 132 133 return rc; 134 } 135 136 /*! \ingroup XAstroPack 137 \brief Compute MJD from date 138 \verbatim 139 MJD = modified Julian date (number of days elapsed since 1900 jan 0.5), 140 \endverbatim 141 */ 142 double MJDfrDate(double dy,int mn,int yr) 143 { 144 double mjd; 145 cal_mjd(mn,dy,yr,&mjd); 146 return mjd; 147 } 148 149 /*! \ingroup XAstroPack 150 \brief Compute date from MJD 151 */ 152 void DatefrMJD(double mjd,double *dy,int *mn,int *yr) 153 { 154 mjd_cal(mjd,mn,dy,yr); 155 } 156 157 /*! \ingroup XAstroPack 158 \brief Given a mjd, return the year as a double. 159 */ 160 double YearfrMJD(double mjd) 161 { 162 double yr; 163 mjd_year(mjd,&yr); 164 return yr; 165 } 166 167 /*! \ingroup XAstroPack 168 \brief Given a decimal year, return mjd 169 */ 170 double MJDfrYear(double yr) 171 { 172 double mjd; 173 year_mjd(yr,&mjd); 174 return mjd; 175 } 176 177 /*! \ingroup XAstroPack 178 \brief Given a mjd, return the year and number of days since 00:00 Jan 1 179 \warning: if mjd = 2 January -> number of days = 1 180 */ 181 void YDfrMJD(double mjd,double *dy,int *yr) 182 { 183 mjd_dayno(mjd,yr,dy); 184 } 185 186 /*! \ingroup XAstroPack 187 \brief Given a year, 188 */ 189 int IsLeapYear(int y) 190 { 191 return isleapyear(y); 192 } 193 194 /*! \ingroup XAstroPack 195 \brief given an mjd, set *dow to 0..6 according to which day of the week it falls on (0=sunday). 196 \return return 0 if ok else -1 if can't figure it out. 197 */ 198 int DayOrder(double mjd,int *dow) 199 { 200 return mjd_dow(mjd,dow); 201 } 202 203 /*! \ingroup XAstroPack 204 \brief given a mjd, return the the number of days in the month. 205 */ 206 int DaysInMonth(double mjd) 207 { 208 int ndays; 209 mjd_dpm(mjd,&ndays); 210 return ndays; 211 } 212 213 /*! \ingroup XAstroPack 214 \brief Given a mjd, truncate it to the beginning of the whole day 215 */ 216 double MJDat0hFrMJD(double mjd) 217 { 218 return mjd_day(mjd); 219 } 220 221 /*! \ingroup XAstroPack 222 \brief Given a mjd, return the number of hours past midnight of the whole day 223 */ 224 double HfrMJD(double mjd) 225 { 226 return mjd_hr(mjd); 227 } 228 229 /*! \ingroup XAstroPack 230 \brief Give GST from UTC 231 \verbatim 232 Given a modified julian date, mjd, and a universally coordinated time, utc, 233 return greenwich mean siderial time, *gst. 234 N.B. mjd must be at the beginning of the day. 235 \endverbatim 236 */ 237 double GSTfrUTC(double mjd0,double utc) 238 { 239 double gst; 240 utc_gst(mjd0,utc,&gst); 241 return gst; 242 } 243 244 /*! \ingroup XAstroPack 245 \brief Give UTC from GST 246 \verbatim 247 Given a modified julian date, mjd, and a greenwich mean siderial time, gst, 248 return universally coordinated time, *utc. 249 N.B. mjd must be at the beginning of the day. 250 \endverbatim 251 */ 252 double UTCfrGST(double mjd0,double gst) 253 { 254 double utc; 255 gst_utc(mjd0,gst,&utc); 256 return utc; 257 } 258 259 /*! \ingroup XAstroPack 260 \brief Given apparent altitude find airmass. 261 */ 262 double AirmassfrAlt(double alt) 263 { 264 double x; 265 alt = degrad(alt); 266 airmass(alt,&x); 267 return x; 268 } 269 270 /*! \ingroup XAstroPack 271 \brief given geocentric time "jd" and coords of a distant object at "ra/dec" (J2000), 272 find the difference "hcp" in time between light arriving at earth vs the sun. 273 \return "hcp" must be subtracted from "geocentric jd" to get "heliocentric jd". 274 \warning "jd" is the TRUE Julian day (jd = mjd+MJD0). 275 */ 276 double HelioCorr(double jd,double ra,double dec) 277 { 278 double hcp; 279 ra=hrrad(ra); 280 dec=degrad(dec); 281 heliocorr(jd,ra,dec,&hcp); 282 return hcp; 283 } 284 285 /*! \ingroup XAstroPack 37 286 \brief gmst0() - return Greenwich Mean Sidereal Time at 0h UT 38 287 \param mjd0 = date at 0h UT in julian days since MJD0 … … 235 484 \warning Correction for the effect on the angle of the obliquity due to nutation is not included. 236 485 */ 237 // Attention, j'ai modifie eq_ecl.c pour proteger NaN238 // dans ecleq_aux :239 // *q = (sy*ceps)-(cy*seps*sx*sw);240 // if(*q<-1.) *q = -PI/2.; else if(*q>1.) *q = PI/2.; else *q = asin(*q);241 486 void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat) 242 487 // Coordonnees equatoriales -> Coordonnees ecliptiques … … 336 581 *sunecb = raddeg(*sunecb); 337 582 } 338 339 /*! \ingroup XAstroPack340 \brief Given a coordinate type "typ", convert to standard for astropack341 \verbatim342 // Return : 0 = OK343 // 1 = Unknown type of coordinates344 // 2 = bad range for coord1345 // 4 = bad range for coord2346 // 6 = bad range for coord1 et coord2347 \endverbatim348 */349 int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2)350 {351 int rc = 0;352 353 // ---- Equatoriales alpha,delta354 // - standard = [0,24[ , [-90,90]355 if(typ&TypCoordEq) {356 if(typ&TypCoordDD) {357 coord1 = deghr(coord1);358 } else if(typ&TypCoordRR) {359 coord1 = radhr(coord1);360 coord2 = raddeg(coord2);361 }362 if(coord1==24.) coord1 = 0.;363 if(coord1<0. || coord1>=24.) rc+= 2;364 if(coord2<-90. || coord2>90. ) rc+= 4;365 366 // ---- Galactiques gLong, gLat367 // ---- Horizontales azimuth,altitude368 // ---- Ecliptiques EclLong,EclLat369 // - standard = [0,360[ , [-90,90]370 } else if( typ&TypCoordGal || typ&TypCoordHor || typ&TypCoordEcl) {371 if(typ&TypCoordHD) {372 coord1 = hrdeg(coord1);373 } else if(typ&TypCoordRR) {374 coord1 = raddeg(coord1);375 coord2 = raddeg(coord2);376 }377 if(coord1==360.) coord1 = 0.;378 if(coord1<0. || coord1>=360.) rc+= 2;379 if(coord2<-90. || coord2>90. ) rc+= 4;380 381 } else { // Coordonnees non-connues382 rc= 1;383 }384 385 return rc;386 }
Note:
See TracChangeset
for help on using the changeset viewer.