Skip to content

Commit 54b3112

Browse files
authored
fix: enforce Float64 for the streamline axis (#160)
1 parent b57b9bb commit 54b3112

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

ext/BatsrusPyPlotExt/animate.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function Batsrus.animate(
6464
# First file to setup parameters if vmin/vmax are Inf
6565
bd = load(files[1])
6666
if bd.head.gencoord
67-
range = isnothing(plotrange) ? [-Inf, Inf, -Inf, Inf] : plotrange
68-
_, _, data = interp2d(bd, var, range, plotinterval; innermask, rbody)
67+
extents = isnothing(plotrange) ? [-Inf, Inf, -Inf, Inf] : plotrange
68+
_, _, data = interp2d(bd, var, extents, plotinterval; innermask, rbody)
6969
else
7070
data = bd[var]
7171
if !isnothing(plotrange)
@@ -101,9 +101,9 @@ function Batsrus.animate(
101101

102102
bd = load(file)
103103
if bd.head.gencoord
104-
range = isnothing(plotrange) ? [-Inf, Inf, -Inf, Inf] : plotrange
104+
extents = isnothing(plotrange) ? [-Inf, Inf, -Inf, Inf] : plotrange
105105
x_coords, y_coords, data =
106-
interp2d(bd, var, range, plotinterval; innermask, rbody)
106+
interp2d(bd, var, extents, plotinterval; innermask, rbody)
107107
else
108108
data = bd[var]
109109
# Apply plotrange if provided (using DimensionalData selectors)
@@ -114,6 +114,9 @@ function Batsrus.animate(
114114
# Get coordinates
115115
x_coords = dims(data, 1).val
116116
y_coords = dims(data, 2).val
117+
# Ensure uniform spacing for Matplotlib with Float64 precision
118+
x_coords = range(Float64(x_coords[1]), Float64(x_coords[end]), length(x_coords))
119+
y_coords = range(Float64(y_coords[1]), Float64(y_coords[end]), length(y_coords))
117120
data = data'
118121
end
119122

@@ -176,9 +179,9 @@ function Batsrus.animate(
176179
vars = split(streamvars, ";")
177180
if length(vars) == 2
178181
if bd.head.gencoord
179-
range = isnothing(plotrange) ? [-Inf, Inf, -Inf, Inf] : plotrange
182+
extents = isnothing(plotrange) ? [-Inf, Inf, -Inf, Inf] : plotrange
180183
xi, yi, (v1, v2) = interp2d(
181-
bd, [String(vars[1]), String(vars[2])], range, plotinterval;
184+
bd, [String(vars[1]), String(vars[2])], extents, plotinterval;
182185
innermask, rbody
183186
)
184187
else

0 commit comments

Comments
 (0)