From 82ae9de8dbd5ab629ef5ad83d529c89b8d307a55 Mon Sep 17 00:00:00 2001 From: Rafael Caixeta <8386288+rmcaixeta@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:40:17 -0300 Subject: [PATCH] Bump version --- Project.toml | 4 ++-- README.md | 2 +- src/LocalAnisotropies.jl | 2 +- src/estimators/variograms.jl | 4 ++-- src/parametrization.jl | 8 ++++---- src/parametrization/geometric.jl | 8 ++++---- src/parametrization/interpolation.jl | 2 +- src/parametrization/searchers.jl | 4 ++-- src/parametrization/utilities.jl | 4 ++-- src/spacetransforms/deformation.jl | 11 ++++++----- test/runtests.jl | 11 ++++++----- 11 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Project.toml b/Project.toml index 8d328e3..c6ef898 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/README.md b/README.md index a2e7017..e5f822b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/LocalAnisotropies.jl b/src/LocalAnisotropies.jl index e480701..975586a 100644 --- a/src/LocalAnisotropies.jl +++ b/src/LocalAnisotropies.jl @@ -65,7 +65,7 @@ export to_3d, to_vtk, AnisoDistance, - Geometrical, + Geometric, Gradients, GraphDistance, LocalInterpolate, diff --git a/src/estimators/variograms.jl b/src/estimators/variograms.jl index 69c1577..d335a0c 100644 --- a/src/estimators/variograms.jl +++ b/src/estimators/variograms.jl @@ -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)) @@ -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)) diff --git a/src/parametrization.jl b/src/parametrization.jl index 4c3a120..367c32d 100644 --- a/src/parametrization.jl +++ b/src/parametrization.jl @@ -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)) @@ -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 diff --git a/src/parametrization/geometric.jl b/src/parametrization/geometric.jl index b8b10db..0eaaee8 100644 --- a/src/parametrization/geometric.jl +++ b/src/parametrization/geometric.jl @@ -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 @@ -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) @@ -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]) diff --git a/src/parametrization/interpolation.jl b/src/parametrization/interpolation.jl index a5b024d..b7c0144 100644 --- a/src/parametrization/interpolation.jl +++ b/src/parametrization/interpolation.jl @@ -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 diff --git a/src/parametrization/searchers.jl b/src/parametrization/searchers.jl index 50693eb..7a1167e 100644 --- a/src/parametrization/searchers.jl +++ b/src/parametrization/searchers.jl @@ -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) diff --git a/src/parametrization/utilities.jl b/src/parametrization/utilities.jl index fa57b64..6a9a811 100644 --- a/src/parametrization/utilities.jl +++ b/src/parametrization/utilities.jl @@ -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) @@ -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 diff --git a/src/spacetransforms/deformation.jl b/src/spacetransforms/deformation.jl index c77d74d..8cc39a8 100644 --- a/src/spacetransforms/deformation.jl +++ b/src/spacetransforms/deformation.jl @@ -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 @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index c5773f0..cc0c696 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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 @@ -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)) @@ -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)