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

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

add routine arguments by reference cmv 16/08/04

File size: 11.9 KB
RevLine 
[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
9extern "C" { /* extern "C" */
10#endif
[2552]11/* #include "XAstro/P_.h" */
[1456]12#include "XAstro/astro.h"
[2552]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
[1456]24#ifdef __cplusplus
25} /* extern "C" */
26#endif
27
[1515]28enum TypAstroCoord {
[1808]29 //------ Coordonnees de type (A,B) avec:
30 // A,B <==> alpha,delta
31 // A,B <==> longitude,latitude
32 // A,B <==> azimuth,altitude ou elevation
[1515]33
[1808]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
[1682]38
[1808]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
[1515]46
[1808]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
[1515]58 // Coordonnees Equatoriales alpha,delta
[1808]59 TypCoordEq = (unsigned long) (1 << 15),
[1515]60 // Coordonnees Galactiques gLong, gLat
[1808]61 TypCoordGal = (unsigned long) (1 << 16),
[1515]62 // Coordonnees Horizontales azimuth,altitude
[1808]63 TypCoordHor = (unsigned long) (1 << 17),
[1515]64 // Coordonnees Ecliptiques EclLong,EclLat
[1808]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)
[1515]79};
80
[1679]81// ------------------- Utilitaires -------------------
[1808]82unsigned long CoordConvertToStd(unsigned long typ,double* coord1,double* coord2);
[2601]83inline unsigned long CoordConvertToStd(unsigned long typ,double &coord1,double &coord2)
84 {return CoordConvertToStd(typ,&coord1,&coord2);}
85
[1808]86unsigned long GetCoordUnit(int coordnum,unsigned long typ);
[2601]87
[1808]88unsigned long DecodeTypAstro(const char *ctype);
89inline unsigned long DecodeTypAstro(const string stype)
[2601]90 {return DecodeTypAstro(stype.c_str());}
[1808]91string DecodeTypAstro(unsigned long typ);
[2601]92
[1808]93void ToCoLat(double* val,unsigned long typ);
[2601]94inline void ToCoLat(double &val,unsigned long typ)
95 {ToCoLat(&val,typ);}
96
[1808]97void InRangeLat(double* val,unsigned long typ);
[2601]98inline void InRangeLat(double &val,unsigned long typ)
99 {InRangeLat(&val,typ);}
100
[1808]101void InRangeCoLat(double* val,unsigned long typ);
[2601]102inline void InRangeCoLat(double &val,unsigned long typ)
103 {InRangeCoLat(&val,typ);}
[1456]104
[1678]105/*!
106\brief Pour remettre la valeur "val" dans la dynamique [0.,range[.
107 Si "vmax" different de "range", c'est la borne superieure
108 qui peut etre atteinte
109 (si elle est depassee, on soustrait "range").
110\verbatim
111 r>0 vmax>0
[1808]112 r=24. vmax=24. -> mets "val" dans [ 0,+24[ borne sup exclue
113 r=24. vmax=12. -> mets "val" dans ]-12,+12] borne inf exclue
[1791]114 (ATTENTION: ca ne marche pas pour la latitude [-90,90]
115 car -90 ne peut etre inclus dans l'intervalle)
[1678]116\endverbatim
117*/
118inline void InRange(double *val,double range)
119 {*val-=range*floor(*val/range);}
[2601]120inline void InRange(double &val,double range)
121 {val-=range*floor(val/range);}
122
[1678]123inline void InRange(double *val,double range,double vmax)
124 {InRange(val,range); if(*val>vmax) *val-=range;}
[2601]125inline void InRange(double &val,double range,double vmax)
126 {InRange(val,range); if(val>vmax) val-=range;}
[1678]127
[1679]128// ------------------- Gestions des temps -------------------
129/*! \ingroup XAstroPack
130\brief Compute true Julian day from MJD
131*/
132inline double TrueJDfrMJD(double mjd) {return mjd + MJD0;}
133
134/*! \ingroup XAstroPack
135\brief Compute MJD from true Julian day
136*/
137inline double MJDfrTrueJD(double jd) {return jd - MJD0;}
138
[1682]139double MJDfrDate(double dy,int mn,int yr);
[2601]140
[1682]141void DatefrMJD(double mjd,double *dy,int *mn,int *yr);
[2601]142inline void DatefrMJD(double mjd,double &dy,int &mn,int &yr)
143 {DatefrMJD(mjd,&dy,&mn,&yr);}
144
[1682]145double YearfrMJD(double mjd);
[2601]146
[1682]147double MJDfrYear(double yr);
[2601]148
[1682]149void YDfrMJD(double mjd,double *dy,int *yr);
[2601]150inline void YDfrMJD(double mjd,double &dy,int &yr)
151 {YDfrMJD(mjd,&dy,&yr);}
152
[1682]153int IsLeapYear(int y);
[2601]154
[1682]155int DayOrder(double mjd,int *dow);
[2601]156inline int DayOrder(double mjd,int &dow)
157 {return DayOrder(mjd,&dow);}
158
[1682]159int DaysInMonth(double mjd);
160double MJDat0hFrMJD(double mjd);
161double HfrMJD(double mjd);
162double GSTfrUTC(double mjd0,double utc);
163double UTCfrGST(double mjd0,double gst);
[1679]164
165/*! \ingroup XAstroPack
166\brief return local sidereal time from greenwich mean siderial time and longitude
167\param precis : if not zero, then correct for obliquity and nutation
168\warning no nutation or obliquity correction are done.
169*/
170inline double LSTfrGST(double gst,double geolng)
171 {double lst = gst + deghr(geolng); InRange(&lst,24.); return lst;}
172
173double GST0(double mjd0);
174double LSTfrMJD(double mjd,double geolng);
[2601]175
[1679]176void HMSfrHdec(double hd,int *h,int *mn,double *s);
[2601]177inline void HMSfrHdec(double hd,int &h,int &mn,double &s)
178 {HMSfrHdec(hd,&h,&mn,&s);}
179
[1679]180double HdecfrHMS(int h,int mn,double s);
181string ToStringHMS(int h,int mn,double s);
182string ToStringHdec(double hd);
183
184// ------------------- Calculs Divers -------------------
185void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2);
[2601]186inline void Precess(double mjd1,double mjd2,double ra1,double dec1,double &ra2,double &dec2)
187 {Precess(mjd1,mjd2,ra1,dec1,&ra2,&dec2);}
188
[1720]189inline void PrecessInPlace(double mjd1,double mjd2,double* ra,double* dec) {
190 double ra1=*ra, dec1=*dec;
191 Precess(mjd1,mjd2,ra1,dec1,ra,dec);
192}
[2601]193inline void PrecessInPlace(double mjd1,double mjd2,double &ra,double &dec) {
194 double ra1=ra, dec1=dec;
195 Precess(mjd1,mjd2,ra1,dec1,ra,dec);
196}
197
[1682]198double AirmassfrAlt(double alt);
199double HelioCorr(double jd,double ra,double dec);
[1679]200
201// ------------------- Transformation de coordonnees -------------------
202/*! \ingroup XAstroPack
[1720]203\brief Give the hour angle from local sideral time and right ascension
[1679]204\warning right ascencion should be first precessed to date of interest
205\warning no nutation or obliquity correction are done.
206*/
207// Attention au probleme de la discontinuite 0h <==> 24h
208// ts=1 ra=23 ; (ts-ra)=-22 <-12 --> ha = +2 = +24 + (ts-ra)
209// ts=23 ra=1 ; (ts-ra)=+22 >+12 --> ha = -2 = -24 + (ts-ra)
210inline double HafrRaTS(double lst,double ra)
211 {double ha = lst - ra; InRange(&ha,24.,12.); return ha;}
212
213/*! \ingroup XAstroPack
214\brief Give the local sideral time and the hour angle return the right ascencion
215\warning right ascencion is the value precessed to date of interest
216\warning no nutation or obliquity correction are done.
217*/
218inline double RafrHaTS(double lst,double ha)
219 {double ra = lst - ha; InRange(&ra,24.); return ra;}
220
221void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
[2601]222inline void EqtoGal(double mjd,double ra,double dec,double &glng,double &glat)
223 {EqtoGal(mjd,ra,dec,&glng,&glat);}
224
225
[1679]226void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
[2601]227inline void GaltoEq(double mjd,double glng,double glat,double &ra,double &dec)
228 {GaltoEq( mjd, glng, glat, &ra, &dec);}
229
[1679]230void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
[2601]231inline void EqHtoHor(double geolat,double ha,double dec,double &az,double &alt)
232 {EqHtoHor( geolat, ha, dec, &az, &alt);}
233
[1679]234void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
[2601]235inline void HortoEqH(double geolat,double az,double alt,double &ha,double &dec)
236 {HortoEqH( geolat, az, alt, &ha, &dec);}
237
[1679]238void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
[2601]239inline void EqtoHor(double geolat,double lst,double ra,double dec,double &az,double &alt)
240 {EqtoHor( geolat, lst, ra, dec, &az, &alt);}
241
[1679]242void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
[2601]243inline void HortoEq(double geolat,double lst,double az,double alt,double &ra,double &dec)
244 {HortoEq( geolat, lst, az, alt, &ra, &dec);}
245
[1679]246void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
[2601]247inline void EqtoEcl(double mjd,double ra,double dec,double &eclng,double &eclat)
248 {EqtoEcl( mjd, ra, dec, &eclng, &eclat);}
249
[1679]250void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
[2601]251inline void EcltoEq(double mjd,double eclng,double eclat,double &ra,double &dec)
252 {EcltoEq( mjd, eclng, eclat, &ra, &dec);}
[1679]253
254// ------------------- Positions des astres -------------------
255void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn);
[2601]256inline void SunPos(double mjd,double &eclsn,double &ecbsn,double &rsn)
257 {SunPos( mjd, &eclsn, &ecbsn, &rsn);}
258
[1679]259void MoonPos(double mjd,double *lmn,double *bmn,double *rho);
[2601]260inline void MoonPos(double mjd,double &lmn,double &bmn,double &rho)
261 {MoonPos( mjd, &lmn, &bmn, &rho);}
262
[2552]263void PlanetPos(double mjd,PLCode numplan,double *sunecl,double *sunecb,double *sundist
[1679]264 ,double *geodist,double *geoecl,double *geoecb
265 ,double *diamang,double *mag);
[2601]266inline void PlanetPos(double mjd,PLCode numplan,double &sunecl,double &sunecb,double &sundist
267 ,double &geodist,double &geoecl,double &geoecb
268 ,double &diamang,double &mag)
269 {PlanetPos(mjd,numplan,&sunecl,&sunecb,&sundist,&geodist,&geoecl,&geoecb,&diamang,&mag);}
270
[1679]271/*! \ingroup XAstroPack
272\brief Same as PlanetPos above with less arguments
273*/
[2552]274inline void PlanetPos(double mjd,PLCode numplan,double *geoecl,double *geoecb
[1679]275 ,double *geodist,double *diamang)
276{
277 double sunecl,sunecb,sundist,mag;
278 PlanetPos(mjd,numplan,&sunecl,&sunecb,&sundist,geodist,geoecl,geoecb,diamang,&mag);
279}
[2601]280inline void PlanetPos(double mjd,PLCode numplan,double &geoecl,double &geoecb
281 ,double &geodist,double &diamang)
282{
283 double sunecl,sunecb,sundist,mag;
284 PlanetPos(mjd,numplan,sunecl,sunecb,sundist,geodist,geoecl,geoecb,diamang,mag);
285}
[1679]286
287/*! \ingroup XAstroPack
288\brief Give Jupiter position
289*/
290inline void JupiterPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
291{
292 PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang);
293}
[2601]294inline void JupiterPos(double mjd,double &ecl,double &ecb,double &geodist,double &diamang)
295{
296 PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang);
297}
[1679]298
299/*! \ingroup XAstroPack
300\brief Give Saturn position
301*/
302inline void SaturnPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
303{
304 PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang);
305}
[2601]306inline void SaturnPos(double mjd,double &ecl,double &ecb,double &geodist,double &diamang)
307{
308 PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang);
309}
[1679]310
[1456]311#endif
Note: See TracBrowser for help on using the repository browser.