[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 |
|
---|
[1682] | 20 | TypCoordH0 = (unsigned long) (1 << 10), // heure=[0,24[
|
---|
| 21 | TypCoordH1 = (unsigned long) (1 << 11), // heure=]-12,12]
|
---|
| 22 | TypCoordD0 = (unsigned long) (1 << 12), // degre=[0,360[
|
---|
| 23 | TypCoordD1 = (unsigned long) (1 << 13), // degre=]-180,180]
|
---|
| 24 | TypCoordD2 = (unsigned long) (1 << 14), // degre=[-90,90]
|
---|
| 25 | TypCoordR0 = (unsigned long) (1 << 15), // degre=[0,2Pi[
|
---|
| 26 | TypCoordR1 = (unsigned long) (1 << 16), // degre=]-Pi,Pi]
|
---|
| 27 | TypCoordR2 = (unsigned long) (1 << 17), // degre=[-Pi/2,Pi/2]
|
---|
| 28 |
|
---|
[1515] | 29 | // Pour indiquer que les coordonnees sont en (heure=[0,24[,degre=[-90,90])
|
---|
| 30 | TypCoordHD = (unsigned long) (1 << 20),
|
---|
| 31 | // Pour indiquer que les coordonnees sont en (degre=[0,360[,degre=[-90,90])
|
---|
| 32 | TypCoordDD = (unsigned long) (1 << 21),
|
---|
| 33 | // Pour indiquer que les coordonnees sont en (radian=[0,2Pi[,radian=[-Pi/2,Pi/2])
|
---|
| 34 | TypCoordRR = (unsigned long) (1 << 22),
|
---|
[1682] | 35 | // Pour indiquer que les coordonnees sont en (heure=]-12,12],degre=[-90,90])
|
---|
| 36 | TypCoordH1D = (unsigned long) (1 << 23),
|
---|
| 37 | // Pour indiquer que les coordonnees sont en (degre=]-180,180],degre=[-90,90])
|
---|
| 38 | TypCoordD1D = (unsigned long) (1 << 24),
|
---|
| 39 | // Pour indiquer que les coordonnees sont en (radian=]-Pi,Pi],radian=[-Pi/2,Pi/2])
|
---|
| 40 | TypCoordR1R = (unsigned long) (1 << 25),
|
---|
[1515] | 41 |
|
---|
| 42 | // Coordonnees Equatoriales alpha,delta
|
---|
| 43 | TypCoordEq = (unsigned long) (1 << 0),
|
---|
| 44 | TypCoordEqStd = (unsigned long) ((1 << 0) | (1 << 20)),
|
---|
| 45 | // Coordonnees Galactiques gLong, gLat
|
---|
| 46 | TypCoordGal = (unsigned long) (1 << 1),
|
---|
| 47 | TypCoordGalStd = (unsigned long) ((1 << 1) | (1 << 21)),
|
---|
| 48 | // Coordonnees Horizontales azimuth,altitude
|
---|
| 49 | TypCoordHor = (unsigned long) (1 << 2),
|
---|
| 50 | TypCoordHorStd = (unsigned long) ((1 << 2) | (1 << 21)),
|
---|
| 51 | // Coordonnees Ecliptiques EclLong,EclLat
|
---|
| 52 | TypCoordEcl = (unsigned long) (1 << 3),
|
---|
| 53 | TypCoordEclStd = (unsigned long) ((1 << 3) | (1 << 21))
|
---|
| 54 | };
|
---|
| 55 |
|
---|
[1679] | 56 | // ------------------- Utilitaires -------------------
|
---|
[1515] | 57 | int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2);
|
---|
[1456] | 58 |
|
---|
[1678] | 59 | /*!
|
---|
| 60 | \brief Pour remettre la valeur "val" dans la dynamique [0.,range[.
|
---|
| 61 | Si "vmax" different de "range", c'est la borne superieure
|
---|
| 62 | qui peut etre atteinte
|
---|
| 63 | (si elle est depassee, on soustrait "range").
|
---|
| 64 | \verbatim
|
---|
| 65 | r>0 vmax>0
|
---|
| 66 | r=24. vmax=24. -> mets dans [ 0,+24[ borne sup exclue
|
---|
| 67 | r=24. vmax=12. -> mets dans ]-12,+12] borne inf exclue
|
---|
| 68 | \endverbatim
|
---|
| 69 | */
|
---|
| 70 | inline void InRange(double *val,double range)
|
---|
| 71 | {*val-=range*floor(*val/range);}
|
---|
| 72 | inline void InRange(double *val,double range,double vmax)
|
---|
| 73 | {InRange(val,range); if(*val>vmax) *val-=range;}
|
---|
| 74 |
|
---|
[1679] | 75 | // ------------------- Gestions des temps -------------------
|
---|
| 76 | /*! \ingroup XAstroPack
|
---|
| 77 | \brief Compute true Julian day from MJD
|
---|
| 78 | */
|
---|
| 79 | inline double TrueJDfrMJD(double mjd) {return mjd + MJD0;}
|
---|
| 80 |
|
---|
| 81 | /*! \ingroup XAstroPack
|
---|
| 82 | \brief Compute MJD from true Julian day
|
---|
| 83 | */
|
---|
| 84 | inline double MJDfrTrueJD(double jd) {return jd - MJD0;}
|
---|
| 85 |
|
---|
[1682] | 86 | double MJDfrDate(double dy,int mn,int yr);
|
---|
| 87 | void DatefrMJD(double mjd,double *dy,int *mn,int *yr);
|
---|
| 88 | double YearfrMJD(double mjd);
|
---|
| 89 | double MJDfrYear(double yr);
|
---|
| 90 | void YDfrMJD(double mjd,double *dy,int *yr);
|
---|
| 91 | int IsLeapYear(int y);
|
---|
| 92 | int DayOrder(double mjd,int *dow);
|
---|
| 93 | int DaysInMonth(double mjd);
|
---|
| 94 | double MJDat0hFrMJD(double mjd);
|
---|
| 95 | double HfrMJD(double mjd);
|
---|
| 96 | double GSTfrUTC(double mjd0,double utc);
|
---|
| 97 | double UTCfrGST(double mjd0,double gst);
|
---|
[1679] | 98 |
|
---|
| 99 | /*! \ingroup XAstroPack
|
---|
| 100 | \brief return local sidereal time from greenwich mean siderial time and longitude
|
---|
| 101 | \param precis : if not zero, then correct for obliquity and nutation
|
---|
| 102 | \warning no nutation or obliquity correction are done.
|
---|
| 103 | */
|
---|
| 104 | inline double LSTfrGST(double gst,double geolng)
|
---|
| 105 | {double lst = gst + deghr(geolng); InRange(&lst,24.); return lst;}
|
---|
| 106 |
|
---|
| 107 | double GST0(double mjd0);
|
---|
| 108 | double LSTfrMJD(double mjd,double geolng);
|
---|
| 109 | void HMSfrHdec(double hd,int *h,int *mn,double *s);
|
---|
| 110 | double HdecfrHMS(int h,int mn,double s);
|
---|
| 111 | string ToStringHMS(int h,int mn,double s);
|
---|
| 112 | string ToStringHdec(double hd);
|
---|
| 113 |
|
---|
| 114 | // ------------------- Calculs Divers -------------------
|
---|
| 115 | void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2);
|
---|
[1682] | 116 | double AirmassfrAlt(double alt);
|
---|
| 117 | double HelioCorr(double jd,double ra,double dec);
|
---|
[1679] | 118 |
|
---|
| 119 | // ------------------- Transformation de coordonnees -------------------
|
---|
| 120 | /*! \ingroup XAstroPack
|
---|
| 121 | \brief Give the hour angle from local sideral time and right ascencion
|
---|
| 122 | \warning right ascencion should be first precessed to date of interest
|
---|
| 123 | \warning no nutation or obliquity correction are done.
|
---|
| 124 | */
|
---|
| 125 | // Attention au probleme de la discontinuite 0h <==> 24h
|
---|
| 126 | // ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra)
|
---|
| 127 | // ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra)
|
---|
| 128 | inline double HafrRaTS(double lst,double ra)
|
---|
| 129 | {double ha = lst - ra; InRange(&ha,24.,12.); return ha;}
|
---|
| 130 |
|
---|
| 131 | /*! \ingroup XAstroPack
|
---|
| 132 | \brief Give the local sideral time and the hour angle return the right ascencion
|
---|
| 133 | \warning right ascencion is the value precessed to date of interest
|
---|
| 134 | \warning no nutation or obliquity correction are done.
|
---|
| 135 | */
|
---|
| 136 | inline double RafrHaTS(double lst,double ha)
|
---|
| 137 | {double ra = lst - ha; InRange(&ra,24.); return ra;}
|
---|
| 138 |
|
---|
| 139 | void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
|
---|
| 140 | void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
|
---|
| 141 | void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
|
---|
| 142 | void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
|
---|
| 143 | void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
|
---|
| 144 | void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
|
---|
| 145 | void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
|
---|
| 146 | void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
|
---|
| 147 |
|
---|
| 148 | // ------------------- Positions des astres -------------------
|
---|
| 149 | void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn);
|
---|
| 150 | void MoonPos(double mjd,double *lmn,double *bmn,double *rho);
|
---|
| 151 | void PlanetPos(double mjd,int numplan,double *sunecl,double *sunecb,double *sundist
|
---|
| 152 | ,double *geodist,double *geoecl,double *geoecb
|
---|
| 153 | ,double *diamang,double *mag);
|
---|
| 154 | /*! \ingroup XAstroPack
|
---|
| 155 | \brief Same as PlanetPos above with less arguments
|
---|
| 156 | */
|
---|
| 157 | inline void PlanetPos(double mjd,int numplan,double *geoecl,double *geoecb
|
---|
| 158 | ,double *geodist,double *diamang)
|
---|
| 159 | {
|
---|
| 160 | double sunecl,sunecb,sundist,mag;
|
---|
| 161 | PlanetPos(mjd,numplan,&sunecl,&sunecb,&sundist,geodist,geoecl,geoecb,diamang,&mag);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | /*! \ingroup XAstroPack
|
---|
| 165 | \brief Give Jupiter position
|
---|
| 166 | */
|
---|
| 167 | inline void JupiterPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
| 168 | {
|
---|
| 169 | PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang);
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | /*! \ingroup XAstroPack
|
---|
| 173 | \brief Give Saturn position
|
---|
| 174 | */
|
---|
| 175 | inline void SaturnPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
| 176 | {
|
---|
| 177 | PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang);
|
---|
| 178 | }
|
---|
| 179 |
|
---|
[1456] | 180 | #endif
|
---|