Skip to content

Commit

Permalink
Merge pull request #384 from volodia99/return-plot-1d
Browse files Browse the repository at this point in the history
BUG: fix reading coordinates in `Fargo3DReader.read`
  • Loading branch information
neutrinoceros authored Dec 16, 2024
2 parents 026e270 + 681dc32 commit c5ef2e7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions nonos/_readers/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,22 @@ def read(
n1 = len(V["x1"]) - 1
n2 = len(V["x2"]) - 1
n3 = len(V["x3"]) - 1
grid_shape = n3, n1, n2
shift = n2 // 2
if geometry_str == "cylindrical":
grid_shape = n3, n1, n2
tuple_transposition = (1, 2, 0)
shift = n2 // 2
elif geometry_str == "spherical":
grid_shape = n2, n1, n3
tuple_transposition = (1, 0, 2)
shift = n3 // 2
else:
raise NotImplementedError(f"Geometry {geometry_str!r} is not supported")

def _read_array(file: Path):
return np.roll(
np.fromfile(file, dtype="float64")
.reshape(grid_shape)
.transpose(1, 2, 0),
.transpose(tuple_transposition),
shift,
axis=1,
)
Expand Down

0 comments on commit c5ef2e7

Please sign in to comment.