Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4bb8ab1
Ontology Logger extension: a logger annotating the saved data with th…
claude Nov 27, 2026
a104d00
Ontology Logger: select the instruments by the concept of their chann…
claude Nov 27, 2026
4ca7997
Ontology Logger: the basic ontology is a Turtle file read by the rdf …
claude Nov 27, 2026
b2f38ce
Add the Spectro Concepts demo extension: what the terms of the channe…
claude Nov 27, 2026
bd8ab94
Spectro Concepts: one bench with a beam block and a cuvette holder, t…
claude Nov 28, 2026
f0f8e99
Spectro Concepts: the states of the bench are terms, their values are…
claude Nov 28, 2026
cd848b8
Spectro Concepts: line lengths
claude Nov 28, 2026
cfaf918
Spectro Concepts: line lengths
claude Nov 28, 2026
2831a48
Spectro Concepts: the cuvette state is Reference in beam, not blank
claude Nov 28, 2026
5e4576c
spectro ontology: mark the states of the controls (kinds of pq:State)
claude Nov 28, 2026
6399f01
spectro ontology: the states are the members of an enumeration (owl:o…
claude Nov 28, 2026
3a2e08a
spectro ontology: requiresState, the predicate of PyMoDAQ read by the…
claude Nov 28, 2026
1b943ab
Spectro Concepts: one button prepares the demo (ontology, probe, term…
claude Nov 29, 2026
bc8e3c5
Spectro Concepts: describe the prepare button in the docstring
claude Nov 29, 2026
d3eef21
Spectro Concepts: the term Spectrum goes only to the detectors that a…
claude Nov 29, 2026
cf156cb
Spectro Concepts: a wide log under the viewers replaces the cramped t…
claude Nov 29, 2026
2e318fd
Spectro Concepts: wrap a docstring line
claude Nov 29, 2026
a8127e4
Spectro Concepts: the log takes the left dock in place of the setting…
claude Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,17 @@ Extensions
save them. It shows how to use the ``modules_manager``, how to wait for the instruments with callbacks instead of
blocking the GUI, units on the positions and a clean shutdown. It works with the mock instruments of PyMoDAQ. See
"How a Dashboard extension works" in the PyMoDAQ documentation.

* **Spectro Concepts** (*extensions/spectro_concepts.py*): what the ontology terms of the channels let the experiment do,
whatever the modules are called. It needs the ``pymodaq_ontology`` package (PyMoDAQ ``dev`` branch for now). The
experiments ``spectro_lab_a.xml`` and ``spectro_lab_b.xml`` simulate an absorption bench: one spectrometer
(*MockSpectro*), a beam block (*MockBeamBlock*) and a cuvette holder (*MockSampleChanger*), with neutral module names
that differ from one experiment to the other. In the *Ontology* manager assign the term *Spectrum* to the spectrometer
and associate the value of each actuator, as configured on the bench, with a state (*Beam blocked*, *Beam open*,
*Reference in beam*, *Sample in beam*). The ontology *resources/ontology/spectro_ontology.ttl* says in which state of the bench a
spectrum is a *Dark spectrum* (beam blocked), a *Reference spectrum* (reference cuvette) or a *Sample spectrum*, and that a
*Transmittance* and an *Absorbance* are derived from them. The action *What can I measure?* tells what can be measured
and computed, or which state has no value yet; *Measure and compute* sets the bench for each measurement, grabs, then
computes and shows the results, with the formulas coded in the extension.

Installation instructions
=========================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Ontology demo: the beam block of a simulated absorption bench (1 blocks the beam, 0 lets it through)

The beam block, the cuvette holder (``MockSampleChanger``) and the spectrometer (``MockSpectro``) share one simulated
bench (see ``hardware/spectro_bench.py``): all are masters, nothing to link in the experiment.
"""
from pymodaq.control_modules.move_utility_classes import DAQ_Move_base, comon_parameters_fun, main, DataActuatorType
from pymodaq.utils.data import DataActuator

from pymodaq_plugins_mockexamples.hardware.spectro_bench import SpectroBench


class DAQ_Move_MockBeamBlock(DAQ_Move_base):
"""Sets ``beam_block`` of the bench"""
_controller_units = ''
is_multiaxes = True
_axis_names = ['Block']
_epsilons = 0.01
attribute = 'beam_block' # of the bench, set by this plugin

params = [] + comon_parameters_fun(axis_names=_axis_names, epsilon=_epsilons)
data_actuator_type = DataActuatorType.DataActuator

def ini_attributes(self):
self.controller: SpectroBench = None

def get_actuator_value(self) -> DataActuator:
pos = DataActuator(self._title, data=float(getattr(self.controller, self.attribute)), units=self.axis_unit)
return self.get_position_with_scaling(pos)

def close(self):
pass

def commit_settings(self, param):
pass

def ini_stage(self, controller: SpectroBench = None):
self.controller = SpectroBench.shared()
return 'Simulated absorption bench initialized', True

def move_abs(self, position: DataActuator):
position = self.check_bound(position)
self.target_value = position
setattr(self.controller, self.attribute, float(self.target_value.value(self.axis_unit)))

def move_rel(self, position: DataActuator):
position = self.check_bound(self.current_value + position) - self.current_value
self.target_value = position + self.current_value
setattr(self.controller, self.attribute, float(self.target_value.value(self.axis_unit)))

def stop_motion(self):
self.move_done()


if __name__ == '__main__':
main(__file__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Ontology demo: the cuvette holder of a simulated absorption bench (0 the reference cuvette, 1 the sample), see
``MockBeamBlock``"""
from pymodaq.control_modules.move_utility_classes import comon_parameters_fun, main, DataActuatorType

from pymodaq_plugins_mockexamples.daq_move_plugins.daq_move_MockBeamBlock import DAQ_Move_MockBeamBlock


class DAQ_Move_MockSampleChanger(DAQ_Move_MockBeamBlock):
"""Sets ``sample_position`` of the bench"""
_axis_names = ['Holder']
attribute = 'sample_position'

params = [] + comon_parameters_fun(axis_names=_axis_names, epsilon=DAQ_Move_MockBeamBlock._epsilons)
data_actuator_type = DataActuatorType.DataActuator


if __name__ == '__main__':
main(__file__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Ontology demo: the spectrometer of a simulated absorption bench, in counts on a wavelength axis in nm

What it sees depends on the beam block (``MockBeamBlock``) and on the cuvette holder (``MockSampleChanger``), which
share the same simulated bench (``hardware/spectro_bench.py``). The module has a
neutral name in the experiments ``spectro_lab_a`` and ``spectro_lab_b``: what a spectrum means depends on the state of
the bench when it is taken, which is what the ontology describes.
"""
from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main
from pymodaq.utils.data import DataFromPlugins, Axis
from pymodaq_data import DataToExport

from pymodaq_plugins_mockexamples.hardware.spectro_bench import SpectroBench


class DAQ_1DViewer_MockSpectro(DAQ_Viewer_base):
"""Counts of the spectrometer of the bench, on a wavelength axis in nm"""
params = comon_parameters

def ini_attributes(self):
self.controller: SpectroBench = None

def ini_detector(self, controller=None):
self.controller = SpectroBench.shared()
return 'Simulated spectrometer', True

def close(self):
pass

def commit_settings(self, param):
pass

def grab_data(self, Naverage=1, **kwargs):
axis = Axis(data=self.controller.get_wavelength_axis(), label='wavelength', units='nm', index=0)
n = max(Naverage, 1)
spectrum = sum(self.controller.grab_spectrum() for _ in range(n)) / n
self.dte_signal.emit(DataToExport(
name='MockSpectro',
data=[DataFromPlugins(name='Spectrum', data=[spectrum], dim='Data1D', labels=['intensity'],
units='counts', axes=[axis])]))

def stop(self):
pass


if __name__ == '__main__':
main(__file__)
Loading