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

Last change on this file since 2322 was 1808, checked in by cmv, 24 years ago

nouvelle interface de gestion des systemes de coordonnees et des unites cmv 3/12/01

File size: 8.5 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#ifdef __cplusplus
14} /* extern "C" */
15#endif
16
17enum 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 -------------------
71unsigned long CoordConvertToStd(unsigned long typ,double* coord1,double* coord2);
72unsigned long GetCoordUnit(int coordnum,unsigned long typ);
73unsigned long DecodeTypAstro(const char *ctype);
74inline unsigned long DecodeTypAstro(const string stype)
75 {return DecodeTypAstro(stype.c_str());}
76string DecodeTypAstro(unsigned long typ);
77void ToCoLat(double* val,unsigned long typ);
78void InRangeLat(double* val,unsigned long typ);
79void 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*/
94inline void InRange(double *val,double range)
95 {*val-=range*floor(*val/range);}
96inline 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*/
103inline double TrueJDfrMJD(double mjd) {return mjd + MJD0;}
104
105/*! \ingroup XAstroPack
106\brief Compute MJD from true Julian day
107*/
108inline double MJDfrTrueJD(double jd) {return jd - MJD0;}
109
110double MJDfrDate(double dy,int mn,int yr);
111void DatefrMJD(double mjd,double *dy,int *mn,int *yr);
112double YearfrMJD(double mjd);
113double MJDfrYear(double yr);
114void YDfrMJD(double mjd,double *dy,int *yr);
115int IsLeapYear(int y);
116int DayOrder(double mjd,int *dow);
117int DaysInMonth(double mjd);
118double MJDat0hFrMJD(double mjd);
119double HfrMJD(double mjd);
120double GSTfrUTC(double mjd0,double utc);
121double 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*/
128inline double LSTfrGST(double gst,double geolng)
129 {double lst = gst + deghr(geolng); InRange(&lst,24.); return lst;}
130
131double GST0(double mjd0);
132double LSTfrMJD(double mjd,double geolng);
133void HMSfrHdec(double hd,int *h,int *mn,double *s);
134double HdecfrHMS(int h,int mn,double s);
135string ToStringHMS(int h,int mn,double s);
136string ToStringHdec(double hd);
137
138// ------------------- Calculs Divers -------------------
139void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2);
140inline 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}
144double AirmassfrAlt(double alt);
145double 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)
156inline 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*/
164inline double RafrHaTS(double lst,double ha)
165 {double ra = lst - ha; InRange(&ra,24.); return ra;}
166
167void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
168void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
169void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
170void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
171void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
172void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
173void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
174void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
175
176// ------------------- Positions des astres -------------------
177void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn);
178void MoonPos(double mjd,double *lmn,double *bmn,double *rho);
179void 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*/
185inline 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*/
195inline 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*/
203inline 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
Note: See TracBrowser for help on using the repository browser.