Changeset 1679 in Sophya for trunk/SophyaExt/XAstroPack/xastropack.h
- Timestamp:
- Oct 10, 2001, 11:55:10 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/XAstroPack/xastropack.h
r1678 r1679 39 39 }; 40 40 41 double TrueJDfrMJD(double mjd); 42 double MJDfrTrueJD(double jd); 43 double MJDfrDate(double dy,int mn,int yr); 44 void DatefrMJD(double mjd,double *dy,int *mn,int *yr); 45 double YearfrMJD(double mjd); 46 double MJDfrYear(double yr); 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); 53 double GSTfrUTC(double mjd0,double utc); 54 double UTCfrGST(double mjd0,double gst); 41 // ------------------- Utilitaires ------------------- 42 int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2); 43 44 /*! 45 \brief Pour remettre la valeur "val" dans la dynamique [0.,range[. 46 Si "vmax" different de "range", c'est la borne superieure 47 qui peut etre atteinte 48 (si elle est depassee, on soustrait "range"). 49 \verbatim 50 r>0 vmax>0 51 r=24. vmax=24. -> mets dans [ 0,+24[ borne sup exclue 52 r=24. vmax=12. -> mets dans ]-12,+12] borne inf exclue 53 \endverbatim 54 */ 55 inline void InRange(double *val,double range) 56 {*val-=range*floor(*val/range);} 57 inline void InRange(double *val,double range,double vmax) 58 {InRange(val,range); if(*val>vmax) *val-=range;} 59 60 // ------------------- Gestions des temps ------------------- 61 /*! \ingroup XAstroPack 62 \brief Compute true Julian day from MJD 63 */ 64 inline double TrueJDfrMJD(double mjd) {return mjd + MJD0;} 65 66 /*! \ingroup XAstroPack 67 \brief Compute MJD from true Julian day 68 */ 69 inline double MJDfrTrueJD(double jd) {return jd - MJD0;} 70 71 /*! \ingroup XAstroPack 72 \brief Compute MJD from date 73 \verbatim 74 MJD = modified Julian date (number of days elapsed since 1900 jan 0.5), 75 \endverbatim 76 */ 77 inline double MJDfrDate(double dy,int mn,int yr) 78 {double mjd; cal_mjd(mn,dy,yr,&mjd); return mjd;} 79 80 /*! \ingroup XAstroPack 81 \brief Compute date from MJD 82 */ 83 inline void DatefrMJD(double mjd,double *dy,int *mn,int *yr) 84 {mjd_cal(mjd,mn,dy,yr);} 85 86 /*! \ingroup XAstroPack 87 \brief Given a mjd, return the year as a double. 88 */ 89 inline double YearfrMJD(double mjd) 90 {double yr; mjd_year(mjd,&yr); return yr;} 91 92 /*! \ingroup XAstroPack 93 \brief Given a decimal year, return mjd 94 */ 95 inline double MJDfrYear(double yr) 96 {double mjd; year_mjd(yr,&mjd); return mjd;} 97 98 /*! \ingroup XAstroPack 99 \brief Given a mjd, return the year and number of days since 00:00 Jan 1 100 \warning: if mjd = 2 January -> number of days = 1 101 */ 102 inline void YDfrMJD(double mjd,double *dy,int *yr) 103 {mjd_dayno(mjd,yr,dy);} 104 105 /*! \ingroup XAstroPack 106 \brief Given a year, 107 */ 108 inline int IsLeapYear(int y) 109 {return isleapyear(y);} 110 111 /*! \ingroup XAstroPack 112 \brief given an mjd, set *dow to 0..6 according to which day of the week it falls on (0=sunday). 113 \return return 0 if ok else -1 if can't figure it out. 114 */ 115 inline int DayOrder(double mjd,int *dow) 116 {return mjd_dow(mjd,dow);} 117 118 /*! \ingroup XAstroPack 119 \brief given a mjd, return the the number of days in the month. 120 */ 121 inline int DaysInMonth(double mjd) 122 {int ndays; mjd_dpm(mjd,&ndays); return ndays;} 123 124 /*! \ingroup XAstroPack 125 \brief Given a mjd, truncate it to the beginning of the whole day 126 */ 127 inline double MJDat0hFrMJD(double mjd) {return mjd_day(mjd);} 128 129 /*! \ingroup XAstroPack 130 \brief Given a mjd, return the number of hours past midnight of the whole day 131 */ 132 inline double HfrMJD(double mjd) {return mjd_hr(mjd);} 133 134 /*! \ingroup XAstroPack 135 \brief Give GST from UTC 136 \verbatim 137 Given a modified julian date, mjd, and a universally coordinated time, utc, 138 return greenwich mean siderial time, *gst. 139 N.B. mjd must be at the beginning of the day. 140 \endverbatim 141 */ 142 inline double GSTfrUTC(double mjd0,double utc) 143 {double gst; utc_gst(mjd0,utc,&gst) ; return gst;} 144 145 /*! \ingroup XAstroPack 146 \brief Give UTC from GST 147 \verbatim 148 Given a modified julian date, mjd, and a greenwich mean siderial time, gst, 149 return universally coordinated time, *utc. 150 N.B. mjd must be at the beginning of the day. 151 \endverbatim 152 */ 153 inline double UTCfrGST(double mjd0,double gst) 154 {double utc; gst_utc(mjd0,gst,&utc); return utc;} 155 156 /*! \ingroup XAstroPack 157 \brief return local sidereal time from greenwich mean siderial time and longitude 158 \param precis : if not zero, then correct for obliquity and nutation 159 \warning no nutation or obliquity correction are done. 160 */ 161 inline double LSTfrGST(double gst,double geolng) 162 {double lst = gst + deghr(geolng); InRange(&lst,24.); return lst;} 163 55 164 double GST0(double mjd0); 56 double LSTfrGST(double gst,double geolng);57 165 double LSTfrMJD(double mjd,double geolng); 58 void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2);59 double AirmassfrAlt(double alt);60 double HafrRaTS(double lst,double ra);61 double RafrHaTS(double lst,double ha);62 double HelioCorr(double jd,double ra,double dec);63 166 void HMSfrHdec(double hd,int *h,int *mn,double *s); 64 167 double HdecfrHMS(int h,int mn,double s); 65 168 string ToStringHMS(int h,int mn,double s); 66 169 string ToStringHdec(double hd); 170 171 // ------------------- Calculs Divers ------------------- 172 void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2); 173 174 /*! \ingroup XAstroPack 175 \brief Given apparent altitude find airmass. 176 */ 177 inline double AirmassfrAlt(double alt) 178 {double x; alt = degrad(alt); airmass(alt,&x); return x;} 179 180 /*! \ingroup XAstroPack 181 \brief given geocentric time "jd" and coords of a distant object at "ra/dec" (J2000), 182 find the difference "hcp" in time between light arriving at earth vs the sun. 183 \return "hcp" must be subtracted from "geocentric jd" to get "heliocentric jd". 184 \warning "jd" is the TRUE Julian day (jd = mjd+MJD0). 185 */ 186 inline double HelioCorr(double jd,double ra,double dec) 187 {double hcp; ra=hrrad(ra); dec=degrad(dec); heliocorr(jd,ra,dec,&hcp); return hcp;} 188 189 // ------------------- Transformation de coordonnees ------------------- 190 /*! \ingroup XAstroPack 191 \brief Give the hour angle from local sideral time and right ascencion 192 \warning right ascencion should be first precessed to date of interest 193 \warning no nutation or obliquity correction are done. 194 */ 195 // Attention au probleme de la discontinuite 0h <==> 24h 196 // ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra) 197 // ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra) 198 inline double HafrRaTS(double lst,double ra) 199 {double ha = lst - ra; InRange(&ha,24.,12.); return ha;} 200 201 /*! \ingroup XAstroPack 202 \brief Give the local sideral time and the hour angle return the right ascencion 203 \warning right ascencion is the value precessed to date of interest 204 \warning no nutation or obliquity correction are done. 205 */ 206 inline double RafrHaTS(double lst,double ha) 207 {double ra = lst - ha; InRange(&ra,24.); return ra;} 208 67 209 void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat); 68 210 void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec); … … 73 215 void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat); 74 216 void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec); 75 void SunPos(double mjd,double *lsn,double *bsn); 76 void MoonPos(double mjd,double *lmn,double *bmn); 77 void PlanetPos(double mjd,int numplan,double *ecl,double *ecb,double *diamang); 78 void JupiterPos(double mjd,double *ecl,double *ecb,double *diamang); 79 void SaturnPos(double mjd,double *ecl,double *ecb,double *diamang); 80 int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2); 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;} 217 218 // ------------------- Positions des astres ------------------- 219 void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn); 220 void MoonPos(double mjd,double *lmn,double *bmn,double *rho); 221 void PlanetPos(double mjd,int numplan,double *sunecl,double *sunecb,double *sundist 222 ,double *geodist,double *geoecl,double *geoecb 223 ,double *diamang,double *mag); 224 /*! \ingroup XAstroPack 225 \brief Same as PlanetPos above with less arguments 226 */ 227 inline void PlanetPos(double mjd,int numplan,double *geoecl,double *geoecb 228 ,double *geodist,double *diamang) 229 { 230 double sunecl,sunecb,sundist,mag; 231 PlanetPos(mjd,numplan,&sunecl,&sunecb,&sundist,geodist,geoecl,geoecb,diamang,&mag); 232 } 233 234 /*! \ingroup XAstroPack 235 \brief Give Jupiter position 236 */ 237 inline void JupiterPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang) 238 { 239 PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang); 240 } 241 242 /*! \ingroup XAstroPack 243 \brief Give Saturn position 244 */ 245 inline void SaturnPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang) 246 { 247 PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang); 248 } 97 249 98 250 #endif
Note:
See TracChangeset
for help on using the changeset viewer.