Skip to content

Commit

Permalink
Require Chron.jl v0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Jun 13, 2024
1 parent d8bc6bd commit f9880e2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SubsidenceChron"
uuid = "f7321fe0-76de-4184-b262-f3439fe138fd"
authors = ["Tianran Zhang", "C. Brenhin Keller"]
version = "0.3.2"
version = "0.4.0"

[deps]
Chron = "68885b1f-77b5-52a7-b2e7-6a8014c56b98"
Expand All @@ -15,7 +15,7 @@ StatGeochemBase = "61e559cd-58b4-4257-8528-26bb26ff2b9a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Chron = "0.4.15, 0.5"
Chron = "0.5"
Distributions = "0.15 - 0.25"
IfElse = "0.1"
LoopVectorization = "0.12"
Expand Down
12 changes: 12 additions & 0 deletions test/testCoupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ println("StratMetropolisDist:")
@test mdl.Age_975CI [66.1, 66.09, 66.09, 66.08, 66.08, 66.07, 66.06, 66.05, 66.03, 66.01, 65.97, 65.97, 65.96, 65.96, 65.95] atol=0.15
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test size(lldist) == (config.nsteps,)
@test !isnan(mean(lldist))

# Try adding systematic uncertainties too
smpl.Chronometer = (:UPb, :UPb, :ArAr, :UPb, :UPb)
Expand All @@ -67,6 +69,8 @@ println("StratMetropolisDist with systematic uncertainties:")
@test mdl.Age_975CI [66.1, 66.09, 66.09, 66.08, 66.08, 66.07, 66.06, 66.05, 66.03, 66.01, 65.97, 65.97, 65.96, 65.96, 65.95] atol=0.15
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test size(lldist) == (config.nsteps,)
@test !isnan(mean(lldist))

## --- As above, but with hiata

Expand All @@ -88,6 +92,10 @@ println("StratMetropolisDist with hiata:")
@test mdl.Age_975CI [66.11, 66.1, 66.1, 66.1, 66.1, 66.08, 66.08, 66.08, 66.08, 65.98, 65.96, 65.96, 65.96, 65.96, 65.95] atol=0.15
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test size(hiatusdist) == (nHiatuses, config.nsteps)
@test mean(hiatusdist, dims=2) [0.064; 0.061;;] atol=0.3
@test size(lldist) == (config.nsteps,)
@test !isnan(mean(lldist))

## --- As above, but treat everything as a gaussian/weighted mean

Expand All @@ -107,6 +115,8 @@ println("StratMetropolisDist with fitted Gaussians:")
@test mdl.Age_975CI [66.09, 66.09, 66.08, 66.08, 66.08, 66.07, 66.06, 66.05, 66.04, 66.02, 66.0, 65.99, 65.98, 65.97, 65.96] atol=0.15
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test size(lldist) == (config.nsteps,)
@test !isnan(mean(lldist))

## -- Test coupled with Isoplot.jl Pb-loss-aware eruption ages

Expand Down Expand Up @@ -154,3 +164,5 @@ println("StratMetropolisDist, Pb-loss-aware:")
@test mdl.Age_975CI [752.51, 752.47, 752.43, 752.37, 752.29, 752.2, 752.08, 751.85, 750.99] atol=0.7
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test size(lldist) == (config.nsteps,)
@test !isnan(mean(lldist))
16 changes: 9 additions & 7 deletions test/testStratOnly.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## --- Age-depth modelling only

# Make an instance of a ChronAgeData object for nSamples
nSamples = 4
smpl = ChronAgeData(nSamples)
Expand Down Expand Up @@ -28,11 +26,13 @@ config.sieve = round(Int,npoints_approx) # Record one out of every nsieve steps
# Test that results match expectation, within some tolerance
@test mdl.Age isa Vector{Float64}
@test mdl.Age [751.87, 742.76, 733.65, 724.51, 720.15, 715.96, 711.8, 709.15, 706.6, 704.04, 701.42, 698.67] atol=1
@test mdl.Age_025CI [742.48, 723.81, 718.7, 715.73, 707.42, 703.73, 701.34, 698.2, 696.35, 695.04, 694.0, 693.05] atol=2
@test mdl.Age_025CI [742.48, 723.81, 718.7, 715.73, 707.42, 703.73, 701.34, 698.2, 696.35, 695.04, 694.0, 693.05] atol=3
@test mdl.Age_975CI [761.17, 757.98, 752.64, 733.57, 731.21, 728.07, 722.24, 720.59, 718.6, 716.11, 712.48, 704.28] atol=3
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test -Inf < mean(lldist) < 0

