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

Quick fix to avoid dimensionality mismatch when reading openpmd profile #344

Merged
merged 6 commits into from
Feb 6, 2025
Merged
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
Loading