Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 58a70476 authored by usov_i's avatar usov_i
Browse files

Fix KeyError if 'mf' or 'temp' not in data

parent 144b37ba
No related branches found
No related tags found
No related merge requests found
Pipeline #26836 passed
...@@ -147,17 +147,21 @@ def read_detector_data(filepath, cami_meta=None): ...@@ -147,17 +147,21 @@ def read_detector_data(filepath, cami_meta=None):
# optional parameters # optional parameters
if "/entry1/sample/magnetic_field" in h5f: if "/entry1/sample/magnetic_field" in h5f:
scan["mf"] = h5f["/entry1/sample/magnetic_field"][:] scan["mf"] = h5f["/entry1/sample/magnetic_field"][:]
# TODO: NaNs are not JSON compliant, so replace them with None
# this is not a great solution, but makes it safe to use the array in bokeh if "mf" in scan:
scan["mf"] = np.where(np.isnan(scan["mf"]), None, scan["mf"]) # TODO: NaNs are not JSON compliant, so replace them with None
# this is not a great solution, but makes it safe to use the array in bokeh
scan["mf"] = np.where(np.isnan(scan["mf"]), None, scan["mf"])
if "/entry1/sample/temperature" in h5f: if "/entry1/sample/temperature" in h5f:
scan["temp"] = h5f["/entry1/sample/temperature"][:] scan["temp"] = h5f["/entry1/sample/temperature"][:]
elif "/entry1/sample/Ts/value" in h5f: elif "/entry1/sample/Ts/value" in h5f:
scan["temp"] = h5f["/entry1/sample/Ts/value"][:] scan["temp"] = h5f["/entry1/sample/Ts/value"][:]
# TODO: NaNs are not JSON compliant, so replace them with None
# this is not a great solution, but makes it safe to use the array in bokeh if "temp" in scan:
scan["temp"] = np.where(np.isnan(scan["temp"]), None, scan["temp"]) # TODO: NaNs are not JSON compliant, so replace them with None
# this is not a great solution, but makes it safe to use the array in bokeh
scan["temp"] = np.where(np.isnan(scan["temp"]), None, scan["temp"])
# overwrite metadata from .cami # overwrite metadata from .cami
if cami_meta is not None: if cami_meta is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment