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 | //------ Coordonnees de type (A,B) avec:
|
---|
19 | // A,B <==> alpha,delta
|
---|
20 | // A,B <==> longitude,latitude
|
---|
21 | // A,B <==> azimuth,altitude ou elevation
|
---|
22 |
|
---|
23 | //------ Les unites des coordonnees
|
---|
24 | TypUniteH = (unsigned long) (1 << 0), // coord en heure
|
---|
25 | TypUniteD = (unsigned long) (1 << 1), // coord en degre
|
---|
26 | TypUniteR = (unsigned long) (1 << 2), // coord en radian
|
---|
27 |
|
---|
28 | //------ Les unites des coordonnees A et B
|
---|
29 | TypCoord1H = (unsigned long) (1 << 3), // coord A en heure
|
---|
30 | TypCoord1D = (unsigned long) (1 << 4), // coord A en degre
|
---|
31 | TypCoord1R = (unsigned long) (1 << 5), // coord A en radian
|
---|
32 | TypCoord2H = (unsigned long) (1 << 6), // coord B en heure
|
---|
33 | TypCoord2D = (unsigned long) (1 << 7), // coord B en degre
|
---|
34 | TypCoord2R = (unsigned long) (1 << 8), // coord B en radian
|
---|
35 |
|
---|
36 | //------ Le type d'intervalle des coordonnees A et B
|
---|
37 | // Coord A intervalle... ex: [0,24[ ou [0,360[ ou [0,2Pi[
|
---|
38 | TypCoord1C = (unsigned long) (1 << 10),
|
---|
39 | // Coord A intervalle centre... ex: ]-12,12] ou ]-180,180] ou ]-Pi,Pi]
|
---|
40 | TypCoord1L = (unsigned long) (1 << 11),
|
---|
41 | // Coord B intervalle... ex: [0,12] ou [0,180] ou [0,Pi] (colatitude)
|
---|
42 | TypCoord2C = (unsigned long) (1 << 12),
|
---|
43 | // Coord B intervalle centre... ex: [-6,6] ou [-90,90] ou [-Pi/2,Pi/2] (latitude)
|
---|
44 | TypCoord2L = (unsigned long) (1 << 13),
|
---|
45 |
|
---|
46 | //------ Les systemes de coordonnees astronomiques
|
---|
47 | // Coordonnees Equatoriales alpha,delta
|
---|
48 | TypCoordEq = (unsigned long) (1 << 15),
|
---|
49 | // Coordonnees Galactiques gLong, gLat
|
---|
50 | TypCoordGal = (unsigned long) (1 << 16),
|
---|
51 | // Coordonnees Horizontales azimuth,altitude
|
---|
52 | TypCoordHor = (unsigned long) (1 << 17),
|
---|
53 | // Coordonnees Ecliptiques EclLong,EclLat
|
---|
54 | TypCoordEcl = (unsigned long) (1 << 18),
|
---|
55 |
|
---|
56 | //------ Les systemes de coordonnees astronomiques "standard"
|
---|
57 | // Coordonnees Equatoriales alpha,delta
|
---|
58 | TypCoordEqStd = (unsigned long) (TypCoordEq |TypCoord1C|TypCoord1H|TypCoord2L|TypCoord2D),
|
---|
59 | // Coordonnees Galactiques gLong, gLat
|
---|
60 | TypCoordGalStd = (unsigned long) (TypCoordGal|TypCoord1C|TypCoord1D|TypCoord2L|TypCoord2D),
|
---|
61 | // Coordonnees Horizontales azimuth,altitude
|
---|
62 | TypCoordHorStd = (unsigned long) (TypCoordHor|TypCoord1C|TypCoord1D|TypCoord2L|TypCoord2D),
|
---|
63 | // Coordonnees Ecliptiques EclLong,EclLat
|
---|
64 | TypCoordEclStd = (unsigned long) (TypCoordEcl|TypCoord1C|TypCoord1D|TypCoord2L|TypCoord2D),
|
---|
65 |
|
---|
66 | //------ undef pour la forme
|
---|
67 | TypCoordUndef = (unsigned long) (0)
|
---|
68 | };
|
---|
69 |
|
---|
70 | // ------------------- Utilitaires -------------------
|
---|
71 | unsigned long CoordConvertToStd(unsigned long typ,double* coord1,double* coord2);
|
---|
72 | unsigned long GetCoordUnit(int coordnum,unsigned long typ);
|
---|
73 | unsigned long DecodeTypAstro(const char *ctype);
|
---|
74 | inline unsigned long DecodeTypAstro(const string stype)
|
---|
75 | {return DecodeTypAstro(stype.c_str());}
|
---|
76 | string DecodeTypAstro(unsigned long typ);
|
---|
77 | void ToCoLat(double* val,unsigned long typ);
|
---|
78 | void InRangeLat(double* val,unsigned long typ);
|
---|
79 | void InRangeCoLat(double* val,unsigned long typ);
|
---|
80 |
|
---|
81 | /*!
|
---|
82 | \brief Pour remettre la valeur "val" dans la dynamique [0.,range[.
|
---|
83 | Si "vmax" different de "range", c'est la borne superieure
|
---|
84 | qui peut etre atteinte
|
---|
85 | (si elle est depassee, on soustrait "range").
|
---|
86 | \verbatim
|
---|
87 | r>0 vmax>0
|
---|
88 | r=24. vmax=24. -> mets "val" dans [ 0,+24[ borne sup exclue
|
---|
89 | r=24. vmax=12. -> mets "val" dans ]-12,+12] borne inf exclue
|
---|
90 | (ATTENTION: ca ne marche pas pour la latitude [-90,90]
|
---|
91 | car -90 ne peut etre inclus dans l'intervalle)
|
---|
92 | \endverbatim
|
---|
93 | */
|
---|
94 | inline void InRange(double *val,double range)
|
---|
95 | {*val-=range*floor(*val/range);}
|
---|
96 | inline void InRange(double *val,double range,double vmax)
|
---|
97 | {InRange(val,range); if(*val>vmax) *val-=range;}
|
---|
98 |
|
---|
99 | // ------------------- Gestions des temps -------------------
|
---|
100 | /*! \ingroup XAstroPack
|
---|
101 | \brief Compute true Julian day from MJD
|
---|
102 | */
|
---|
103 | inline double TrueJDfrMJD(double mjd) {return mjd + MJD0;}
|
---|
104 |
|
---|
105 | /*! \ingroup XAstroPack
|
---|
106 | \brief Compute MJD from true Julian day
|
---|
107 | */
|
---|
108 | inline double MJDfrTrueJD(double jd) {return jd - MJD0;}
|
---|
109 |
|
---|
110 | double MJDfrDate(double dy,int mn,int yr);
|
---|
111 | void DatefrMJD(double mjd,double *dy,int *mn,int *yr);
|
---|
112 | double YearfrMJD(double mjd);
|
---|
113 | double MJDfrYear(double yr);
|
---|
114 | void YDfrMJD(double mjd,double *dy,int *yr);
|
---|
115 | int IsLeapYear(int y);
|
---|
116 | int DayOrder(double mjd,int *dow);
|
---|
117 | int DaysInMonth(double mjd);
|
---|
118 | double MJDat0hFrMJD(double mjd);
|
---|
119 | double HfrMJD(double mjd);
|
---|
120 | double GSTfrUTC(double mjd0,double utc);
|
---|
121 | double UTCfrGST(double mjd0,double gst);
|
---|
122 |
|
---|
123 | /*! \ingroup XAstroPack
|
---|
124 | \brief return local sidereal time from greenwich mean siderial time and longitude
|
---|
125 | \param precis : if not zero, then correct for obliquity and nutation
|
---|
126 | \warning no nutation or obliquity correction are done.
|
---|
127 | */
|
---|
128 | inline double LSTfrGST(double gst,double geolng)
|
---|
129 | {double lst = gst + deghr(geolng); InRange(&lst,24.); return lst;}
|
---|
130 |
|
---|
131 | double GST0(double mjd0);
|
---|
132 | double LSTfrMJD(double mjd,double geolng);
|
---|
133 | void HMSfrHdec(double hd,int *h,int *mn,double *s);
|
---|
134 | double HdecfrHMS(int h,int mn,double s);
|
---|
135 | string ToStringHMS(int h,int mn,double s);
|
---|
136 | string ToStringHdec(double hd);
|
---|
137 |
|
---|
138 | // ------------------- Calculs Divers -------------------
|
---|
139 | void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2);
|
---|
140 | inline void PrecessInPlace(double mjd1,double mjd2,double* ra,double* dec) {
|
---|
141 | double ra1=*ra, dec1=*dec;
|
---|
142 | Precess(mjd1,mjd2,ra1,dec1,ra,dec);
|
---|
143 | }
|
---|
144 | double AirmassfrAlt(double alt);
|
---|
145 | double HelioCorr(double jd,double ra,double dec);
|
---|
146 |
|
---|
147 | // ------------------- Transformation de coordonnees -------------------
|
---|
148 | /*! \ingroup XAstroPack
|
---|
149 | \brief Give the hour angle from local sideral time and right ascension
|
---|
150 | \warning right ascencion should be first precessed to date of interest
|
---|
151 | \warning no nutation or obliquity correction are done.
|
---|
152 | */
|
---|
153 | // Attention au probleme de la discontinuite 0h <==> 24h
|
---|
154 | // ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra)
|
---|
155 | // ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra)
|
---|
156 | inline double HafrRaTS(double lst,double ra)
|
---|
157 | {double ha = lst - ra; InRange(&ha,24.,12.); return ha;}
|
---|
158 |
|
---|
159 | /*! \ingroup XAstroPack
|
---|
160 | \brief Give the local sideral time and the hour angle return the right ascencion
|
---|
161 | \warning right ascencion is the value precessed to date of interest
|
---|
162 | \warning no nutation or obliquity correction are done.
|
---|
163 | */
|
---|
164 | inline double RafrHaTS(double lst,double ha)
|
---|
165 | {double ra = lst - ha; InRange(&ra,24.); return ra;}
|
---|
166 |
|
---|
167 | void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
|
---|
168 | void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
|
---|
169 | void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
|
---|
170 | void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
|
---|
171 | void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
|
---|
172 | void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
|
---|
173 | void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
|
---|
174 | void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
|
---|
175 |
|
---|
176 | // ------------------- Positions des astres -------------------
|
---|
177 | void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn);
|
---|
178 | void MoonPos(double mjd,double *lmn,double *bmn,double *rho);
|
---|
179 | void PlanetPos(double mjd,int numplan,double *sunecl,double *sunecb,double *sundist
|
---|
180 | ,double *geodist,double *geoecl,double *geoecb
|
---|
181 | ,double *diamang,double *mag);
|
---|
182 | /*! \ingroup XAstroPack
|
---|
183 | \brief Same as PlanetPos above with less arguments
|
---|
184 | */
|
---|
185 | inline void PlanetPos(double mjd,int numplan,double *geoecl,double *geoecb
|
---|
186 | ,double *geodist,double *diamang)
|
---|
187 | {
|
---|
188 | double sunecl,sunecb,sundist,mag;
|
---|
189 | PlanetPos(mjd,numplan,&sunecl,&sunecb,&sundist,geodist,geoecl,geoecb,diamang,&mag);
|
---|
190 | }
|
---|
191 |
|
---|
192 | /*! \ingroup XAstroPack
|
---|
193 | \brief Give Jupiter position
|
---|
194 | */
|
---|
195 | inline void JupiterPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
196 | {
|
---|
197 | PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang);
|
---|
198 | }
|
---|
199 |
|
---|
200 | /*! \ingroup XAstroPack
|
---|
201 | \brief Give Saturn position
|
---|
202 | */
|
---|
203 | inline void SaturnPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
204 | {
|
---|
205 | PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang);
|
---|
206 | }
|
---|
207 |
|
---|
208 | #endif
|
---|