JuliaSpace / SatelliteToolbox.jl

A toolbox for satellite analysis written in julia language.
MIT License
249 stars 33 forks source link

Missing nutation_fk5 method? #44

Closed PerezHz closed 3 years ago

PerezHz commented 3 years ago

Hi @ronisbr! This is an awesome package! I'm using nutation_fk5 to compute some reductions; nutation_fk5 takes Julian dates as an input, i.e. currently there is nutation_fk5(JD_TT::Number), where JD_TT represents a Julian date (TT):

https://github.com/JuliaSpace/SatelliteToolbox.jl/blob/e4b2610c71cb05d0cae28755ed22fce4c85ecb03/src/transformations/fk5/nutation.jl#L183

I was wondering if there is another method for nutation_fk5 which takes "days since J2000" instead as input? If there is no such method, I'd be happy to add it! In that case, would you guys accept such a PR?

helgee commented 3 years ago

Not @ronisbr 😄 but there is such a method in AstroBase.jl: https://github.com/JuliaAstro/AstroBase.jl/blob/master/src/EarthAttitude/nutation.jl#L150

It takes an Epoch struct from AstroTime.jl as an argument, e.g. nutation(iau1980, TTEpoch(1000days; origin=:j2000)).

Sadly AstroBase.jl is still unregistered (because my day job revolves around C++ 🙄 ) so it would not hurt to have it here as well. But at some point we will want to start deduplicating...

ronisbr commented 3 years ago

Hi @ronisbr! This is an awesome package!

Hi @PerezHz ! Nice! I am glad it is being useful :)

I'm using nutation_fk5 to compute some reductions; nutation_fk5 takes Julian dates as an input, i.e. currently there is nutation_fk5(JD_TT::Number), where JD_TT represents a Julian date (TT):

https://github.com/JuliaSpace/SatelliteToolbox.jl/blob/e4b2610c71cb05d0cae28755ed22fce4c85ecb03/src/transformations/fk5/nutation.jl#L183

I was wondering if there is another method for nutation_fk5 which takes "days since J2000" instead as input? If there is no such method, I'd be happy to add it! In that case, would you guys accept such a PR?

I've never bothered to add such a specialization because nutation_fk5 for me was always a low-level function to compute the transformations. The functions rECEFtoECEF, rECItoECEF, rECEFtoECI, and rECItoECI can compute all the possible conversions between the reference systems of IAU 1980.

However, if you want to use, for example, days since J2000, you can do the following:

julia> nutation_fk5( JD_UTCtoTT(1000 - JD_J2000) )

which will compute the nutation parameters for the 1000th day after J2000 epoch. You can also specify the date in the Gregorian calendar using:

julia> nutation_fk5( JD_UTCtoTT(DatetoJD(2020,6,19,18,35,0)) )
(0.4090463509288958, -2.0335288629841028e-6, -8.439439860739239e-5)

Is it OK for you or do you still need some specialization of those functions?

Not @ronisbr 😄 but there is such a method in AstroBase.jl: https://github.com/JuliaAstro/AstroBase.jl/blob/master/src/EarthAttitude/nutation.jl#L150

It takes an Epoch struct from AstroTime.jl as an argument, e.g. nutation(iau1980, TTEpoch(1000days; origin=:j2000)).

Sadly AstroBase.jl is still unregistered (because my day job revolves around C++ 🙄 ) so it would not hurt to have it here as well. But at some point we will want to start deduplicating...

Thanks for the alternative answer @helgee ! In fact, when I had a spare time, I really need to add an interface to AstroTime.jl in my package. Maybe I will keep the current interface (which you pass Julian day in UTC as a float number) and use AstroTime.jl under the hood.

helgee commented 3 years ago

Thanks for the alternative answer @helgee ! In fact, when I had a spare time, I really need to add an interface to AstroTime.jl in my package. Maybe I will keep the current interface (which you pass Julian day in UTC as a float number) and use AstroTime.jl under the hood.

This is a good way forward. At some point in the future these thin wrappers could then be deprecated 👍

PerezHz commented 3 years ago

Thanks guys for your suggestions!

In a nutshell, what I'm actually trying to do is:

rECEFtoECI(DCM, ITRF(), GCRF(), jd, eop_IAU1980)

Where jd is a Julian date, represented as a Taylor1 from TaylorSeries.jl. I was having some trouble making it work, so I was constructing manually the transformation starting from nutation_fk5, which accepts Taylor1 without complaint. But after adding some overloads for Taylor1, it works!

@ronisbr: I'm wondering if there are methods of rECEFtoECI which accept a two-part date, say, jd1, jd2, where the original Julian date is jd = jd1 + jd2? I understand this helps accuracy sometimes?

@helgee: do you think I could use the methods from AstroBase.jl where the time is represented by numeric types such as Taylor1? Would it be possible to do e.g.:

using AstroTime, TaylorSeries
t = 1000 + Taylor1(5)
TTEpoch(t; origin=:j2000)

and pass that to nutation?

Otherwise, please feel free to close this issue and sorry for the noise 😅

helgee commented 3 years ago

@helgee: do you think I could use the methods from AstroBase.jl where the time is represented by numeric types such as Taylor1?

As of now, no. But good to know that you have this requirement 👍 I will adjust the API accordingly.

EDIT: Regarding the two-part Julian date. The calculation is usually just something like jd1 - JD2000 + jd2 so maybe you could also handle it on your end?

PerezHz commented 3 years ago

EDIT: Regarding the two-part Julian date. The calculation is usually just something like jd1 - JD2000 + jd2 so maybe you could also handle it on your end?

Sure, thanks! I could definitely do that!

PerezHz commented 3 years ago

As of now, no. But good to know that you have this requirement 👍 I will adjust the API accordingly.

That would be a really nice thing to have!

I'll close this issue, since the original issue was resolved. Thanks again guys!