Skip to content

Spectro Concepts: a simulated absorption bench and an extension working on ontology terms - #31

Merged
seb5g merged 18 commits into
devfrom
feature/ontology-extension
Nov 30, 2026
Merged

seb5g merged 18 commits into
devfrom
feature/ontology-extension

Conversation

@seb5g

@seb5g seb5g commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What this PR is

A demo of what the OntologyManager of PyMoDAQ (pymodaq_ontology) brings to an experiment: a simulated UV-vis absorption bench and a Dashboard extension, Spectro Concepts, that works on the terms assigned to the channels and never on the names of the modules or the values of the actuators.

(An earlier version of this PR was an OntologyLogger extension. It was replaced by this one and its files are not in the PR any more.)

What is implemented

The simulated bench (one shared simulated device, so there is nothing to link in the experiment)

  • daq_1Dviewer_MockSpectro: the spectrometer, counts on a wavelength axis in nm. What it gives depends on the actuators.
  • daq_move_MockBeamBlock: the beam block (1 blocks the beam, 0 lets it through).
  • daq_move_MockSampleChanger: the cuvette holder (0 the reference cuvette, 1 the sample).
  • hardware/spectro_bench.py: the lamp, the dark level and the sample transmittance.
  • Two experiments, spectro_lab_a.xml and spectro_lab_b.xml, with neutral and different module names, to show that nothing depends on them.

The ontology resources/ontology/spectro_ontology.ttl, read by the rdf source of the manager

  • Terms: Spectrum with Dark, Reference and Sample spectrum; Transmittance; Absorbance; the controls Beam block and Cuvette holder.
  • States of the controls (Beam blocked, Beam open, Reference in beam, Sample in beam) are members of an owl:oneOf enumeration of their control, so the manager shows them but does not let them be assigned to a channel.
  • pq:requiresState (the predicate the manager reads) says in which states each spectrum has its meaning, for example Dark spectrum requires Beam blocked.
  • mock:derivedFrom says what Transmittance and Absorbance are computed from.

The extension extensions/spectro_concepts.py (Spectro Concepts in the Extensions menu), with the logic in ontology_derivations.py

  • You assign Spectrum to the spectrometer in the manager, and associate the value of each actuator with a state.
  • What can I measure? tells, without acquiring, which measurements are possible, what can then be computed, and which state still has no value.
  • Measure and compute moves the actuators to the states of each measurement (using the manager, not the values), grabs the dark, the reference and the sample, computes the transmittance and then the absorbance (formulas coded in the extension) and shows them.
  • It checks that what a channel gives has the unit its term expects (counts for a spectrum).
  • Without pymodaq_ontology the extension says it cannot work.

Tests and docs

  • tests/test_ontology_derivations.py: the derivations, on the graph of the ontology.
  • tests/test_spectro_concepts.py: the extension in a Dashboard with the mock bench, up to a whole measure-and-compute run, with module names that say nothing (M1, M2...).
  • README section for the extension.

What is NOT implemented

  • The extension does not save a file and does not annotate saved data: it shows the results in a viewer. Saving with the semantic_iri annotation and the embedded ontology is done by the manager for extensions that save (see PyMoDAQ #1571, #1587), but it is not wired into this demo yet.
  • No manual step by step mode, no sequencer, no "is the dark ok, again or go on".
  • The extension does not yet tell the manager which measurement it takes (set_measurement, PyMoDAQ #1591) nor check the actuators with it.
  • Formulas are coded in the extension: the ontology only says what is derived from what, not how.

Requirements and how to try

  • Needs PyMoDAQ dev with pymodaq_ontology (the manager, the states and requiresState, #1586) and the mock instruments pymodaq_plugins_mock. The base branch is the dev of this repository for that reason.
  • The tests are skipped when pymodaq_ontology or the mock plugins are missing, so the CI of this repository does not run them.
  • Local run: pytest tests/test_ontology_derivations.py tests/test_spectro_concepts.py with PyMoDAQ dev installed. The mock-instrument tests need a display (QT_QPA_PLATFORM=offscreen works).
  • To try it: load the experiment spectro_lab_a, open the Ontology manager, load spectro_ontology.ttl, assign Spectrum to the spectrometer, associate each actuator value with a state, then open Spectro Concepts.

https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY


Generated by Claude Code

…e terms of the ontology manager

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83933974-6ec3-4c7a-a4a8-a8d4e3c306a5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…els, with a hierarchy of terms

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY

seb5g commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

CI note: the red tests and compatibility (3.14 / pyside6) jobs end with a segmentation fault in Qt/pyqtgraph code, in tests that already exist (test_move_and_grab and its neighbours). The tests of this PR (test_ontology_logger.py) are skipped in CI because pymodaq_ontology is not installed there. The same commit also has a green Tests run next to the red ones, so the crash is not deterministic: it looks like the intermittent Qt crash already seen on PyMoDAQ dev CI. I re-ran the job once and will not re-run it again.


Generated by Claude Code

…source

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
…ls allow to compute

Simulated spectrometers (dark, reference, sample), two experiments with different module names,
a small spectro ontology declaring the derivations (transmittance, absorbance), the extension and its tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
…he ontology gives the state for each measurement

Remove the Ontology Logger. The extension plans the measurements from the terms of the actuators and of the
spectrometer (dark: beam blocked; reference: blank cuvette; sample: sample cuvette), runs them, then computes
the transmittance and the absorbance.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
… associated in the ontology manager

The ontology no longer says that a value stands for a state: the user associates the value of each actuator,
as configured on the bench, with a state term in the manager; the extension only asks for states.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
…neOf) of their control

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
… ontology manager

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
@seb5g seb5g changed the title Ontology Logger: demo extension annotating the saved data with ontology terms Spectro Concepts: a simulated absorption bench and an extension working on ontology terms Nov 29, 2026
… of the spectrometer, states of the actuators)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
…re spectrometers (by plugin)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
…ext zone; each action and step writes to it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
…s tree, a time on each line and a separator between actions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN81mHyjs9x4DB6NLuNY
@seb5g
seb5g merged commit eebd61e into dev Nov 30, 2026
8 checks passed
@seb5g
seb5g deleted the feature/ontology-extension branch November 30, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants