Closed henry2004y closed 3 years ago
See de24e8173047c
There are some side effects. The contour function in gr() backend from Plots.jl only accepts 1D arrays, so most likely https://github.com/henry2004y/Batsrus.jl/blob/a5da0a5b211de4f33b18299790695239d673c9a3/src/plot/plots.jl#L37 won't work. I need to fix this!
I realized that the initial issue was not about 1D/2D grid arrays, but the consistency of ndgrid/meshgrid format for generating the variable w. Now I switched back to 1D grid arrays in getdata
by default, and it only returns 2D grid array when griddim=2
.
Tested for both PyPlot and Plots.
I have made several rounds of mistakes related to array storage ordering, specifically
meshgrid
vsndgrid
. Even though some Matplotlib functions likecontourf
support 1D grid arrays, it is very easy to mess it up when other conditions are handling 2D ndarrays from the interpolation package Dierckx.Therefore I decided to eliminate passing 1D arrays and always use 2D grid arrays. The list comprehension version of
meshgrid
iswhile the matrix multiplication version is
Based on my test results, the list comprehension version is consistently faster and consumes less memory than the matrix multiplication version. I have now replaced all the occurrences with a function called
meshgrid
.