1 parent
29ca01b31d
commit
9fc92c3024
1 file changed
+30
-66
@@ -23,11 +23,21 @@ class XtremeNeXusFormat(DefaultFormat):
|
||||
entry = self.storage.create_group("entry")
|
||||
self.write_entry_metadata(entry)
|
||||
|
||||
##############################
|
||||
#### Entry Data ####
|
||||
##############################
|
||||
data = entry.create_group("data")
|
||||
data.attrs["NX_class"] = "NXdata"
|
||||
# The title is a combination of the sample name, the scan name and the scan number.
|
||||
# If any of these are missing, they will be omitted from the title.
|
||||
title_parts = []
|
||||
sample_name = self.info_storage.get("sample_name")
|
||||
if sample_name:
|
||||
title_parts.append(sample_name)
|
||||
scan_name = self.info_storage.get("scan_name")
|
||||
if scan_name:
|
||||
title_parts.append(scan_name)
|
||||
scan_number = self.info_storage.get("scan_number")
|
||||
if scan_number:
|
||||
title_parts.append(str(scan_number))
|
||||
|
||||
title = " - ".join(title_parts)
|
||||
entry.create_dataset(name="title", data=title)
|
||||
|
||||
##############################
|
||||
#### Sample ####
|
||||
@@ -123,11 +133,6 @@ class XtremeNeXusFormat(DefaultFormat):
|
||||
grating._storage["distance"].attrs["units"] = "m" # pylint: disable=protected-access
|
||||
self.safe_dataset(group=grating, name="beta", device="grating_beta")
|
||||
|
||||
exit_slit = monochromator.create_group("exit_slit")
|
||||
exit_slit.attrs["NX_class"] = "NXslit"
|
||||
exit_slit.create_dataset(name="description", data="Vertical exit slit")
|
||||
self.safe_dataset(group=exit_slit, name="y_gap", device="exit_slit")
|
||||
|
||||
for prefix, (group_name, description, distance_m) in self._MIRROR_GROUPS.items():
|
||||
mirror = instrument.create_group(group_name)
|
||||
mirror.attrs["NX_class"] = "NXmirror"
|
||||
@@ -138,6 +143,13 @@ class XtremeNeXusFormat(DefaultFormat):
|
||||
device_name = f"{prefix}_{axis}"
|
||||
self.safe_dataset(group=mirror, name=axis, device=device_name)
|
||||
|
||||
exit_slit = instrument.create_group("exit_slit")
|
||||
exit_slit.attrs["NX_class"] = "NXslit"
|
||||
exit_slit.create_dataset(
|
||||
name="description", data="Aperture between focusing and refocusing mirror"
|
||||
)
|
||||
self.safe_dataset(group=exit_slit, name="y_gap", device="exit_slit")
|
||||
|
||||
##############################
|
||||
#### Endstation ####
|
||||
##############################
|
||||
@@ -172,16 +184,18 @@ class XtremeNeXusFormat(DefaultFormat):
|
||||
adc_signals.attrs["NX_class"] = "NXdetector"
|
||||
self._write_signals_with_softlink(adc_signals)
|
||||
|
||||
for group_name, description, device_name in self._KEITHLEY_GROUPS:
|
||||
electrometer = instrument.create_group(group_name)
|
||||
electrometer.attrs["NX_class"] = "NXdetector"
|
||||
electrometer.create_dataset(name="description", data=description)
|
||||
self.safe_dataset(group=electrometer, name="gain_code", device=device_name)
|
||||
keithley = instrument.create_group("keithley")
|
||||
for keithley_index in range(1, 4):
|
||||
tmp = keithley.create_group(f"keithley_{keithley_index}")
|
||||
tmp.attrs["NX_class"] = "NXdetector"
|
||||
self.safe_dataset(group=tmp, device=f"keithley_{keithley_index}", name="gain")
|
||||
|
||||
##############################
|
||||
#### NXdata ####
|
||||
##############################
|
||||
self._populate_default_nxdata(data)
|
||||
data = entry.create_group("data")
|
||||
data.attrs["NX_class"] = "NXdata"
|
||||
self._write_signals_with_softlink(data)
|
||||
|
||||
def _write_signals_with_softlink(self, group):
|
||||
signals_is_async = "signals" in self.info_storage["bec"].get("readout_priority", {}).get(
|
||||
@@ -213,53 +227,3 @@ class XtremeNeXusFormat(DefaultFormat):
|
||||
self.safe_dataset(
|
||||
group=group, name="energy", device="signals", signal=f"{prefix}energy_cerbk"
|
||||
)
|
||||
|
||||
def _populate_default_nxdata(self, data_group) -> None:
|
||||
# We populate the NXdata group with the signals by linking to the datasets in collection.
|
||||
# If the signals are on readout priority "async", we take the async signals, otherwise we take the normal signals.
|
||||
self._write_signals_with_softlink(data_group)
|
||||
|
||||
# has_otf_data = self.get_entry("otf", signal="edata") is not None
|
||||
|
||||
# if has_otf_data:
|
||||
# self.safe_dataset(group=data_group, name="edata", device="otf", signal="edata")
|
||||
# self.safe_dataset(group=data_group, name="data", device="otf", signal="data")
|
||||
# data_group.attrs["signal"] = "data"
|
||||
# self.safe_dataset(group=data_group, name="idata", device="otf", signal="idata")
|
||||
# self.safe_dataset(group=data_group, name="fdata", device="otf", signal="fdata")
|
||||
|
||||
# data_group.attrs["axes"] = ["edata"]
|
||||
# auxiliary_signals = [
|
||||
# signal_name
|
||||
# for signal_name in ("idata", "fdata")
|
||||
# if self.get_entry("otf", signal=signal_name) is not None
|
||||
# ]
|
||||
# if auxiliary_signals:
|
||||
# data_group.attrs["auxiliary_signals"] = auxiliary_signals
|
||||
|
||||
# axis_target = self._axis_target()
|
||||
# if axis_target and not has_otf_data:
|
||||
# self.safe_dataset(group=data_group, name="energy", device="energy")
|
||||
# data_group.attrs["axes"] = ["energy"]
|
||||
# elif axis_target:
|
||||
# self.safe_dataset(group=data_group, name="energy", device="energy")
|
||||
|
||||
# found_signal = None
|
||||
# for signal in self._MONITOR_SIGNALS:
|
||||
# if self.get_entry("signals", signal=signal) is None:
|
||||
# continue
|
||||
# self.safe_dataset(group=data_group, name=signal, device="signals", signal=signal)
|
||||
# if found_signal is None:
|
||||
# found_signal = signal
|
||||
|
||||
# if found_signal and not has_otf_data:
|
||||
# data_group.attrs["signal"] = found_signal
|
||||
# elif self.get_entry("energy") is not None and not has_otf_data:
|
||||
# data_group.attrs["signal"] = "energy"
|
||||
|
||||
# def _axis_target(self) -> str | None:
|
||||
# if self.get_entry("energy") is not None:
|
||||
# return "/entry/instrument/beam_energy/energy"
|
||||
# if self.get_entry("mono") is not None:
|
||||
# return "/entry/instrument/monochromator/energy"
|
||||
# return None
|
||||
Reference in new issue
Block a user