Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcaixeta committed Jul 10, 2024
1 parent a93d1c1 commit 82ae9de
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LocalAnisotropiesMakieExt = "Makie"
[compat]
CSV = "0.10"
Distances = "0.10"
GeoStatsBase = "0.44, 0.45"
GeoStatsBase = "0.45"
GeoStatsFunctions = "0.4"
GeoStatsModels = "0.4"
GeoStatsTransforms = "0.7"
Expand All @@ -45,7 +45,7 @@ Graphs = "1.4"
ImageFiltering = "0.7"
LinearAlgebra = "<0.0.1, 1"
Makie = "0.21"
Meshes = "0.45, 0.46"
Meshes = "0.46"
MultivariateStats = "0.10"
NearestNeighbors = "0.4"
RecipesBase = "1.1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Some extra tools to work with local anisotropies:

```julia
# import external local anisotropies in GSLIB convention
dummy = georef((az=1:10, r1=1:10, r2=1:10), PointSet(rand(2,10)))
dummy = georef((az=1:10, r1=1:10, r2=1:10))
pars = localanisotropies(dummy, [:az], [:r1,:r2], :GSLIB)

# interpolate local anisotropies into a coarser grid
Expand Down
2 changes: 1 addition & 1 deletion src/LocalAnisotropies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export
to_3d,
to_vtk,
AnisoDistance,
Geometrical,
Geometric,
Gradients,
GraphDistance,
LocalInterpolate,
Expand Down
4 changes: 2 additions & 2 deletions src/estimators/variograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function mwvario(model, localpar)
# get reference pars. and apply local anisotropy to given structures
p = structures(model.γ)
γs = map(p[3]) do γ
Qs = ustrip(Q ./ collect(radii.ball))' .^ 2)
Qs = ustrip.(Q ./ collect(radii.ball))' .^ 2)
γ = @set γ.ball = MetricBall(1.0, Mahalanobis(Symmetric(Qs)))
end
γl = NuggetEffect(p[1]) + sum(c*γ for (c, γ) in zip(p[2], γs))
Expand Down Expand Up @@ -58,7 +58,7 @@ function kccov(γ::Variogram, xi, xj, Qi::AbstractMatrix, Qj::AbstractMatrix)
## modify variogram with average anisotropy matrix
p = structures(γ)
γs = map(p[3]) do γx
Qs = ustrip(Qij ./ collect(radii(γx.ball))' .^ 2)
Qs = ustrip.(Qij ./ collect(radii(γx.ball))' .^ 2)
γx = @set γx.ball = MetricBall(1.0, Mahalanobis(Symmetric(Qs)))
end
γl = NuggetEffect(p[1]) + sum(c*γx for (c, γx) in zip(p[2], γs))
Expand Down
8 changes: 4 additions & 4 deletions src/parametrization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ spars(D::LocalGeoData, i::Int) = spars(D)[i-nvals(D)]
spars(D::LocalGeoData, i::AbstractVector{Int}) = view(spars(D), i .- nvals(D))
nall(D::LocalGeoData) = sdata(D) ? nvals(D)+snvals(D) : nvals(D)
centro(D::LocalGeoData, i::Int) = i<=nvals(D) ? centro(obj(D),i) : centro(sobj(D),i-nvals(D))
coords_(D::LocalGeoData, i::Int) = ustrip(to(centro(D,i)))
coords_(D::SpatialData) = reduce(hcat, [ustrip(to(centro(D,x))) for x in 1:nvals(D)])
coords_(D::SpatialData, i::AbstractVector{Int}) = reduce(hcat, [ustrip(to(centro(D,x))) for x in i])
coords_(D::LocalGeoData, i::Int) = ustrip.(to(centro(D,i)))
coords_(D::SpatialData) = reduce(hcat, [ustrip.(to(centro(D,x))) for x in 1:nvals(D)])
coords_(D::SpatialData, i::AbstractVector{Int}) = reduce(hcat, [ustrip.(to(centro(D,x))) for x in i])

rotation(D::LocalGeoData) = D.localaniso.rotation
srotation(D::LocalGeoData) = view(rotation(D),spars(D))
Expand All @@ -135,7 +135,7 @@ function Base.show(io::IO, ::MIME"text/plain", ld::LocalGeoData)
end

abstract type LocalParMethods end
struct Geometrical <: LocalParMethods end
struct Geometric <: LocalParMethods end
struct Gradients <: LocalParMethods end


Expand Down
8 changes: 4 additions & 4 deletions src/parametrization/geometric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ------------------------------------------------------------------

"""
localanisotropies(Geometrical, searcher; simplify=true)
localanisotropies(Geometric, searcher; simplify=true)
Extract `LocalAnisotropy` from a searcher object. Based on the spatial data and
the parameters from the searcher object, a group of neighbor points is collected
Expand All @@ -19,11 +19,11 @@ intermediate axis will be orthogonal to the others). This is default for 3-D.
```julia
searcher = KNearestSearch(pts3dsurface, 10)
prelpars = localanisotropies(Geometrical, searcher) # extract local pars at surface
prelpars = localanisotropies(Geometric, searcher) # extract local pars at surface
lpars = idwpars(prelpars, searcher, grid) # interpolate local pars to a grid
```
"""
function localanisotropies(::Type{Geometrical}, searcher::NeighborSearchMethod;
function localanisotropies(::Type{Geometric}, searcher::NeighborSearchMethod;
simplify::Bool=true)
D = searcher.domain
X = coords_(D)
Expand Down Expand Up @@ -60,7 +60,7 @@ end

function pca(X, simplify)
N = size(X,1)
M = MultivariateStats.fit(PCA, ustrip(X), maxoutdim=N, pratio=1)
M = MultivariateStats.fit(PCA, ustrip.(X), maxoutdim=N, pratio=1)
λ = principalvars(M) ./ principalvars(M)[1]
nv = length(λ)
v = N == 3 ? projection(M) : vcat(projection(M),[0 0 1][1:nv])
Expand Down
2 changes: 1 addition & 1 deletion src/parametrization/interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function interpolate(lpars, searcher::NeighborSearchMethod, domain=nothing;

Threads.@threads for i in 1:len
ic = domain==nothing ? centro(D,i) : centro(domain,i)
icoords = ustrip(to(ic))
icoords = ustrip.(to(ic))
neighids = search(ic, searcher)

if length(neighids) == 0
Expand Down
4 changes: 2 additions & 2 deletions src/parametrization/searchers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ end

# nearest grid data id to some other sample data
function grid2hd_ids(pdata,pdomain)
hd = [ustrip(to(centro(pdata, i))) for i in 1:nvals(pdata)]
grid = [ustrip(to(centro(pdomain, i))) for i in 1:nvals(pdomain)]
hd = [ustrip.(to(centro(pdata, i))) for i in 1:nvals(pdata)]
grid = [ustrip.(to(centro(pdomain, i))) for i in 1:nvals(pdomain)]

tree = KDTree(grid)
idxs, dists = nn(tree, hd)
Expand Down
4 changes: 2 additions & 2 deletions src/parametrization/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function adjust_rake!(lpar::LocalAnisotropy, az::AbstractVector)
p2 = Plane(Point(0,0,0),n2)

dcm = collect(dcm)
icross = ustrip(to(intersection(p1,p2).geom.b))
icross = ustrip.(to(intersection(p1,p2).geom.b))
dcm[1,:] .= icross
dcm[2,:] .= cross(dcm[1,:],dcm[3,:])
det(dcm) < 0 && (dcm = Diagonal([-1,1,1]) * dcm)
Expand Down Expand Up @@ -195,7 +195,7 @@ function to_vtk(vtkfile, coords::AbstractArray, lpars::LocalAnisotropy;
end

function to_vtk(vtkfile, D::SpatialData, lpars::LocalAnisotropy; kwargs...)
coords = reduce(hcat, [ustrip(to(centro(D,x))) for x in 1:nvals(D)])
coords = reduce(hcat, [ustrip.(to(centro(D,x))) for x in 1:nvals(D)])
to_vtk(vtkfile, coords, lpars; kwargs...)
end

Expand Down
11 changes: 6 additions & 5 deletions src/spacetransforms/deformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ function outobj(D, coord)
out = if sdata(D)
n, hn = nvals(D), nall(D)
h1 = n+1
dc = view(coord,:,1:n)
dobj = dom isa Domain ? PointSet(dc) : georef(dom, dc)
georef(values(sobj(D)), view(coord,:,h1:hn)), dobj
dc = view(coord,:,1:n)
dd = view(coord,:,h1:hn)
dobj = dom isa Domain ? PointSet([tuple(dc[:,x]...) for x in 1:size(dc,2)]) : georef(dom, dc)
georef(values(sobj(D)), PointSet([tuple(dd[:,x]...) for x in 1:size(dd,2)])), dobj
else
dobj = dom isa Domain ? PointSet(coord) : georef(dom, coord)
dobj = dom isa Domain ? PointSet([tuple(coord[:,x]...) for x in 1:size(coord,2)]) : georef(dom, coord)
dobj
end
out
Expand All @@ -157,6 +158,6 @@ first three dimensions in order to help plotting of the data.
"""
function to_3d(s)
dom = domain(s)
c = reduce(hcat,[to(centro(dom,x))[1:3] for x in 1:nvals(dom)])
c = [Point(to(centro(dom,x))[1:3]...) for x in 1:nvals(dom)]
georef(values(s),PointSet(c))
end
11 changes: 6 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import LocalAnisotropies: rotmat
@testset "LocalAnisotropies.jl" begin

# convert data to LocalAnisotropy
dummy = georef((az=1:10, r1=1:10, r2=1:10), PointSet(reshape(1:20,(2,10))/10))
dummy = georef((az=1:10, r1=1:10, r2=1:10), PointSet([(i/2, (i+1)/2) for i in 1:2:19]))
pars = localanisotropies(dummy, [:az], [:r1,:r2], :GSLIB)
@test round(pars.rotation[1][4],digits=4) 0.0087

Expand All @@ -21,7 +21,8 @@ import LocalAnisotropies: rotmat
@test all([x[1] for x in angs_] .≈ 1:10)

# convert data to 3D LocalAnisotropy
dummy = georef((a1=1:10, a2=1:10, a3=1:10, r1=1:10, r2=1:10, r3=1:10), PointSet(rand(3,10)))
pts3d = rand(3,10)
dummy = georef((a1=1:10, a2=1:10, a3=1:10, r1=1:10, r2=1:10, r3=1:10), PointSet([tuple(pts3d[:,x]...) for x in 1:10]))
pars = localanisotropies(dummy, [:a1,:a2,:a3], [:r1,:r2,:r3], :Datamine)
pars_ = adjust_rake(pars,[45+i for i in 1:10])
@test all(round.(rotmat(pars,1)[3,:],digits=4) .≈ round.(rotmat(pars_,1)[3,:],digits=4))
Expand All @@ -32,10 +33,10 @@ import LocalAnisotropies: rotmat

# local anisotropies from pointset coordinates
data = rmat[1] * vcat(reshape(1:200,(2,100))/10,zeros(1,100))
pset = PointSet(data)
pset = PointSet([tuple(data[:,x]...) for x in 1:100])
nhood = KNearestSearch(pset, 10)
gpars = localanisotropies(Geometrical, nhood, simplify=true)
gpars = localanisotropies(Geometrical, nhood, simplify=false)
gpars = localanisotropies(Geometric, nhood, simplify=true)
gpars = localanisotropies(Geometric, nhood, simplify=false)

grid2d = (10,10)
grid3d = (10,10,5)
Expand Down

2 comments on commit 82ae9de

@rmcaixeta
Copy link
Owner 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/111021

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.5.6 -m "<description of version>" 82ae9de8dbd5ab629ef5ad83d529c89b8d307a55
git push origin v0.5.6

Please sign in to comment.