This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from bec_server.file_writer.default_writer import DefaultFormat
|
||||
|
||||
import superxas_bec.bec_widgets.widgets.x10da_parameters as bl
|
||||
import superxas_bec.bec_widgets.widgets.digital_twin.x10da_parameters as bl
|
||||
|
||||
|
||||
class SuperXASNexusStructure(DefaultFormat):
|
||||
"""Nexus Structure for SuperXAS"""
|
||||
@@ -31,8 +32,7 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
|
||||
if "curr" in self.device_manager.devices:
|
||||
ring_current = source.create_soft_link(
|
||||
name="ring_current",
|
||||
target="/entry/collection/devices/curr/curr/value",
|
||||
name="ring_current", target="/entry/collection/devices/curr/curr/value"
|
||||
)
|
||||
ring_current.attrs["NX_class"] = "NX_FLOAT"
|
||||
ring_current.attrs["units"] = "mA"
|
||||
@@ -57,12 +57,12 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
name="reflection",
|
||||
target="/entry/collection/devices/mo1_bragg/mo1_bragg_crystal_current_xtal_string/value",
|
||||
)
|
||||
reflection.attrs["NX_class"] = "NX_CHAR"
|
||||
reflection.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
# Create a softlink
|
||||
d_spacing = crystal.create_soft_link(
|
||||
name="d_spacing",
|
||||
target="/entry/collection/devices/mo1_bragg/mo1_bragg_crystal_current_d_spacing/value",
|
||||
name="d_spacing",
|
||||
target="/entry/collection/devices/mo1_bragg/mo1_bragg_crystal_current_d_spacing/value",
|
||||
)
|
||||
d_spacing.attrs["NX_class"] = "NX_FLOAT"
|
||||
d_spacing.attrs["units"] = "angstrom"
|
||||
@@ -78,23 +78,22 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
name="phi_offset",
|
||||
target="/entry/collection/devices/mo1_bragg/mo1_bragg_crystal_current_phi_off/value",
|
||||
)
|
||||
phi_offset.attrs["NX_class"] = "NX_FLOAT"
|
||||
phi_offset.attrs["NX_class"] = "NX_FLOAT"
|
||||
phi_offset.attrs["units"] = "degree"
|
||||
|
||||
azm_offset = crystal.create_soft_link(
|
||||
name="azm_offset",
|
||||
target="/entry/collection/devices/mo1_bragg/mo1_bragg_crystal_current_azm_off/value",
|
||||
)
|
||||
azm_offset.attrs["NX_class"] = "NX_FLOAT"
|
||||
azm_offset.attrs["NX_class"] = "NX_FLOAT"
|
||||
azm_offset.attrs["units"] = "degree"
|
||||
|
||||
miscut = crystal.create_soft_link(
|
||||
name="miscut",
|
||||
target="/entry/collection/devices/mo1_bragg/mo1_bragg_crystal_current_miscut/value",
|
||||
)
|
||||
miscut.attrs["NX_class"] = "NX_FLOAT"
|
||||
miscut.attrs["units"] = "degree"
|
||||
|
||||
miscut.attrs["NX_class"] = "NX_FLOAT"
|
||||
miscut.attrs["units"] = "degree"
|
||||
|
||||
###################
|
||||
### cm mirror specific information
|
||||
@@ -108,7 +107,7 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
)
|
||||
cm_substrate_material.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
#previous error due to space in name field
|
||||
# previous error due to space in name field
|
||||
|
||||
if "cm_bnd" in self.device_manager.devices:
|
||||
cm_bending = collimating_mirror.create_soft_link(
|
||||
@@ -139,15 +138,15 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
cm_roll_angle.attrs["NX_class"] = "NX_FLOAT"
|
||||
cm_roll_angle.attrs["units"] = "mrad"
|
||||
|
||||
if 'cm_trx' in self.device_manager.devices:
|
||||
cm_trx = - self.device_manager.devices.cm_trx.read(cached=True).get('cm_trx').get('value')
|
||||
stripe = 'Unknown'
|
||||
if "cm_trx" in self.device_manager.devices:
|
||||
cm_trx = (
|
||||
-self.device_manager.devices.cm_trx.read(cached=True).get("cm_trx").get("value")
|
||||
)
|
||||
stripe = "Unknown"
|
||||
for name, low, high in zip(bl.cm.surface, bl.cm.limOptX[0], bl.cm.limOptX[1]):
|
||||
if low <= cm_trx <= high:
|
||||
stripe = name
|
||||
cm_stripe = collimating_mirror.create_dataset(
|
||||
name="stripe", data=stripe
|
||||
)
|
||||
cm_stripe = collimating_mirror.create_dataset(name="stripe", data=stripe)
|
||||
cm_stripe.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
###################
|
||||
@@ -157,9 +156,7 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
focusing_mirror = instrument.create_group(name="focusing_mirror")
|
||||
focusing_mirror.attrs["NX_class"] = "NXmirror"
|
||||
|
||||
fm_substrate_material = focusing_mirror.create_dataset(
|
||||
name="substrate_material", data="Si"
|
||||
)
|
||||
fm_substrate_material = focusing_mirror.create_dataset(name="substrate_material", data="Si")
|
||||
fm_substrate_material.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
if "fm_bnd" in self.device_manager.devices:
|
||||
@@ -191,15 +188,17 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
fm_roll_angle.attrs["NX_class"] = "NX_FLOAT"
|
||||
fm_roll_angle.attrs["units"] = "mrad"
|
||||
|
||||
if 'fm_trx' in self.device_manager.devices:
|
||||
fm_trx = - self.device_manager.devices.fm_trx.read(cached=True).get('fm_trx').get('value')
|
||||
stripe = 'Unknown'
|
||||
for name, low, high in zip(bl.fm.surfaceToroid, bl.fm.limOptXToroid[1], bl.fm.limOptXToroid[0]):
|
||||
if low <= fm_trx <= high:
|
||||
stripe = name + ' (toroid)'
|
||||
fm_stripe = focusing_mirror.create_dataset(
|
||||
name="stripe", data=stripe
|
||||
if "fm_trx" in self.device_manager.devices:
|
||||
fm_trx = (
|
||||
-self.device_manager.devices.fm_trx.read(cached=True).get("fm_trx").get("value")
|
||||
)
|
||||
stripe = "Unknown"
|
||||
for name, low, high in zip(
|
||||
bl.fm.surfaceToroid, bl.fm.limOptXToroid[1], bl.fm.limOptXToroid[0]
|
||||
):
|
||||
if low <= fm_trx <= high:
|
||||
stripe = name + " (toroid)"
|
||||
fm_stripe = focusing_mirror.create_dataset(name="stripe", data=stripe)
|
||||
fm_stripe.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
###################
|
||||
@@ -207,45 +206,65 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
###################
|
||||
|
||||
## Logic if device exist
|
||||
if "nidaq" in self.device_manager.devices:
|
||||
|
||||
#ai_chans_bits = self.device_manager.devices.nidaq.ai_chans.read(cached=True).get("nidaq_ai_chans").get("value")
|
||||
ai_chans_bits = self.configuration.get("nidaq", {}).get("nidaq_ai_chans", {}).get("value")
|
||||
ci_chans_bits = self.configuration.get("nidaq", {}).get("nidaq_ci_chans", {}).get("value")
|
||||
#add_chans_bits = self.device_manager.devices.nidaq.add_chans.read(cached=True).get("nidaq_add_chans").get("value")
|
||||
add_chans_bits = self.configuration.get("nidaq", {}).get("nidaq_add_chans", {}).get("value")
|
||||
if "nidaq" in self.device_manager.devices:
|
||||
|
||||
# ai_chans_bits = self.device_manager.devices.nidaq.ai_chans.read(cached=True).get("nidaq_ai_chans").get("value")
|
||||
ai_chans_bits = (
|
||||
self.configuration.get("nidaq", {}).get("nidaq_ai_chans", {}).get("value")
|
||||
)
|
||||
ci_chans_bits = (
|
||||
self.configuration.get("nidaq", {}).get("nidaq_ci_chans", {}).get("value")
|
||||
)
|
||||
# add_chans_bits = self.device_manager.devices.nidaq.add_chans.read(cached=True).get("nidaq_add_chans").get("value")
|
||||
add_chans_bits = (
|
||||
self.configuration.get("nidaq", {}).get("nidaq_add_chans", {}).get("value")
|
||||
)
|
||||
|
||||
measurement_mode = entry.create_group(name="mode")
|
||||
measurement_mode.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
if (int(ci_chans_bits) & 0x7F) != 0:
|
||||
# Create a dataset
|
||||
rayspec_sdd_active = measurement_mode.create_group(name="Multi_Element_Partial_Fluorescence_Yield")
|
||||
me_sdd = rayspec_sdd_active.create_dataset(name="Detector", data="Rayspec 7 element Silicon Drift Detector")
|
||||
rayspec_sdd_active = measurement_mode.create_group(
|
||||
name="Multi_Element_Partial_Fluorescence_Yield"
|
||||
)
|
||||
me_sdd = rayspec_sdd_active.create_dataset(
|
||||
name="Detector", data="Rayspec 7 element Silicon Drift Detector"
|
||||
)
|
||||
me_sdd.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
if (int(ci_chans_bits) & (1<<8)) != 0:
|
||||
if (int(ci_chans_bits) & (1 << 8)) != 0:
|
||||
# Create a dataset
|
||||
ketek_sdd_active = measurement_mode.create_group(name="Single_Element_Partial_Fluorescence_Yield")
|
||||
se_sdd = ketek_sdd_active.create_dataset(name="Detector", data="Ketex mini single element Silicon Drift Detector")
|
||||
ketek_sdd_active = measurement_mode.create_group(
|
||||
name="Single_Element_Partial_Fluorescence_Yield"
|
||||
)
|
||||
se_sdd = ketek_sdd_active.create_dataset(
|
||||
name="Detector", data="Ketex mini single element Silicon Drift Detector"
|
||||
)
|
||||
se_sdd.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
if ((int(ai_chans_bits) & (1<<6)) != 0):
|
||||
if (int(ai_chans_bits) & (1 << 6)) != 0:
|
||||
# Create a dataset
|
||||
pips_active = measurement_mode.create_group(name="Total_Flourescence_Yield")
|
||||
tfy = pips_active.create_dataset(name="Detector", data="Mirion Technologies Partially Depeleted PIPS Detector")
|
||||
tfy = pips_active.create_dataset(
|
||||
name="Detector", data="Mirion Technologies Partially Depeleted PIPS Detector"
|
||||
)
|
||||
tfy.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
if ((int(ai_chans_bits) & (1<<0)) != 0) & ((int(ai_chans_bits) & (1<<2)) != 0):
|
||||
if ((int(ai_chans_bits) & (1 << 0)) != 0) & ((int(ai_chans_bits) & (1 << 2)) != 0):
|
||||
# Create a dataset
|
||||
ai0ai2_active = measurement_mode.create_group(name="Sample_Transmission")
|
||||
sam_trans = ai0ai2_active.create_dataset(name="Detector", data="Ionitec 15 cm gas filled Ionisation Chambers")
|
||||
sam_trans = ai0ai2_active.create_dataset(
|
||||
name="Detector", data="Ionitec 15 cm gas filled Ionisation Chambers"
|
||||
)
|
||||
sam_trans.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
if ((int(ai_chans_bits) & (1<<2)) != 0) & ((int(ai_chans_bits) & (1<<4)) != 0):
|
||||
if ((int(ai_chans_bits) & (1 << 2)) != 0) & ((int(ai_chans_bits) & (1 << 4)) != 0):
|
||||
# Create a dataset
|
||||
ai2ai4_active = measurement_mode.create_group(name="Reference_Transmission")
|
||||
ref_trans = ai2ai4_active.create_dataset(name="Detector", data="Ionitec 15 cm gas filled Ionisation Chambers")
|
||||
ref_trans = ai2ai4_active.create_dataset(
|
||||
name="Detector", data="Ionitec 15 cm gas filled Ionisation Chambers"
|
||||
)
|
||||
ref_trans.attrs["NX_class"] = "NX_CHAR"
|
||||
|
||||
main_data = entry.create_group(name="data")
|
||||
@@ -254,45 +273,57 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
##################
|
||||
## energy, test whether the signal exists. how to check from config?
|
||||
###################
|
||||
|
||||
|
||||
energy = main_data.create_group(name="energy")
|
||||
energy.attrs["NX_class"] = "NXdata"
|
||||
energy.attrs["units"] = "eV"
|
||||
|
||||
main_data.create_soft_link(name="energy", target="/entry/collection/readout_groups/async/nidaq/nidaq_energy/value")
|
||||
|
||||
|
||||
main_data.create_soft_link(
|
||||
name="energy",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_energy/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## i0
|
||||
###################
|
||||
|
||||
if (int(ai_chans_bits) & (1<<0)) !=0:
|
||||
|
||||
if (int(ai_chans_bits) & (1 << 0)) != 0:
|
||||
i0 = main_data.create_group(name="i0")
|
||||
i0.attrs["NX_class"] = "NXdata"
|
||||
i0.attrs["units"] = "V"
|
||||
|
||||
main_data.create_soft_link(name="i0", target="/entry/collection/readout_groups/async/nidaq/nidaq_ai0_mean/value")
|
||||
|
||||
main_data.create_soft_link(
|
||||
name="i0",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_ai0_mean/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## i1
|
||||
###################
|
||||
|
||||
if (int(ai_chans_bits) & (1<<2)) !=0:
|
||||
|
||||
if (int(ai_chans_bits) & (1 << 2)) != 0:
|
||||
i1 = main_data.create_group(name="i1")
|
||||
i1.attrs["NX_class"] = "NXdata"
|
||||
i1.attrs["units"] = "V"
|
||||
|
||||
main_data.create_soft_link(name="i1", target="/entry/collection/readout_groups/async/nidaq/nidaq_ai2_mean/value")
|
||||
main_data.create_soft_link(
|
||||
name="i1",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_ai2_mean/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## i2
|
||||
###################
|
||||
|
||||
if (int(ai_chans_bits) & (1<<4)) !=0:
|
||||
if (int(ai_chans_bits) & (1 << 4)) != 0:
|
||||
i2 = main_data.create_group(name="i2")
|
||||
i2.attrs["NX_class"] = "NXdata"
|
||||
i2.attrs["units"] = "V"
|
||||
|
||||
main_data.create_soft_link(name="i2", target="/entry/collection/readout_groups/async/nidaq/nidaq_ai4_mean/value")
|
||||
main_data.create_soft_link(
|
||||
name="i2",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_ai4_mean/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## ci sum
|
||||
@@ -303,38 +334,46 @@ class SuperXASNexusStructure(DefaultFormat):
|
||||
ci_sum.attrs["NX_class"] = "NXdata"
|
||||
ci_sum.attrs["units"] = "counts"
|
||||
|
||||
main_data.create_soft_link(name="Fluorescence_Sum", target="/entry/collection/readout_groups/async/nidaq/nidaq_cisum/value")
|
||||
main_data.create_soft_link(
|
||||
name="Fluorescence_Sum",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_cisum/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## mu sample, test whether the signal exists. how to check from config?
|
||||
###################
|
||||
|
||||
if (int(add_chans_bits) & (1<<0)) !=0:
|
||||
if (int(add_chans_bits) & (1 << 0)) != 0:
|
||||
mu_sample = main_data.create_group(name="mu_sample")
|
||||
mu_sample.attrs["NX_class"] = "NXdata"
|
||||
|
||||
main_data.create_soft_link(name="mu_sample", target="/entry/collection/readout_groups/async/nidaq/nidaq_smpl_abs/value")
|
||||
|
||||
main_data.create_soft_link(
|
||||
name="mu_sample",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_smpl_abs/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## fluo sample, test whether the signal exists. how to check from config?
|
||||
###################
|
||||
|
||||
if (int(add_chans_bits) & (1<<1)) !=0:
|
||||
if (int(add_chans_bits) & (1 << 1)) != 0:
|
||||
mu_sample = main_data.create_group(name="fluo_sample")
|
||||
mu_sample.attrs["NX_class"] = "NXdata"
|
||||
|
||||
main_data.create_soft_link(name="fluo_sample", target="/entry/collection/readout_groups/async/nidaq/nidaq_smpl_fluo/value")
|
||||
|
||||
main_data.create_soft_link(
|
||||
name="fluo_sample",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_smpl_fluo/value",
|
||||
)
|
||||
|
||||
##################
|
||||
## mu reference, test whether the signal exists. how to check from config?
|
||||
###################
|
||||
|
||||
if (int(add_chans_bits) & (1<<2)) !=0:
|
||||
|
||||
if (int(add_chans_bits) & (1 << 2)) != 0:
|
||||
mu_reference = main_data.create_group(name="mu_reference")
|
||||
mu_reference.attrs["NX_class"] = "NXdata"
|
||||
|
||||
main_data.create_soft_link(name="mu_reference", target="/entry/collection/readout_groups/async/nidaq/nidaq_ref_abs/value")
|
||||
|
||||
|
||||
|
||||
|
||||
main_data.create_soft_link(
|
||||
name="mu_reference",
|
||||
target="/entry/collection/readout_groups/async/nidaq/nidaq_ref_abs/value",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user