source: Sophya/trunk/SophyaExt/XAstroPack/xastropack.h@ 2552

Last change on this file since 2552 was 2552, checked in by cmv, 21 years ago

POUR LA nouvelle version de xephem/libastro (3.6) cmv 15/6/04

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