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: