1 | #ifndef XASTROPACK_H
|
---|
2 | #define XASTROPACK_H
|
---|
3 |
|
---|
4 | #include "machdefs.h"
|
---|
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 |
|
---|
17 | enum TypAstroCoord {
|
---|
18 | TypCoordUndef = (unsigned long) (0),
|
---|
19 |
|
---|
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 |
|
---|
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),
|
---|
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),
|
---|
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 |
|
---|
56 | // ------------------- Utilitaires -------------------
|
---|
57 | int CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2);
|
---|
58 |
|
---|
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 |
|
---|
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 |
|
---|
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);
|
---|
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);
|
---|
116 | inline void PrecessInPlace(double mjd1,double mjd2,double* ra,double* dec) {
|
---|
117 | double ra1=*ra, dec1=*dec;
|
---|
118 | Precess(mjd1,mjd2,ra1,dec1,ra,dec);
|
---|
119 | }
|
---|
120 | double AirmassfrAlt(double alt);
|
---|
121 | double HelioCorr(double jd,double ra,double dec);
|
---|
122 |
|
---|
123 | // ------------------- Transformation de coordonnees -------------------
|
---|
124 | /*! \ingroup XAstroPack
|
---|
125 | \brief Give the hour angle from local sideral time and right ascension
|
---|
126 | \warning right ascencion should be first precessed to date of interest
|
---|
127 | \warning no nutation or obliquity correction are done.
|
---|
128 | */
|
---|
129 | // Attention au probleme de la discontinuite 0h <==> 24h
|
---|
130 | // ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra)
|
---|
131 | // ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra)
|
---|
132 | inline double HafrRaTS(double lst,double ra)
|
---|
133 | {double ha = lst - ra; InRange(&ha,24.,12.); return ha;}
|
---|
134 |
|
---|
135 | /*! \ingroup XAstroPack
|
---|
136 | \brief Give the local sideral time and the hour angle return the right ascencion
|
---|
137 | \warning right ascencion is the value precessed to date of interest
|
---|
138 | \warning no nutation or obliquity correction are done.
|
---|
139 | */
|
---|
140 | inline double RafrHaTS(double lst,double ha)
|
---|
141 | {double ra = lst - ha; InRange(&ra,24.); return ra;}
|
---|
142 |
|
---|
143 | void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
|
---|
144 | void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
|
---|
145 | void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
|
---|
146 | void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
|
---|
147 | void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
|
---|
148 | void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
|
---|
149 | void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
|
---|
150 | void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
|
---|
151 |
|
---|
152 | // ------------------- Positions des astres -------------------
|
---|
153 | void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn);
|
---|
154 | void MoonPos(double mjd,double *lmn,double *bmn,double *rho);
|
---|
155 | void PlanetPos(double mjd,int numplan,double *sunecl,double *sunecb,double *sundist
|
---|
156 | ,double *geodist,double *geoecl,double *geoecb
|
---|
157 | ,double *diamang,double *mag);
|
---|
158 | /*! \ingroup XAstroPack
|
---|
159 | \brief Same as PlanetPos above with less arguments
|
---|
160 | */
|
---|
161 | inline void PlanetPos(double mjd,int numplan,double *geoecl,double *geoecb
|
---|
162 | ,double *geodist,double *diamang)
|
---|
163 | {
|
---|
164 | double sunecl,sunecb,sundist,mag;
|
---|
165 | PlanetPos(mjd,numplan,&sunecl,&sunecb,&sundist,geodist,geoecl,geoecb,diamang,&mag);
|
---|
166 | }
|
---|
167 |
|
---|
168 | /*! \ingroup XAstroPack
|
---|
169 | \brief Give Jupiter position
|
---|
170 | */
|
---|
171 | inline void JupiterPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
172 | {
|
---|
173 | PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang);
|
---|
174 | }
|
---|
175 |
|
---|
176 | /*! \ingroup XAstroPack
|
---|
177 | \brief Give Saturn position
|
---|
178 | */
|
---|
179 | inline void SaturnPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
180 | {
|
---|
181 | PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang);
|
---|
182 | }
|
---|
183 |
|
---|
184 | #endif
|
---|