parent
57e503fc3d
commit
cf6527af13
@ -188,10 +188,7 @@ def create():
|
||||
# skip unnecessary update caused by selection drop
|
||||
return
|
||||
|
||||
det_data = pyzebra.read_detector_data(new[0])
|
||||
|
||||
if cami_meta and "crystal" in cami_meta:
|
||||
det_data["ub"] = cami_meta["crystal"]["UB"]
|
||||
det_data = pyzebra.read_detector_data(new[0], cami_meta)
|
||||
|
||||
index_spinner.value = 0
|
||||
index_spinner.high = det_data["data"].shape[0] - 1
|
||||
|
@ -3,6 +3,7 @@ import numpy as np
|
||||
|
||||
|
||||
META_MATRIX = ("UB")
|
||||
META_CELL = ("cell")
|
||||
META_STR = ("name")
|
||||
|
||||
def read_h5meta(filepath):
|
||||
@ -43,19 +44,21 @@ def parse_h5meta(file):
|
||||
value = value.strip()
|
||||
|
||||
if variable in META_STR:
|
||||
content[section][variable] = value
|
||||
pass
|
||||
elif variable in META_CELL:
|
||||
value = np.array(value.split(",")[:6], dtype=np.float)
|
||||
elif variable in META_MATRIX:
|
||||
ub_matrix = np.array(value.split(",")[:9], dtype=np.float).reshape(3, 3)
|
||||
content[section][variable] = ub_matrix
|
||||
value = np.array(value.split(",")[:9], dtype=np.float).reshape(3, 3)
|
||||
else: # default is a single float number
|
||||
content[section][variable] = float(value)
|
||||
value = float(value)
|
||||
content[section][variable] = value
|
||||
else:
|
||||
content[section].append(line)
|
||||
|
||||
return content
|
||||
|
||||
|
||||
def read_detector_data(filepath):
|
||||
def read_detector_data(filepath, cami_meta=None):
|
||||
"""Read detector data and angles from an h5 file.
|
||||
|
||||
Args:
|
||||
@ -78,6 +81,11 @@ def read_detector_data(filepath):
|
||||
else:
|
||||
det_data["zebra_mode"] = "nb"
|
||||
|
||||
# overwrite zebra_mode from cami
|
||||
if cami_meta is not None:
|
||||
if "zebra_mode" in cami_meta:
|
||||
det_data["zebra_mode"] = cami_meta["zebra_mode"][0]
|
||||
|
||||
# om, sometimes ph
|
||||
if det_data["zebra_mode"] == "nb":
|
||||
det_data["omega"] = h5f["/entry1/area_detector2/rotation_angle"][:]
|
||||
@ -91,6 +99,8 @@ def read_detector_data(filepath):
|
||||
det_data["chi"] = h5f["/entry1/sample/chi"][:] # ch
|
||||
det_data["phi"] = h5f["/entry1/sample/phi"][:] # ph
|
||||
det_data["ub"] = h5f["/entry1/sample/UB"][:].reshape(3, 3)
|
||||
det_data["name"] = h5f["/entry1/sample/name"][0].decode()
|
||||
det_data["cell"] = h5f["/entry1/sample/cell"][:]
|
||||
|
||||
for var in ("omega", "gamma", "nu", "chi", "phi"):
|
||||
if abs(det_data[var][0] - det_data[var][-1]) > 0.1:
|
||||
@ -106,4 +116,22 @@ def read_detector_data(filepath):
|
||||
if "/entry1/sample/temperature" in h5f:
|
||||
det_data["temp"] = h5f["/entry1/sample/temperature"][:]
|
||||
|
||||
# overwrite metadata from .cami
|
||||
if cami_meta is not None:
|
||||
if "crystal" in cami_meta:
|
||||
cami_meta_crystal = cami_meta["crystal"]
|
||||
if "name" in cami_meta_crystal:
|
||||
det_data["name"] = cami_meta_crystal["name"]
|
||||
if "UB" in cami_meta_crystal:
|
||||
det_data["ub"] = cami_meta_crystal["UB"]
|
||||
if "cell" in cami_meta_crystal:
|
||||
det_data["cell"] = cami_meta_crystal["cell"]
|
||||
if "lambda" in cami_meta_crystal:
|
||||
det_data["wave"] = cami_meta_crystal["lambda"]
|
||||
|
||||
if "detector parameters" in cami_meta:
|
||||
cami_meta_detparam = cami_meta["detector parameters"]
|
||||
if "dist1" in cami_meta_detparam:
|
||||
det_data["ddist"] = cami_meta_detparam["dist1"]
|
||||
|
||||
return det_data
|
||||
|
Loading…
x
Reference in New Issue
Block a user