Skip to content

Commit

Permalink
Add image_from_paths/image_from_paths!
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Dec 26, 2024
1 parent 70473fe commit e51d85a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Thermochron"
uuid = "b9a8379e-ee1a-4388-b7ca-7852af1cef08"
authors = ["C. Brenhin Keller and collaborators"]
version = "0.11.1"
version = "0.11.2"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Expand Down Expand Up @@ -30,5 +30,5 @@ LsqFit = "0.15.0"
NaNStatistics = "0.6"
ProgressMeter = "1"
Reexport = "1"
StatGeochemBase = "0.4.3, 0.5, 0.6"
StatGeochemBase = "0.6.11"
julia = "1.11"
33 changes: 33 additions & 0 deletions src/inversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,36 @@
)
return ttresult, kineticresult
end


"""
```julia
image_from_paths(tT::TTResult;
xresolution::Int=1800,
yresolution::Int=1200,
xrange = nanextrema(tT.tpointdist),
yrange = nanextrema(tT.Tpointdist),
)
```
Produce a 2d image (histogram) of path densities given a `TTResult`
```julia
julia> imgcounts, xq, yq = image_from_paths(tT; xrange=boundary.agepoints, yrange=boundary.T₀)
```
"""
function StatGeochemBase.image_from_paths(tT::TTResult;
xresolution::Int = 1800,
yresolution::Int = 1200,
xrange = nanextrema(tT.tpointdist),
yrange = nanextrema(tT.Tpointdist),
)
image_from_paths(tT.tpointdist, tT.Tpointdist; xresolution, yresolution, xrange, yrange)
end
function StatGeochemBase.image_from_paths!(tT::TTResult;
xresolution::Int = 1800,
yresolution::Int = 1200,
xrange = nanextrema(tT.tpointdist),
yrange = nanextrema(tT.Tpointdist),
)
image_from_paths!(tT.tpointdist, tT.Tpointdist; xresolution, yresolution, xrange, yrange)
end
20 changes: 19 additions & 1 deletion test/testcomplete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,22 @@ DN17Eamean = mean(kinetics.zdmdist .|> x-> x.DN17Ea)
@info "Mean zircon DN17Ea: $DN17Eamean"
rmr0mean = mean(kinetics.zdmdist .|> x-> x.rmr0)
@test 0 < rmr0mean < 1
@info "Mean zircon rmr0: $rmr0mean"
@info "Mean zircon rmr0: $rmr0mean"

## --- Test conversion of t-T images

ttimage, xq, yq = image_from_paths(tT, xresolution=200, yresolution=100, yrange=boundary.T₀)
@test xq == 8.75:17.5:3491.25
@test yq == 2.0:4.0:398.0
@test ttimage isa Matrix
@test axes(ttimage, 1) == 1:100
@test axes(ttimage, 2) == 1:200

ttimage2, xq2, yq2 = image_from_paths!(tT, xresolution=200, yresolution=100, yrange=boundary.T₀)
@test xq2 == 8.75:17.5:3491.25
@test yq2 == 2.0:4.0:398.0
@test ttimage2 isa Matrix
@test axes(ttimage2, 1) == 1:100
@test axes(ttimage2, 2) == 1:200

@test ttimage == ttimage2

2 comments on commit e51d85a

@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 register
Release notes:

  • Add image_from_paths/image_from_paths!

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

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

Please sign in to comment.