@test NamedTuple(mdl) isa NamedTuple

# Data about hiatuses
nHiatuses = 2 # The number of hiatuses you have data for
Expand All @@ -45,11 +45,13 @@ hiatus.Duration_sigma = [ 3.1, 2.0 ]
# Run the model. Note the additional `hiatus` arguments
@time (mdl, agedist, hiatusdist, lldist) = StratMetropolis(smpl, hiatus, config); sleep(0.5)


# Test that results match expectation, within some tolerance
@test mdl.Age isa Vector{Float64}
@test mdl.Age [753.23, 748.14, 729.73, 724.3, 721.09, 718.04, 714.96, 713.54, 711.82, 701.99, 699.95, 698.21] atol=1
@test mdl.Age_025CI [744.19, 734.06, 718.01, 715.91, 710.5, 707.73, 705.75, 703.97, 701.87, 694.01, 693.25, 692.56] atol=3
@test mdl.Age_975CI [762.31, 760.19, 743.82, 732.92, 730.96, 728.45, 724.28, 723.32, 722.16, 712.29, 708.49, 703.75] atol=4
@test mdl.Age [752.76, 747.88, 728.92, 724.14, 720.8, 717.62, 714.44, 712.95, 711.41, 700.82, 699.4, 697.99] atol=1
@test mdl.Age_025CI [743.41, 734.96, 717.54, 715.41, 709.67, 707.05, 705.26, 703.72, 702.49, 693.27, 692.65, 692.06] atol=3
@test mdl.Age_975CI [761.77, 759.23, 741.37, 732.59, 730.64, 728.05, 723.52, 722.34, 720.9, 709.03, 706.78, 703.46] atol=3
# Test that all age-depth models are in stratigraphic order
@test all([issorted(x, rev=true) for x in eachcol(agedist)])
@test size(hiatusdist) == (nHiatuses, config.nsteps)
@test mean(hiatusdist, dims=2) [10.580012942504894; 18.96167245288326;;] atol=2
@test -Inf < mean(lldist) < 0
8 changes: 4 additions & 4 deletions test/testSubsidence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ config.sieve = round(Int,npoints_approx) # Record one out of every nsieve steps
mean_ages = nanmean(agedist_test, dim=2)
expected_mean_ages = [398.51, 397.72, 396.96, 396.19, 395.43, 394.67, 393.92, 393.17, 392.41, 391.65, 390.9, 390.15, 389.4, 388.65, 387.8, 386.92, 386.06, 385.19, 384.3, 383.42, 382.53, 381.65, 380.77, 379.89, 379.02, 378.14, 377.26, 376.37, 375.49, 374.61, 373.73, 372.85, 371.97, 371.08, 370.21, 369.33, 368.45, 367.56, 366.68, 365.8, 364.93, 364.05, 363.18, 362.31, 360.6, 358.87, 357.17, 355.45, 353.74, 352.0, 350.31, 348.61, 346.93, 345.24, 343.53, 341.79, 340.07, 338.35, 336.61, 334.87, 333.13, 331.4, 329.66, 327.94, 324.34, 320.83, 317.26, 313.63, 310.12, 306.46, 302.86, 299.29, 295.63, 291.97, 288.41, 284.76, 281.0, 277.38, 273.77, 270.23, 266.64, 262.96, 259.28, 255.54, 251.75, 248.12, 244.46, 240.89, 237.42, 233.89, 230.45, 227.02, 223.57, 220.26]
@test all(isapprox.(mean_ages, expected_mean_ages, atol=20))
# println(round.(mean_ages, digits=2))
println(round.(mean_ages, digits=2))

