项目作者: saurvs

项目描述 :
Astronomical algorithms in Rust
高级语言: Rust
项目地址: git://github.com/saurvs/astro-rust.git
创建时间: 2015-11-06T17:59:11Z
项目社区:https://github.com/saurvs/astro-rust

开源协议:MIT License

下载


astro-rust

Contents

API Docs

About

astro-rust is a library of advanced astronomical algorithms for the Rust programming language.

Implemented algorithms include:

  • planetary and solar positioning by the complete set of elements of Bretagnon and Francou’s VSP087 theory
  • lunar positioning by the principle elements of Chapront’s ELP-2000/82 theory
  • satellite positioning for Saturn and Jupiter
  • finding Julian dates, sidereal time, dynamical time, equinoxes, rising and setting times, times of lunar phases
  • coordinate transformations
  • corrections for precession, nutation, parallax, aberration, atmospheric refraction
  • calculation of the physical ephemeris for Mars, Jupiter, and the rings of Saturn
  • finding position angles, illuminated fractions, visual magnitudes
  • and much more.

Usage

  • Add the dependency astro in your Cargo.toml

    1. [dependencies]
    2. astro = "2.0.0"
  • Include the crate astro in your code

    1. extern crate astro;
    2. use astro::*;
  • Specify your time of interest using the Julian day

    1. // for example, the time of the Apollo 11 moon landing
    2. let day_of_month = time::DayOfMonth{day : 20,
    3. hr : 20,
    4. min : 18,
    5. sec : 4.0,
    6. time_zone: 0.0};
    7. let date = time::Date{year : 1969,
    8. month : 7, // July
    9. decimal_day: time::decimal_day(&day_of_month),
    10. cal_type : time::CalType::Gregorian};
    11. let julian_day = time::julian_day(&date);
    12. // for higher accuracy in specifying the time of interest,
    13. // find the Julian Ephemeris day; this slightly differs from
    14. // the Julian day by ΔT, which is usually a few seconds. you
    15. // can get a reported value of it from the Astronomical
    16. // Almanac, or calculate it using the built-in function
    17. let delta_t = time::delta_t(date.year, date.month);
    18. let julian_ephm_day = time::julian_ephemeris_day(julian_day, delta_t);
  • Find the position of the Sun and the Moon with respect to the Earth

    1. // geocentric ecliptic point and radius vector of the Sun
    2. let (sun_ecl_point, rad_vec_sun) = sun::geocent_ecl_pos(julian_day);
    3. // sun_ecl_point.long - ecliptic longitude (radians)
    4. // sun_ecl_point.lat - ecliptic latitude (radians)
    5. // rad_vec_sun - distance between the Sun and the Earth (AU)
    6. // and similarly for the Moon
    7. let (moon_ecl_point, rad_vec_moon) = lunar::geocent_ecl_pos(julian_day);
  • Find the position of a planet with respect to the Sun

    1. // the heliocentric point and radius vector of a planet, like Jupiter
    2. let (jup_long, jup_lat, rad_vec) = planet::heliocent_pos(&planet::Planet::Jupiter, julian_day);
    3. // or neptune
    4. let (nep_long, nep_lat, rad_vec) = planet::heliocent_pos(&planet::Planet::Neptune, julian_day);
    5. // positioning for all the eight planets (and (the dwarf planet) Pluto) is supported
    6. let (plut_long, plut_lat, rad_vec) = pluto::heliocent_pos(julian_day);
  • Find the geodesic distance between two locations on Earth

    1. // geodesic distance between the Observatoire de Paris and
    2. // the US Naval Observatory at Washington DC
    3. let paris = coords::GeographPoint{long: angle::deg_frm_dms(-2, 20, 14.0).to_radians(),
    4. lat : angle::deg_frm_dms(48, 50, 11.0).to_radians()};
    5. let washington = coords::GeographPoint{long: angle::deg_frm_dms(77, 3, 56.0).to_radians(),
    6. lat : angle::deg_frm_dms(38, 55, 17.0).to_radians()};
    7. // angle::deg_frm_dms() converts degrees expressed in degrees,
    8. // minutes and seconds into a fractional degree
    9. let distance = planet::earth::geodesic_dist(&paris, &washington); // in meters
  • Convert equatorial coordinates to ecliptic coordinates

    1. // equatorial coordinates of the star Pollux
    2. let right_ascension = 116.328942_f64.to_radians();
    3. let declination = 28.026183_f64.to_radians();
    4. // mean obliquity of the ecliptic
    5. let oblq_eclip = 23.4392911_f64.to_radians();
    6. // you can also get oblq_eclip from ecliptic::mn_oblq_IAU(julian_day)
    7. // for the Julian day on which the coordinates of the star
    8. // were observed
    9. // also make sure to type #[macro_use] before including the crate
    10. // to use macros
    11. // now, convert equatorial coordinates to ecliptic coordinates
    12. let (ecl_long, ecl_lat) = ecl_frm_eq!(right_ascension, declination, oblq_eclip);
  • Convert equatorial coordinates to galactic coordinates

    1. // equatorial coordinates of the Nova Serpentis 1978
    2. let right_ascension = angle::deg_frm_hms(17, 48, 59.74).to_radians();
    3. let declination = angle::deg_frm_dms(-14, 43, 8.2).to_radians();
    4. // convert to galactic coordinates
    5. let (gal_long, gal_lat) = gal_frm_eq!(right_ascension, declination);
  • Correct for nutation in different coordinate systems

    1. // nutation in ecliptic longitude and obliquity of the ecliptic
    2. let (nut_in_long, nut_in_oblq) = nutation::nutation(julian_day);
    3. // nutation in equatorial coordinates
    4. let (nut_in_asc, nut_in_dec) = nutation::nutation_in_eq_coords(julian_day);

Contributing

Anyone interested to contribute in any way possible is encouraged to do so. Not all the algorithms in Meeus’s book have been implemented yet. Documentation and tests need to be written for them as well. Refactored code and minor optimizations for the existing code are also welcome.

The end goal (of this project) is to build a modern, well-tested, well-documented library of algorithms for future use in astronomy. And Rust is very much the right choice for building that.

A fun suggestion is the addition of the recent IAU 2000/2006 precession-nutation model. This method improves upon the existing model implemented here “by taking into account the effect of mantle anelasticity, ocean tides, electromagnetic couplings produced between the fluid outer core and the mantle as well as between the solid inner core and fluid outer core”.

References

The main reference used as the source of algorithms is the famous book Astronomical Algorithms by Jean Meeus, whose almost every chapter has been addressed here, with functions that are well-documented and tests that use example data from the book; in some cases, such as ΔT approximation and planetary heliocentric positioning, more accurate methods have been implemented.