[1456] | 1 | #ifndef XASTROPACK_H
|
---|
| 2 | #define XASTROPACK_H
|
---|
| 3 |
|
---|
[1475] | 4 | #include "machdefs.h"
|
---|
[1456] | 5 | #include <string.h>
|
---|
| 6 | #include <string>
|
---|
| 7 |
|
---|
| 8 | #ifdef __cplusplus
|
---|
| 9 | extern "C" { /* extern "C" */
|
---|
| 10 | #endif
|
---|
| 11 | #include "XAstro/P_.h"
|
---|
| 12 | #include "XAstro/astro.h"
|
---|
| 13 | #ifdef __cplusplus
|
---|
| 14 | } /* extern "C" */
|
---|
| 15 | #endif
|
---|
| 16 |
|
---|
[1515] | 17 | enum TypAstroCoord {
|
---|
| 18 | TypCoordUndef = (unsigned long) (0),
|
---|
| 19 |
|
---|
| 20 | // Pour indiquer que les coordonnees sont en (heure=[0,24[,degre=[-90,90])
|
---|
| 21 | TypCoordHD = (unsigned long) (1 << 20),
|
---|
| 22 | // Pour indiquer que les coordonnees sont en (degre=[0,360[,degre=[-90,90])
|
---|
| 23 | TypCoordDD = (unsigned long) (1 << 21),
|
---|
| 24 | // Pour indiquer que les coordonnees sont en (radian=[0,2Pi[,radian=[-Pi/2,Pi/2])
|
---|
| 25 | TypCoordRR = (unsigned long) (1 << 22),
|
---|
| 26 |
|
---|
| 27 | // Coordonnees Equatoriales alpha,delta
|
---|
| 28 | TypCoordEq = (unsigned long) (1 << 0),
|
---|
| 29 | TypCoordEqStd = (unsigned long) ((1 << 0) | (1 << 20)),
|
---|
| 30 | // Coordonnees Galactiques gLong, gLat
|
---|
| 31 | TypCoordGal = (unsigned long) (1 << 1),
|
---|
| 32 | TypCoordGalStd = (unsigned long) ((1 << 1) | (1 << 21)),
|
---|
| 33 | // Coordonnees Horizontales azimuth,altitude
|
---|
| 34 | TypCoordHor = (unsigned long) (1 << 2),
|
---|
| 35 | TypCoordHorStd = (unsigned long) ((1 << 2) | (1 << 21)),
|
---|
| 36 | // Coordonnees Ecliptiques EclLong,EclLat
|
---|
| 37 | TypCoordEcl = (unsigned long) (1 << 3),
|
---|
| 38 | TypCoordEclStd = (unsigned long) ((1 << 3) | (1 << 21))
|
---|
| 39 | };
|
---|
| 40 |
|
---|
[1679] | 41 | // ------------------- Utilitaires -------------------
|
---|
[1515] | 42 | int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2);
|
---|
[1456] | 43 |
|
---|
[1678] | 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 |
|
---|
[1679] | 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 |
|
---|
| 164 | double GST0(double mjd0);
|
---|
| 165 | double LSTfrMJD(double mjd,double geolng);
|
---|
| 166 | void HMSfrHdec(double hd,int *h,int *mn,double *s);
|
---|
| 167 | double HdecfrHMS(int h,int mn,double s);
|
---|
| 168 | string ToStringHMS(int h,int mn,double s);
|
---|
| 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 |
|
---|
| 209 | void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
|
---|
| 210 | void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
|
---|
| 211 | void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
|
---|
| 212 | void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
|
---|
| 213 | void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
|
---|
| 214 | void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
|
---|
| 215 | void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
|
---|
| 216 | void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
|
---|
| 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 | }
|
---|
| 249 |
|
---|
[1456] | 250 | #endif
|
---|