# Test subsidence parameters
@test isapprox(only(subsmdl_test.Beta), 1.385317084366247, atol=0.1)
Expand Down Expand Up @@ -176,14 +176,14 @@ smpl.Height_Unit = "m"

# Test mean age-depth model
mean_ages = nanmean(agedist_test, dim=2)
expected_mean_ages = [398.51, 397.72, 396.96, 396.19, 395.43, 394.67, 393.92, 393.17, 392.41, 391.65, 390.9, 390.15, 389.4, 388.65, 387.8, 386.92, 386.06, 385.19, 384.3, 383.42, 382.53, 381.65, 380.77, 379.89, 379.02, 378.14, 377.26, 376.37, 375.49, 374.61, 373.73, 372.85, 371.97, 371.08, 370.21, 369.33, 368.45, 367.56, 366.68, 365.8, 364.93, 364.05, 363.18, 362.31, 360.6, 358.87, 357.17, 355.45, 353.74, 352.0, 350.31, 348.61, 346.93, 345.24, 343.53, 341.79, 340.07, 338.35, 336.61, 334.87, 333.13, 331.4, 329.66, 327.94, 324.34, 320.83, 317.26, 313.63, 310.12, 306.46, 302.86, 299.29, 295.63, 291.97, 288.41, 284.76, 281.0, 277.38, 273.77, 270.23, 266.64, 262.96, 259.28, 255.54, 251.75, 248.12, 244.46, 240.89, 237.42, 233.89, 230.45, 227.02, 223.57, 220.26]
expected_mean_ages = [398.61, 397.78, 396.99, 396.26, 395.55, 394.87, 394.18, 393.38, 392.74, 392.04, 391.27, 390.53, 389.65, 388.74, 387.93, 387.15, 386.38, 385.6, 384.81, 384.06, 383.33, 382.53, 381.73, 380.95, 380.14, 379.3, 378.42, 377.62, 376.79, 375.94, 375.09, 374.1, 373.26, 372.27, 371.32, 370.25, 369.26, 368.4, 367.37, 366.26, 365.2, 364.1, 363.21, 362.3, 360.66, 358.53, 356.82, 354.9, 352.73, 350.94, 348.94, 347.02, 345.05, 343.42, 341.77, 340.15, 338.74, 337.24, 335.72, 334.24, 332.81, 331.04, 329.31, 327.89, 324.6, 320.52, 316.51, 313.65, 309.71, 306.69, 303.72, 300.81, 297.91, 294.51, 291.23, 288.37, 285.97, 282.59, 278.41, 275.78, 273.22, 270.78, 267.98, 264.7, 261.29, 258.09, 254.56, 250.22, 246.32, 242.24, 237.7, 232.23, 226.76, 220.52]
@test all(isapprox.(mean_ages, expected_mean_ages, atol=25))
# println(round.(mean_ages, digits=2))

# Test subsidence parameters
@test isapprox(only(subsmdl_test.Beta), 1.1247054117222945, atol=0.1)
@test isapprox(only(subsmdl_test.Beta_025CI), 1.0148599420923872, atol=0.1)
@test isapprox(only(subsmdl_test.Beta_975CI), 1.3342992791049268, atol=0.1)
@test isapprox(only(subsmdl_test.Beta_025CI), 1.0148599420923872, atol=0.15)
@test isapprox(only(subsmdl_test.Beta_975CI), 1.3509359022349554, atol=0.15)
@test isapprox(only(subsmdl_test.T0), 388.6046712104339, atol=5)
@test isapprox(only(subsmdl_test.T0_025CI), 338.7980819566939, atol=10)
@test isapprox(only(subsmdl_test.T0_975CI), 499.6217634635351, atol=10)

2 comments on commit f9880e2

@brenhinkeller
Copy link
Member Author

Choose a reason for hiding this comment

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

@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/108936

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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 v0.4.0 -m "<description of version>" f9880e209390aaee5e5623c4d45e784a94b2c946
git push origin v0.4.0

Please sign in to comment.