Giter Club home page Giter Club logo

astro-rust's People

Contributors

liamdawson avatar manguluka avatar mhaessig avatar saurvs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astro-rust's Issues

Decimal Day implementation incorrect?

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.

How to calculate sunset?

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!

Compute topocentric az/el of celestial body from Earth

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.

Compute topocentric az/el of planet from Earth

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.

Use VSOP87 crate

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!

dec_frm_hz() incorrect

Correct impl is:

(
observer_lat.sin() * alt.sin()
- observer_lat.cos() * alt.cos() * az.cos()
).asin()

decimal_day is broken

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);
}

Feature request: TLE support

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.

Differences between astro-rust and ERFA in AltAz -> (Hour angle, Dec) conversion

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.