From 6a496888fdeea10a32fe4cdf788be723c8415c6c Mon Sep 17 00:00:00 2001 From: Marko Toplak Date: Fri, 4 Oct 2024 15:15:35 +0200 Subject: [PATCH] Nea .gsf files not always include Interferometer Center/Distance --- orangecontrib/spectroscopy/io/neaspec.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/orangecontrib/spectroscopy/io/neaspec.py b/orangecontrib/spectroscopy/io/neaspec.py index fcec2d00a..f7f41827c 100644 --- a/orangecontrib/spectroscopy/io/neaspec.py +++ b/orangecontrib/spectroscopy/io/neaspec.py @@ -283,13 +283,18 @@ def _format_file(self, gsf_a, gsf_p, parameters, channel_a, channel_p): # calculate datapoint spacing in cm for the fft widget number_of_points = px_z - scan_size = float( - info["Interferometer Center/Distance"][2].replace(",", "") - ) # Microns - scan_size = scan_size * 1e-4 # Convert to cm - step_size = (scan_size * 2) / (number_of_points - 1) - # metadata info for the fft widget calculation - info["Calculated Datapoint Spacing (Δx)"] = ["[cm]", step_size] + try: + scan_size = float( + info["Interferometer Center/Distance"][2].replace(",", "") + ) # Microns + except KeyError: + scan_size = None + if scan_size is not None: + scan_size = scan_size * 1e-4 # Convert to cm + step_size = (scan_size * 2) / (number_of_points - 1) + # metadata info for the fft widget calculation + info["Calculated Datapoint Spacing (Δx)"] = ["[cm]", step_size] + # metadata info for selecting the correct fft method in the fft widget info["Channel Data Type"] = "Polar", "i.e. Amplitude and Phase separated"