Skip to content

Commit

Permalink
Move GeoStatsBase into an ext. (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion authored Jan 7, 2024
1 parent c0c87d7 commit 124e220
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 26 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.3] - 2023-10-14
## [0.8.5] - 2024-01-07
- Fix small bug in metadata
- Move GeoStatsBase into an extension

## [0.8.4] - 2024-01-07
- Fix crop returning too small an array
- Update GeoStatsBase compat bounds and fix interpolation

## [0.8.3] - 2023-10-14
- Correct roundoff errors in ranges
- Drop Julia 1.6 (LTS), now requires 1.9

## [0.8.2] - 2023-05-10
Expand Down
14 changes: 11 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
name = "GeoArrays"
uuid = "2fb1d81b-e6a0-5fc5-82e6-8e06903437ab"
authors = ["Maarten Pronk <[email protected]>"]
version = "0.8.4"
version = "0.8.5"

[weakdeps]
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"

[extensions]
# name of extension to the left
# extension dependencies required to load the extension to the right
# use a list for multiple extension dependencies
GeoArraysStatsExt = "GeoStatsBase"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand All @@ -10,7 +19,6 @@ DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Extents = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Expand All @@ -23,7 +31,7 @@ DataAPI = "1"
Extents = "0.1"
GeoFormatTypes = "0.4"
GeoInterface = "1"
GeoStatsBase = "0.37, 0.38, 0.39"
GeoStatsBase = "0.37 - 0.43"
IterTools = "1"
PrecompileTools = "1"
RecipesBase = "0.7, 0.8, 1.0"
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GeoArrays = "2fb1d81b-e6a0-5fc5-82e6-8e06903437ab"
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
push!(LOAD_PATH, "../src/")
using Documenter, GeoArrays
using Documenter, GeoArrays, GeoStatsBase

cl = joinpath(@__DIR__, "src/CHANGELOG.md")
isfile(cl) || cp(joinpath(@__DIR__, "../CHANGELOG.md"), cl)
Expand Down
28 changes: 28 additions & 0 deletions ext/GeoArraysStatsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module GeoArraysStatsExt

using GeoArrays, GeoStatsBase

"""
fill!(ga::GeoArray, solver::EstimationSolver, band=1)
Replace missing values in GeoArray `ga` using `solver` from the GeoStats ecosystem.
"""
function GeoArrays.fill!(ga::GeoArray, solver::T, band=1) where {T<:EstimationSolver}
data = @view ga.A[:, :, band]
m = ismissing.(data)
sum(m) == 0 && return ga
cds = collect(coords(ga))
problemdata = GeoStatsBase.georef(
(; band=@view data[.!m]),
@view cds[.!m]
)
problem = EstimationProblem(problemdata, GeoStatsBase.PointSet(cds[m]), :band)
solution = solve(problem, solver)

data[m] .= getproperty(solution, :band)
ga
end

@deprecate interpolate!(ga::GeoArray, solver::T, band=1) where {T<:EstimationSolver} fill!(ga, solver, band)

end
2 changes: 1 addition & 1 deletion src/geoarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function DataAPI.metadata(ga::GeoArray; style=false)
end
function DataAPI.metadata!(ga::GeoArray, key::AbstractString, value::AbstractString; style::Symbol=:default, domain::Union{Nothing,AbstractString}=nothing)
d = isnothing(domain) ? "ROOT" : domain
metadata(ga)[d][k] = value
metadata(ga)[d][key] = value
end
function DataAPI.emptymetadata!(ga::GeoArray)
ga.metadata = Dict{String,Any}()
Expand Down
24 changes: 4 additions & 20 deletions src/interpolate.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
using GeoStatsBase

"""
fill!(ga::GeoArray, solver::EstimationSolver, band=1)
fill!(ga::GeoArray, solver, band=1)
Replace missing values in GeoArray `ga` using `solver` from the GeoStats ecosystem.
Replace missing values in GeoArray `ga` using `solver`.
"""
function fill!(ga::GeoArray, solver::T, band=1) where {T<:EstimationSolver}
data = @view ga.A[:, :, band]
m = ismissing.(data)
sum(m) == 0 && return ga
cds = collect(coords(ga))
problemdata = GeoStatsBase.georef(
(; band=@view data[.!m]),
@view cds[.!m]
)
problem = EstimationProblem(problemdata, GeoStatsBase.PointSet(cds[m]), :band)
solution = solve(problem, solver)

data[m] .= getproperty(solution, :band)
ga
function fill!(::GeoArray, solver, band)
error("fill! using $solver is not implemented yet. Please use an `EstimationSolver` from the GeoStats.jl ecosystem.")
end

@deprecate interpolate!(ga::GeoArray, solver::T, band=1) where {T<:EstimationSolver} fill!(ga, solver, band)

2 comments on commit 124e220

@evetion
Copy link
Owner Author

@evetion evetion commented on 124e220 Jan 7, 2024

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/98404

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.8.5 -m "<description of version>" 124e220efce6e2fa5d06e5752bd45904f20cd270
git push origin v0.8.5

Please sign in to comment.