Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interp2d #68

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading