From 71c893ad1c473dc1b184148b2e43e2481ca0b913 Mon Sep 17 00:00:00 2001 From: Igor Andriyash Date: Wed, 12 Jun 2024 13:23:24 +0200 Subject: [PATCH] allow `r=0` in FromArrayProfile (and derived) method (#245) --- lasy/profiles/from_array_profile.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lasy/profiles/from_array_profile.py b/lasy/profiles/from_array_profile.py index 8b36d1ff..47640a67 100644 --- a/lasy/profiles/from_array_profile.py +++ b/lasy/profiles/from_array_profile.py @@ -62,11 +62,13 @@ def __init__(self, wavelength, pol, array, dim, axes, axes_order=["x", "y", "t"] else: self.array = array - # The first point is at dr/2. - # To make correct interpolation within the first cell, mirror - # field and axes along r. - r = np.concatenate((-axes["r"][::-1], axes["r"])) - array = np.concatenate((array[::-1], array)) + # If the first point of radial axis is not 0, we "mirror" it, + # to make correct interpolation within the first cell + if axes["r"][0] != 0.0: + r = np.concatenate(([-axes["r"][0]], axes["r"])) + array = np.concatenate(([array[0]], array)) + else: + r = axes["r"] self.combined_field_interp = RegularGridInterpolator( (r, axes["t"]),