saurvs / astro-rust Goto Github PK
View Code? Open in Web Editor NEWAstronomical algorithms in Rust
Home Page: https://saurvs.github.io/astro-rust/
License: MIT License
Astronomical algorithms in Rust
Home Page: https://saurvs.github.io/astro-rust/
License: MIT License
The existing code in decimal_day is incorrect. It doesn't divide minutes by minutes/day, but by minutes per hour, and seconds not by seconds/day but by seconds/minute.
Corrected version:
fn decimal_day(day: &astro::time::DayOfMonth) -> f64 {
(day.day as f64)
+ (day.hr as f64) / 24.0
+ (day.min as f64) / (60.0 * 24.0)
+ day.sec / (60.0 * 60.0 * 24.0)
- day.time_zone / 24.0
}
With this fix, the following program will print the correct Julian Ephemeris Date for UTC now.
extern crate astro;
extern crate chrono;
use chrono::prelude::*;
fn decimal_day(day: &astro::time::DayOfMonth) -> f64 {
(day.day as f64)
+ (day.hr as f64) / 24.0
+ (day.min as f64) / (60.0 * 24.0)
+ day.sec / (60.0 * 60.0 * 24.0)
- day.time_zone / 24.0
}
fn tm_to_date(now: DateTime<Utc>) -> astro::time::Date
{
let day_of_month = astro::time::DayOfMonth {
day : now.day() as u8,
hr : now.hour() as u8,
min : now.minute() as u8,
sec : 0f64,//now.second() as f64,
time_zone : 0.0 };
astro::time::Date {
year : now.year() as i16,
month : now.month() as u8,
decimal_day : decimal_day(&day_of_month),
cal_type : astro::time::CalType::Gregorian }
}
fn now_utc() -> astro::time::Date
{
let utc: DateTime<Utc> = Utc::now();
println!("{:?}", utc);
tm_to_date(utc)
}
fn main() {
let date = now_utc();
let julian_day = astro::time::julian_day(&date);
let delta_t = astro::time::delta_t(date.year as i32, date.month);
let julian_ephm_day = astro::time::julian_ephemeris_day(julian_day, delta_t);
println!("{}", julian_ephm_day);
}
impl is currently:
green_sidreal - observer_long - asc
it should be:
green_sidreal + observer_long - asc
Very nice library!
It would be awesome to see TLE support in this library so it can be used for tracking satellites.
Currently rust-gpredict can be used for that, however it relies on C libgpredict. It would be better to use rust native library.
Hello, first of all, thank you for your hard work on this library!
I hope this bug report helps you improve it. If you'd like a pull request for this simple change I can do that too.
Specifically, I am observing inconsistencies with the decimal_day
function.
The decimal_day
you expect in astro::time::Date
is in the range [1.0, 31.0] (it's the decimal day of the month), however, in the source for astro::time::decimal_day
, the divisors for minute and second are incorrect for "minutes of the hour" and "seconds of the minute". Each of these values are only divided by 60. This leads to a drastically incorrect decimal day where minute and second are large. It seems to me that the correct divisors should be (60.0 * 24.0)
for minutes and (60.0 * 60.0 * 24.0)
for seconds.
This is only my initial take, I am no expert in the field, but as a user of this library this was confusing, so if this is intended functionality then it might be a good idea to make a documentation change.
The server seems to be not working anymore: https://downforeveryoneorjustme.com/62.161.69.131 .
Correct impl is:
(
observer_lat.sin() * alt.sin()
- observer_lat.cos() * alt.cos() * az.cos()
).asin()
I was wondering if I can use this project to compute the topocentric azimuth and elevation of a planet/celestial body on Earth. Given that I don't have a lot of astronomy expertise, I'm not sure where to start after reading the documentation.
It would make debugging easier (e.g. confirming values are correct for used structs) if the structs in this crate derived the Debug trait. :)
I'm trying to use this library to calculate sunset times for locations on Earth on a given date but I don't have a background in astronomy and I can't figure out how to calculate four of the values needed as input to the astro::transit::time
function. Here's what I have so far:
extern crate astro;
extern crate chrono;
use astro::coords::GeographPoint;
use astro::time;
use astro::transit::{self, TransitBody, TransitType};
use chrono::{Datelike, Timelike, UTC};
fn main() {
let coords: (f64, f64) = (40.7128, -74.0059); // GPS coords of New York City
let now = UTC::now();
let day_of_month = time::DayOfMonth {
day: now.day() as u8,
hr: now.hour() as u8,
min: now.minute() as u8,
sec: now.second() as f64,
time_zone: 0.0,
};
let date = time::Date {
year: now.year() as i16,
month: now.month() as u8,
decimal_day: time::decimal_day(&day_of_month),
cal_type: time::CalType::Gregorian,
};
let julian_day = time::julian_day(&date);
let delta_t = time::delta_t(date.year as i32, date.month);
let julian_ephm_day = time::julian_ephemeris_day(julian_day, delta_t);
let sunset_time = astro::transit::time(&TransitType::Set,
&TransitBody::Sun,
&GeographPoint {
lat: coords.0.to_radians(),
long: coords.1.to_radians(),
},
// How do I calculate the next four args?
eq_point1,
eq_point2,
eq_point3,
apprnt_greenwhich_sidr,
// End of missing args
delta_t,
0f64); // moon_eq_hz_parallax not needed
println!("{:?}", sunset_time);
}
Any pointers would be greatly appreciated. Thanks!
Hi! I want to use this library, but I noticed some differences with others (notably ERFA https://github.com/liberfa/erfa). I didn't go through the differences in the mathematics, but I did do a quick comparison in python by converting both the C and rust codes: https://gist.github.com/cjordan/d0909a3ed4e726e720d99761dfa6591f
In the rust code, it looks like a az.cos() needs to be changed to alt.cos(), as well as changing a couple of signs. I wanted to raise this as an issue in case I'm being naive here and this is working as intended. If these changes should be applied to the code, then I'm happy to give a PR to fix them.
Also, if I require both the hour angle and declination from a AltAz pair, would it make sense to make another function to provide both? I would be using such a function in a hot loop.
I was wondering if I can use this project to compute the topocentric azimuth and elevation of a planet/celestial body on Earth. Given that I don't have a lot of astronomy expertise, I'm not sure where to start after reading the documentation.
Hi there,
I just found out about astro-rust, and I wanted to let you know about the VSOP87 crate. I think it could be useful, since it can be used for almost anything related to planetary positions. I have seen that you already calculate those things, but I haven gotten into depth.
I hope you find it useful!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.