Skip to content

Commit

Permalink
🚨 Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronan Arraes Jardim Chagas authored and Ronan Arraes Jardim Chagas committed Sep 26, 2024
1 parent d8b95b9 commit fce8a4a
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions test/gravity_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@
#
############################################################################################

# == File: ./src/GravityModels/api.jl ======================================================

@testset "API" verbose = true begin
dt_J2000 = DateTime("2000-01-01T12:00:00.000")

# We will fetch the EIGEN-6C model that has time dependent coefficients.
eigen6c_file = fetch_icgem_file(
"http://icgem.gfz-potsdam.de/getmodel/gfc/0776caed6c65af24051697a65147b59e436cb464cb0930c1863fee6ecfbc31b0/EIGEN-6C.gfc"
)

eigen6c = GravityModels.load(IcgemFile, eigen6c_file)

time = Dates.value(DateTime("2023-06-19") - dt_J2000) / 1000

Clm_expected, Slm_expected = GravityModels.coefficients(eigen6c, 2, 2, time)
Clm, Slm = GravityModels.coefficients(eigen6c, 2, 2, DateTime("2023-06-19"))

@test Clm == Clm_expected
@test Slm == Slm_expected

Clm_expected, Slm_expected = GravityModels.coefficients(eigen6c, 2, 2, 0)
Clm, Slm = GravityModels.coefficients(eigen6c, 2, 2)

@test Clm == Clm_expected
@test Slm == Slm_expected
end

# == File: ./src/GravityModels/accelerations.jl ============================================

# TODO: Add tests with a model that has time-varying coefficients.
Expand Down Expand Up @@ -79,8 +106,31 @@ end

# == File: ./src/GravityModels/gravitational_field_derivative.jl ===========================

# NOTE: We can skip the gravitational field derivative tests because it is indirectly tested
# in the previous sections.
# NOTE: We can skip most of the gravitational field derivative tests because it is
# indirectly tested in the previous sections.

@testset "Gravity Field Derivative" verbose = true begin
dt_J2000 = DateTime("2000-01-01T12:00:00.000")

# We will fetch the EIGEN-6C model that has time dependent coefficients.
eigen6c_file = fetch_icgem_file(
"http://icgem.gfz-potsdam.de/getmodel/gfc/0776caed6c65af24051697a65147b59e436cb464cb0930c1863fee6ecfbc31b0/EIGEN-6C.gfc"
)

eigen6c = GravityModels.load(IcgemFile, eigen6c_file)
r_itrf = [7000.0e3, 0, 0]

time = Dates.value(DateTime("2023-06-19") - dt_J2000) / 1000
∂U_∂r_expected, ∂U_∂ϕ_expected, ∂U_∂λ_expected =
GravityModels.gravitational_field_derivative(eigen6c, r_itrf, time)

∂U_∂r, ∂U_∂ϕ, ∂U_∂λ =
GravityModels.gravitational_field_derivative(eigen6c, r_itrf, DateTime("2023-06-19"))

@test ∂U_∂r == ∂U_∂r_expected
@test ∂U_∂ϕ == ∂U_∂ϕ_expected
@test ∂U_∂λ == ∂U_∂λ_expected
end

@testset "Gravity Field Derivative [ERRORS]" verbose = true begin
egm96 = GravityModels.load(IcgemFile, fetch_icgem_file(:EGM96))
Expand Down

0 comments on commit fce8a4a

Please sign in to comment.