Skip to content

Commit

Permalink
Add missing missing wrappers (#61)
Browse files Browse the repository at this point in the history
* Add atcc13, atccq, moon98

* Fix docs

* Bump version

* Update CI
  • Loading branch information
helgee authored Jul 28, 2021
1 parent d3d5e92 commit ea9fbf7
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.3' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "ERFA"
uuid = "17511681-8477-586a-8d98-4cfd5a1f2ec3"
version = "1.0.0"
version = "1.1.0"

[deps]
ERFA_jll = "a00367d1-88f1-52c5-9c6b-193aa5f849e1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
ERFA_jll = "1.7"
julia = "1.3"
ERFA_jll = "2"
julia = "1.6"

[extras]
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand Down
1 change: 1 addition & 0 deletions src/ERFA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include("h.jl")
include("i.jl")
include("j.jl")
include("l.jl")
include("m.jl")
include("n.jl")
include("o.jl")
include("p.jl")
Expand Down
138 changes: 138 additions & 0 deletions src/a.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,144 @@ function apio13(utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tk, rh, wl)
return astrom
end

"""
atcc13(rc, dc, pr, pd, px, rv, date1, date2)
Transform a star's ICRS catalog entry (epoch J2000.0) into ICRS
astrometric place.
### Given ###
- `rc`: ICRS right ascension at J2000.0 (radians, Note 1)
- `dc`: ICRS declination at J2000.0 (radians, Note 1)
- `pr`: RA proper motion (radians/year, Note 2)
- `pd`: Dec proper motion (radians/year)
- `px`: parallax (arcsec)
- `rv`: radial velocity (km/s, +ve if receding)
- `date1`: TDB as a 2-part...
- `date2`: ...Julian Date (Note 3)
### Returned ###
- `ra`, `da`: ICRS astrometric RA,Dec (radians)
### Notes ###
1. Star data for an epoch other than J2000.0 (for example from the
Hipparcos catalog, which has an epoch of J1991.25) will require a
preliminary call to eraPmsafe before use.
2. The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt.
3. The TDB date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TDB)=2450123.7 could be expressed in any of these ways, among
others:
| `date1` | `date2` | Method |
|:----------|:------------|:------------|
| 2450123.7 | 0.0 | JD |
| 2451545.0 | -1421.3 | J2000 |
| 2400000.5 | 50123.2 | MJD |
| 2450123.5 | 0.2 | date & time |
The JD method is the most natural and convenient to use in cases
where the loss of several decimal digits of resolution is
acceptable. The J2000 method is best matched to the way the
argument is handled internally and will deliver the optimum
resolution. The MJD method and the date & time methods are both
good compromises between resolution and convenience. For most
applications of this function the choice will not be at all
critical.
TT can be used instead of TDB without any significant impact on
accuracy.
### Called ###
- [`apci13`](@ref): astrometry parameters, ICRS-CIRS, 2013
- [`atccq`](@ref): quick catalog ICRS to astrometric
"""
function atcc13(rc, dc, pr, pd, px, rv, date1, date2)
ra = Ref{Cdouble}()
da = Ref{Cdouble}()
ccall((:eraAtcc13, liberfa), Cvoid,
(Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble,
Ref{Cdouble}, Ref{Cdouble}),
rc, dc, pr, pd, px, rv, date1, date2, ra, da)
return ra[], da[]
end

"""
atccq(rc, dc, pr, pd, px, rv, astrom)
Quick transformation of a star's ICRS catalog entry (epoch J2000.0)
into ICRS astrometric place, given precomputed star-independent
astrometry parameters.
Use of this function is appropriate when efficiency is important and
where many star positions are to be transformed for one date. The
star-independent parameters can be obtained by calling one of the
functions [`apci`](@ref), [`apci13`](@ref), [`apcg`](@ref), [`apcg13`](@ref),
[`apco`](@ref), [`apco13`](@ref), [`apcs`](@ref), [`apcs13`](@ref).
If the parallax and proper motions are zero the transformation has
no effect.
### Given ###
- `rc`, `dc`: ICRS RA,Dec at J2000.0 (radians)
- `pr`: RA proper motion (radians/year, Note 3)
- `pd`: Dec proper motion (radians/year)
- `px`: parallax (arcsec)
- `rv`: radial velocity (km/s, +ve if receding)
- `astrom`: Star-independent astrometry parameters:
- `pmt`: unchanged
- `eb`: unchanged
- `eh`: unchanged
- `em`: unchanged
- `v`: unchanged
- `bm1`: unchanged
- `bpn`: unchanged
- `along`: Longitude + s' (radians)
- `xp1`: Polar motion xp wrt local meridian (radians)
- `yp1`: Polar motion yp wrt local meridian (radians)
- `sphi`: Sine of geodetic latitude
- `cphi`: Cosine of geodetic latitude
- `diurab`: Magnitude of diurnal aberration vector
- `l`: "Local" Earth rotation angle (radians)
- `refa`: Refraction constant A (radians)
- `refb`: Refraction constant B (radians)
### Returned ###
- `ra`, `da`: ICRS astrometric RA,Dec (radians)
### Notes ###
1. All the vectors are with respect to BCRS axes.
2. Star data for an epoch other than J2000.0 (for example from the
Hipparcos catalog, which has an epoch of J1991.25) will require a
preliminary call to eraPmsafe before use.
3. The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt.
### Called ###
- [`pmpx`](@ref): proper motion and parallax
- [`c2s`](@ref): p-vector to spherical
- [`anp`](@ref): normalize angle into range 0 to 2pi
"""
function atccq(rc, dc, pr, pd, px, rv, astrom)
ra = Ref{Cdouble}()
da = Ref{Cdouble}()
ccall((:eraAtccq, liberfa), Cvoid,
(Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble,
Ref{ASTROM}, Ref{Cdouble}, Ref{Cdouble}),
rc, dc, pr, pd, px, rv, astrom, ra, da)
return ra[], da[]
end

"""
atci13(rc, dc, pr, pd, px, rv, date1, date2)
Expand Down
95 changes: 95 additions & 0 deletions src/m.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""
moon98(date1, date2)
Approximate geocentric position and velocity of the Moon.
n.b. Not IAU-endorsed and without canonical status.
### Given ###
- `date1`: TT date part A (Notes 1,4)
- `date2`: TT date part B (Notes 1,4)
### Returned ###
- `pv`: Moon p,v, GCRS (AU, AU/d, Note 5)
### Notes ###
1. The TT date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TT)=2450123.7 could be expressed in any of these ways, among
others:
| `date1` | `date2` | Method |
|:----------|:------------|:------------|
| 2450123.7 | 0.0 | JD |
| 2451545.0 | -1421.3 | J2000 |
| 2400000.5 | 50123.2 | MJD |
| 2450123.5 | 0.2 | date & time |
The JD method is the most natural and convenient to use in cases
where the loss of several decimal digits of resolution is
acceptable. The J2000 method is best matched to the way the
argument is handled internally and will deliver the optimum
resolution. The MJD method and the date & time methods are both
good compromises between resolution and convenience. The limited
accuracy of the present algorithm is such that any of the methods
is satisfactory.
2. This function is a full implementation of the algorithm
published by Meeus (see reference) except that the light-time
correction to the Moon's mean longitude has been omitted.
3. Comparisons with ELP/MPP02 over the interval 1950-2100 gave RMS
errors of 2.9 arcsec in geocentric direction, 6.1 km in position
and 36 mm/s in velocity. The worst case errors were 18.3 arcsec
in geocentric direction, 31.7 km in position and 172 mm/s in
velocity.
4. The original algorithm is expressed in terms of "dynamical time",
which can either be TDB or TT without any significant change in
accuracy. UT cannot be used without incurring significant errors
(30 arcsec in the present era) due to the Moon's 0.5 arcsec/sec
movement.
5. The result is with respect to the GCRS (the same as J2000.0 mean
equator and equinox to within 23 mas).
6. Velocity is obtained by a complete analytical differentiation
of the Meeus model.
7. The Meeus algorithm generates position and velocity in mean
ecliptic coordinates of date, which the present function then
rotates into GCRS. Because the ecliptic system is precessing,
there is a coupling between this spin (about 1.4 degrees per
century) and the Moon position that produces a small velocity
contribution. In the present function this effect is neglected
as it corresponds to a maximum difference of less than 3 mm/s and
increases the RMS error by only 0.4%.
### References ###
- Meeus, J., Astronomical Algorithms, 2nd edition, Willmann-Bell,
1998, p337.
- Simon, J.L., Bretagnon, P., Chapront, J., Chapront-Touze, M.,
Francou, G. & Laskar, J., Astron.Astrophys., 1994, 282, 663
### Called ###
- [`s2pv`](@ref): spherical coordinates to pv-vector
- [`pfw06`](@ref): bias-precession F-W angles, IAU 2006
- [`ir`](@ref): initialize r-matrix to identity
- [`rz`](@ref): rotate around Z-axis
- [`rx`](@ref): rotate around X-axis
- [`rxpv`](@ref): product of r-matrix and pv-vector
"""
function moon98(date1, date2)
pv = Array{Cdouble}(undef, 3, 2)
ccall((:eraMoon98, liberfa), Cvoid,
(Cdouble, Cdouble, Ptr{Cdouble}),
date1, date2, pv)
return cmatrix_to_array(pv)
end

33 changes: 33 additions & 0 deletions test/a.jl
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,39 @@ end
@test_throws ERFAException apio13(-1e9, 0.0, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
end

@testset "atcc13" begin
rc = 2.71
dc = 0.174
pr = 1e-5
pd = 5e-6
px = 0.1
rv = 55.0
date1 = 2456165.5
date2 = 0.401182685

ra, da = atcc13(rc, dc, pr, pd, px, rv, date1, date2)

@test ra 2.710126504531372384 atol=1e-12
@test da 0.1740632537628350152 atol=1e-12
end

@testset "atccq" begin
date1 = 2456165.5
date2 = 0.401182685
astrom, eo = apci13(date1, date2)
rc = 2.71
dc = 0.174
pr = 1e-5
pd = 5e-6
px = 0.1
rv = 55.0

ra, da = atccq(rc, dc, pr, pd, px, rv, astrom)

@test ra 2.710126504531372384 atol=1e-12
@test da 0.1740632537628350152 atol=1e-12
end

@testset "atci13" begin
rc = 2.71
dc = 0.174
Expand Down
11 changes: 11 additions & 0 deletions test/m.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@testset "moon98" begin
pv = moon98(2400000.5, 43999.9)

@test pv[1][1] -0.2601295959971044180e-2 atol=1e-11
@test pv[1][2] 0.6139750944302742189e-3 atol=1e-11
@test pv[1][3] 0.2640794528229828909e-3 atol=1e-11

@test pv[2][1] -0.1244321506649895021e-3 atol=1e-11
@test pv[2][2] -0.5219076942678119398e-3 atol=1e-11
@test pv[2][3] -0.1716132214378462047e-3 atol=1e-11
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ using Test
include("i.jl")
include("j.jl")
include("l.jl")
include("m.jl")
include("n.jl")
include("o.jl")
include("p.jl")
Expand Down

2 comments on commit ea9fbf7

@helgee
Copy link
Member Author

@helgee helgee commented on ea9fbf7 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/41670

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" ea9fbf78907d3b5a7aaeaa8624c66ddad66a83ce
git push origin v1.1.0

Please sign in to comment.