Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix complex interpolation in FromArrayProfile method #230

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lasy/profiles/from_array_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ def __init__(self, wavelength, pol, array, dim, axes, axes_order=["x", "y", "t"]
else:
self.array = array

self.field_interp = RegularGridInterpolator(
self.combined_field_interp = RegularGridInterpolator(
(axes["x"], axes["y"], axes["t"]),
array,
np.abs(array) + 1.0j * np.unwrap(np.angle(array), axis=-1),
bounds_error=False,
fill_value=0.0,
)

else: # dim = "rt"
assert axes_order in [["r", "t"], ["t", "r"]]

Expand All @@ -68,17 +67,23 @@ def __init__(self, wavelength, pol, array, dim, axes, axes_order=["x", "y", "t"]
# field and axes along r.
r = np.concatenate((-axes["r"][::-1], axes["r"]))
array = np.concatenate((array[::-1], array))
self.field_interp = RegularGridInterpolator(

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

def evaluate(self, x, y, t):
"""Return the envelope field of the scaled profile."""
if self.dim == "xyt":
envelope = self.field_interp((x, y, t))
combined_field = self.combined_field_interp((x, y, t))
else:
envelope = self.field_interp((np.sqrt(x**2 + y**2), t))
combined_field = self.combined_field_interp((np.sqrt(x**2 + y**2), t))

envelope = np.abs(np.real(combined_field)) * np.exp(
1.0j * np.imag(combined_field)
)

return envelope
Loading