From aea884848a32dae86b82545dea447ecab3755c51 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 8 Dec 2023 11:26:32 -0800 Subject: [PATCH] Long Data Profile: Optional Phase The phase argument is documented as optional, but currently required. This makes it optional in the implementation. --- .../longitudinal/longitudinal_profile_from_data.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/longitudinal_profile_from_data.py b/lasy/profiles/longitudinal/longitudinal_profile_from_data.py index 673a5e1f..e8a699e7 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile_from_data.py +++ b/lasy/profiles/longitudinal/longitudinal_profile_from_data.py @@ -63,7 +63,10 @@ def __init__(self, data, lo, hi): # First find central frequency wavelength = data["axis"] spectral_intensity = data["intensity"] - spectral_phase = data["phase"] + if data.get("phase") is None: + spectral_phase = np.zeros_like(wavelength) + else: + spectral_phase = data["phase"] dt = data["dt"] cwl = np.sum(spectral_intensity * wavelength) / np.sum(spectral_intensity) cfreq = c / cwl @@ -106,7 +109,10 @@ def __init__(self, data, lo, hi): elif data["datatype"] == "temporal": time = data["axis"] temporal_intensity = data["intensity"] - temporal_phase = data["phase"] + if data.get("phase") is None: + temporal_phase = np.zeros_like(time) + else: + temporal_phase = data["phase"] cwl = data["wavelength"] else: