Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert between HJD <-> BJD? #49

Open
icweaver opened this issue Jul 6, 2021 · 2 comments
Open

Convert between HJD <-> BJD? #49

icweaver opened this issue Jul 6, 2021 · 2 comments

Comments

@icweaver
Copy link
Member

icweaver commented Jul 6, 2021

Hi,

Awesome package, thanks for all of your work! I am slowly migrating some routines in Python over to Julia and was wondering if there was already a way to convert between HJD <-> BJD, similarly to the astropy snippet I found here? https://gist.github.com/StuartLittlefair/4ab7bb8cf21862e250be8cb25f72bb7a

from astropy.coordinates import SkyCoord, EarthLocation
from astropy import units as u
from astropy.time import Time

def helio_to_bary(coords, hjd, obs_name):
    helio = Time(hjd, scale='utc', format='jd')
    obs = EarthLocation.of_site(obs_name)
    star = SkyCoord(coords, unit=(u.hour, u.deg)) 
    ltt = helio.light_travel_time(star, 'heliocentric', location=obs)
    guess = helio - ltt
    # if we assume guess is correct - how far is heliocentric time away from true value?
    delta = (guess + guess.light_travel_time(star, 'heliocentric', obs)).jd  - helio.jd
    # apply this correction
    guess -= delta * u.d

    ltt = guess.light_travel_time(star, 'barycentric', obs)
    return guess.tdb + ltt

def bary_to_helio(coords, bjd, obs_name):
    bary = Time(bjd, scale='tdb', format='jd')
    obs = EarthLocation.of_site(obs_name)
    star = SkyCoord(coords, unit=(u.hour, u.deg))
    ltt = bary.light_travel_time(star, 'barycentric', location=obs) 
    guess = bary - ltt
    delta = (guess + guess.light_travel_time(star, 'barycentric', obs)).jd  - bary.jd
    guess -= delta * u.d
    
    ltt = guess.light_travel_time(star, 'heliocentric', obs)
    return guess.utc + ltt

which for example would return something like this:

> helio_to_bary("1:12:43.2 +31:12:43", 2457681.00027, "CTIO")
<Time object: scale='tdb' format='jd' value=2457681.0010844585>

Sorry if this is the wrong place to ask this!

@helgee
Copy link
Member

helgee commented Jul 8, 2021

Hi!

This is the right place for your question 👍

AstroTime.jl alone will probably never support this because we need an ephemeris for the conversion. AstroBase.jl however could...

Shall I transfer the issue over there?

@icweaver
Copy link
Member Author

icweaver commented Jul 8, 2021

Ah, ok. That would be great, thanks!

@helgee helgee transferred this issue from JuliaAstro/AstroTime.jl Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants