Skip to content

Commit

Permalink
Quick fix to avoid dimensionality mismatch when reading openpmd profi…
Browse files Browse the repository at this point in the history
…le (#344)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
delaossa and pre-commit-ci[bot] authored Feb 6, 2025
1 parent 4d4ee77 commit 1c8e3c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lasy/profiles/from_array_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ def __init__(self, wavelength, pol, array, dim, axes, axes_order=["x", "y", "t"]
else:
r = axes["r"]

# The `RegularGridInterpolator` below expects a 2D array.
# However, when reading lasy envelope files, the array is 3D.
# First dimension corresponds to the azimuthal mode decomposition.
# For now, this only fix profiles with one mode.
if len(array.shape) == 3:
assert array.shape[0] == 1, (
"Handling `rt` profiles with more than one azimuthal mode still needs to be implemented."
)
array = array[0]

self.combined_field_interp = RegularGridInterpolator(
(r, axes["t"]),
np.abs(array) + 1.0j * np.unwrap(np.angle(array), axis=-1),
Expand Down

0 comments on commit 1c8e3c1

Please sign in to comment.