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

add EclipticCoords #46

Merged
merged 3 commits into from
Feb 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add tests
  • Loading branch information
aplavin committed Jan 13, 2023
commit 04d50388a7d7dacd0d8238116e3df423d1bff370
16 changes: 9 additions & 7 deletions test/astropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const lats = pi .* (rand(rng, N) .- 0.5) # (-π, π)
astropy_conversion(::Type{<:ICRSCoords}) = apc.ICRS
astropy_conversion(::Type{<:FK5Coords{F}}) where {F} = apc.FK5(equinox="J$F")
astropy_conversion(::Type{<:GalCoords}) = apc.Galactic
astropy_conversion(::Type{<:EclipticCoords{F}}) where {F} = apc.GeocentricMeanEcliptic(equinox="J$F")

function test_against_astropy(intype, outtype)
function test_against_astropy(intype, outtype; atol=0)
## get julia values
output_coords = map((lon, lat) -> convert(outtype, intype(lon, lat)), lons, lats)
output_lons = map(lon, output_coords)
Expand All @@ -28,8 +29,8 @@ function test_against_astropy(intype, outtype)
ap_output_lons = pyconvert(Vector, output_coord_list.spherical.lon.rad)
ap_output_lats = pyconvert(Vector, output_coord_list.spherical.lat.rad)

@test output_lons ≈ ap_output_lons
@test output_lats ≈ ap_output_lats
@test output_lons ≈ ap_output_lons atol=atol*√N
@test output_lats ≈ ap_output_lats atol=atol*√N

end

Expand All @@ -47,10 +48,11 @@ end
FK5Coords{2000,F},
FK5Coords{1975,F},
GalCoords{F},
EclipticCoords{2000,F},
EclipticCoords{1975,F},
)

@testset "$IN_SYS --> $OUT_SYS"for IN_SYS in systems, OUT_SYS in systems
test_against_astropy(IN_SYS, OUT_SYS)

@testset "$IN_SYS --> $OUT_SYS" for IN_SYS in systems, OUT_SYS in systems
atol = IN_SYS <: EclipticCoords || OUT_SYS <: EclipticCoords ? 1e-3 : 0
test_against_astropy(IN_SYS, OUT_SYS; atol)
end
end