Skip to content

Commit

Permalink
Interp2d (#68)
Browse files Browse the repository at this point in the history
* Refactor interp2d

* Add interp2d benchmark

* Bump patch
  • Loading branch information
henry2004y authored Nov 12, 2024
1 parent 80e96e1 commit b03ecda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Batsrus"
uuid = "e74ebddf-6ac1-4047-a0e5-c32c99e57753"
authors = ["Hongyang Zhou <[email protected]>"]
version = "0.7.0"
version = "0.7.1"

[deps]
FortranFiles = "c58ffaec-ab22-586d-bfc5-781a99fd0b10"
Expand Down
6 changes: 4 additions & 2 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ SUITE["read"]["ASCII"] = @benchmarkable load($file)

file = joinpath(directory, files[2])
bd = load(file)
SUITE["read"]["Binary structured"] = @benchmarkable load($file)
SUITE["read"]["Extract density"] = @benchmarkable Batsrus.getvar($bd, "Rho")
SUITE["read"]["Extract B"] = @benchmarkable Batsrus.getvar($bd, "B")
SUITE["read"]["Binary structured"] = @benchmarkable load($file)

SUITE["read"]["Interp2d"] = @benchmarkable Batsrus.interp2d($bd, "rho")
file = joinpath(directory, files[3])
bd = load(file)
SUITE["read"]["Anisotropy"] = @benchmarkable bd["Anisotropy1"]
2 changes: 1 addition & 1 deletion src/Batsrus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Batsrus
#
# Hongyang Zhou, [email protected]

using LinearAlgebra: normalize, ×,
using LinearAlgebra: normalize, ×, , Adjoint
using Printf, Reexport, Requires
using Parsers
using Interpolations: cubic_spline_interpolation, BSpline, Linear, scale, interpolate
Expand Down
5 changes: 4 additions & 1 deletion src/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ data resolution is the same as the original.
- `useMatplotlib=true`: Whether to Matplotlib (somehow faster) or NaturalNeighbours for scattered interpolation.
"""
function interp2d(bd::BATS{2, 3, T}, var::AbstractString,
plotrange::Vector=[-Inf, Inf, -Inf, Inf], plotinterval::Real=Inf;
plotrangeIn::Vector=[-Inf32, Inf32, -Inf32, Inf32], plotinterval::Real=Inf32;
innermask::Bool=false, rbody::Real=1.0, useMatplotlib::Bool=true) where T
x, w = bd.x, bd.w
varIndex_ = findindex(bd, var)
plotrange = T.(plotrangeIn)

local Wi::Union{Matrix{T}, Adjoint{T, Matrix{T}}}

if bd.head.gencoord # Generalized coordinates
X, Y = eachslice(x, dims=3)
Expand Down

2 comments on commit b03ecda

@henry2004y
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/119225

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

Please sign in to comment.