[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
|
---|
| 9 | extern "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] | 28 | enum 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] | 82 | unsigned long CoordConvertToStd(unsigned long typ,double* coord1,double* coord2);
|
---|
[2601] | 83 | inline unsigned long CoordConvertToStd(unsigned long typ,double &coord1,double &coord2)
|
---|
| 84 | {return CoordConvertToStd(typ,&coord1,&coord2);}
|
---|
| 85 |
|
---|
[1808] | 86 | unsigned long GetCoordUnit(int coordnum,unsigned long typ);
|
---|
[2601] | 87 |
|
---|
[1808] | 88 | unsigned long DecodeTypAstro(const char *ctype);
|
---|
| 89 | inline unsigned long DecodeTypAstro(const string stype)
|
---|
[2601] | 90 | {return DecodeTypAstro(stype.c_str());}
|
---|
[1808] | 91 | string DecodeTypAstro(unsigned long typ);
|
---|
[2601] | 92 |
|
---|
[1808] | 93 | void ToCoLat(double* val,unsigned long typ);
|
---|
[2601] | 94 | inline void ToCoLat(double &val,unsigned long typ)
|
---|
| 95 | {ToCoLat(&val,typ);}
|
---|
| 96 |
|
---|
[1808] | 97 | void InRangeLat(double* val,unsigned long typ);
|
---|
[2601] | 98 | inline void InRangeLat(double &val,unsigned long typ)
|
---|
| 99 | {InRangeLat(&val,typ);}
|
---|
| 100 |
|
---|
[1808] | 101 | void InRangeCoLat(double* val,unsigned long typ);
|
---|
[2601] | 102 | inline 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 | */
|
---|
| 118 | inline void InRange(double *val,double range)
|
---|
| 119 | {*val-=range*floor(*val/range);}
|
---|
[2601] | 120 | inline void InRange(double &val,double range)
|
---|
| 121 | {val-=range*floor(val/range);}
|
---|
| 122 |
|
---|
[1678] | 123 | inline void InRange(double *val,double range,double vmax)
|
---|
| 124 | {InRange(val,range); if(*val>vmax) *val-=range;}
|
---|
[2601] | 125 | inline 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 | */
|
---|
| 132 | inline double TrueJDfrMJD(double mjd) {return mjd + MJD0;}
|
---|
| 133 |
|
---|
| 134 | /*! \ingroup XAstroPack
|
---|
| 135 | \brief Compute MJD from true Julian day
|
---|
| 136 | */
|
---|
| 137 | inline double MJDfrTrueJD(double jd) {return jd - MJD0;}
|
---|
| 138 |
|
---|
[1682] | 139 | double MJDfrDate(double dy,int mn,int yr);
|
---|
[2601] | 140 |
|
---|
[1682] | 141 | void DatefrMJD(double mjd,double *dy,int *mn,int *yr);
|
---|
[2601] | 142 | inline void DatefrMJD(double mjd,double &dy,int &mn,int &yr)
|
---|
| 143 | {DatefrMJD(mjd,&dy,&mn,&yr);}
|
---|
| 144 |
|
---|
[1682] | 145 | double YearfrMJD(double mjd);
|
---|
[2601] | 146 |
|
---|
[1682] | 147 | double MJDfrYear(double yr);
|
---|
[2601] | 148 |
|
---|
[1682] | 149 | void YDfrMJD(double mjd,double *dy,int *yr);
|
---|
[2601] | 150 | inline void YDfrMJD(double mjd,double &dy,int &yr)
|
---|
| 151 | {YDfrMJD(mjd,&dy,&yr);}
|
---|
| 152 |
|
---|
[1682] | 153 | int IsLeapYear(int y);
|
---|
[2601] | 154 |
|
---|
[1682] | 155 | int DayOrder(double mjd,int *dow);
|
---|
[2601] | 156 | inline int DayOrder(double mjd,int &dow)
|
---|
| 157 | {return DayOrder(mjd,&dow);}
|
---|
| 158 |
|
---|
[1682] | 159 | int DaysInMonth(double mjd);
|
---|
| 160 | double MJDat0hFrMJD(double mjd);
|
---|
| 161 | double HfrMJD(double mjd);
|
---|
| 162 | double GSTfrUTC(double mjd0,double utc);
|
---|
| 163 | double 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 | */
|
---|
| 170 | inline double LSTfrGST(double gst,double geolng)
|
---|
| 171 | {double lst = gst + deghr(geolng); InRange(&lst,24.); return lst;}
|
---|
| 172 |
|
---|
| 173 | double GST0(double mjd0);
|
---|
| 174 | double LSTfrMJD(double mjd,double geolng);
|
---|
[2601] | 175 |
|
---|
[1679] | 176 | void HMSfrHdec(double hd,int *h,int *mn,double *s);
|
---|
[2601] | 177 | inline void HMSfrHdec(double hd,int &h,int &mn,double &s)
|
---|
| 178 | {HMSfrHdec(hd,&h,&mn,&s);}
|
---|
| 179 |
|
---|
[1679] | 180 | double HdecfrHMS(int h,int mn,double s);
|
---|
| 181 | string ToStringHMS(int h,int mn,double s);
|
---|
| 182 | string ToStringHdec(double hd);
|
---|
| 183 |
|
---|
| 184 | // ------------------- Calculs Divers -------------------
|
---|
| 185 | void Precess(double mjd1,double mjd2,double ra1,double dec1,double *ra2,double *dec2);
|
---|
[2601] | 186 | inline void Precess(double mjd1,double mjd2,double ra1,double dec1,double &ra2,double &dec2)
|
---|
| 187 | {Precess(mjd1,mjd2,ra1,dec1,&ra2,&dec2);}
|
---|
| 188 |
|
---|
[1720] | 189 | inline 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] | 193 | inline 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] | 198 | double AirmassfrAlt(double alt);
|
---|
| 199 | double 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)
|
---|
| 210 | inline 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 | */
|
---|
| 218 | inline double RafrHaTS(double lst,double ha)
|
---|
| 219 | {double ra = lst - ha; InRange(&ra,24.); return ra;}
|
---|
| 220 |
|
---|
| 221 | void EqtoGal(double mjd,double ra,double dec,double *glng,double *glat);
|
---|
[2601] | 222 | inline void EqtoGal(double mjd,double ra,double dec,double &glng,double &glat)
|
---|
| 223 | {EqtoGal(mjd,ra,dec,&glng,&glat);}
|
---|
| 224 |
|
---|
| 225 |
|
---|
[1679] | 226 | void GaltoEq(double mjd,double glng,double glat,double *ra,double *dec);
|
---|
[2601] | 227 | inline void GaltoEq(double mjd,double glng,double glat,double &ra,double &dec)
|
---|
| 228 | {GaltoEq( mjd, glng, glat, &ra, &dec);}
|
---|
| 229 |
|
---|
[1679] | 230 | void EqHtoHor(double geolat,double ha,double dec,double *az,double *alt);
|
---|
[2601] | 231 | inline void EqHtoHor(double geolat,double ha,double dec,double &az,double &alt)
|
---|
| 232 | {EqHtoHor( geolat, ha, dec, &az, &alt);}
|
---|
| 233 |
|
---|
[1679] | 234 | void HortoEqH(double geolat,double az,double alt,double *ha,double *dec);
|
---|
[2601] | 235 | inline void HortoEqH(double geolat,double az,double alt,double &ha,double &dec)
|
---|
| 236 | {HortoEqH( geolat, az, alt, &ha, &dec);}
|
---|
| 237 |
|
---|
[1679] | 238 | void EqtoHor(double geolat,double lst,double ra,double dec,double *az,double *alt);
|
---|
[2601] | 239 | inline void EqtoHor(double geolat,double lst,double ra,double dec,double &az,double &alt)
|
---|
| 240 | {EqtoHor( geolat, lst, ra, dec, &az, &alt);}
|
---|
| 241 |
|
---|
[1679] | 242 | void HortoEq(double geolat,double lst,double az,double alt,double *ra,double *dec);
|
---|
[2601] | 243 | inline void HortoEq(double geolat,double lst,double az,double alt,double &ra,double &dec)
|
---|
| 244 | {HortoEq( geolat, lst, az, alt, &ra, &dec);}
|
---|
| 245 |
|
---|
[1679] | 246 | void EqtoEcl(double mjd,double ra,double dec,double *eclng,double *eclat);
|
---|
[2601] | 247 | inline void EqtoEcl(double mjd,double ra,double dec,double &eclng,double &eclat)
|
---|
| 248 | {EqtoEcl( mjd, ra, dec, &eclng, &eclat);}
|
---|
| 249 |
|
---|
[1679] | 250 | void EcltoEq(double mjd,double eclng,double eclat,double *ra,double *dec);
|
---|
[2601] | 251 | inline 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 -------------------
|
---|
| 255 | void SunPos(double mjd,double *eclsn,double *ecbsn,double *rsn);
|
---|
[2601] | 256 | inline void SunPos(double mjd,double &eclsn,double &ecbsn,double &rsn)
|
---|
| 257 | {SunPos( mjd, &eclsn, &ecbsn, &rsn);}
|
---|
| 258 |
|
---|
[1679] | 259 | void MoonPos(double mjd,double *lmn,double *bmn,double *rho);
|
---|
[2601] | 260 | inline void MoonPos(double mjd,double &lmn,double &bmn,double &rho)
|
---|
| 261 | {MoonPos( mjd, &lmn, &bmn, &rho);}
|
---|
| 262 |
|
---|
[2552] | 263 | void 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] | 266 | inline 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] | 274 | inline 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] | 280 | inline 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 | */
|
---|
| 290 | inline void JupiterPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
| 291 | {
|
---|
| 292 | PlanetPos(mjd,JUPITER,ecl,ecb,geodist,diamang);
|
---|
| 293 | }
|
---|
[2601] | 294 | inline 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 | */
|
---|
| 302 | inline void SaturnPos(double mjd,double *ecl,double *ecb,double *geodist,double *diamang)
|
---|
| 303 | {
|
---|
| 304 | PlanetPos(mjd,SATURN,ecl,ecb,geodist,diamang);
|
---|
| 305 | }
|
---|
[2601] | 306 | inline 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
|
---|