You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating scripts which work on multiple instruments but must be different
Sometime you will want to create a high level routine, like taking a measurement, where the technique is general across multiple instruments but the detail are different on each instrument, e.g. turn on the right number of detectors. The general strategy for this is to get the instrument name (see https://github.com/ISISComputingGroup/IBEX/issues/3052) and then do something sensible either:
importimportlibtry:
module_name="{}.measurement".format(g.get_instrument_py_name())
my_measurement=importlib.import_module(module_name)
exceptImportError:
print("Can not import measurement for the instrument {}".format(g.get_instrument_py_name()))
defmeasurement():
returnmy_measurement.turn_on_detector() # This will fail when called if the module can not be imported