mosca-client 2.0.5__tar.gz → 2.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mosca_client-2.0.5 → mosca_client-2.0.7}/PKG-INFO +2 -2
- {mosca_client-2.0.5 → mosca_client-2.0.7}/pyproject.toml +6 -2
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/dante.py +10 -6
- mosca_client-2.0.7/src/mosca_client/tango/devices/xmap.py +35 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/readers.py +34 -31
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/rois.py +25 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/.gitignore +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/README.rst +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/__init__.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/logging.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/__init__.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/__init__.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/danteplus.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/dummy.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/falconx.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/generator.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/simdante.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/simfalconx.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/simulation.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/devices/xia.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/mca.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/mosca.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/saving.py +0 -0
- {mosca_client-2.0.5 → mosca_client-2.0.7}/src/mosca_client/tango/utils.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mosca-client"
|
|
3
|
-
requires-python = ">=3.10
|
|
4
|
-
version = "2.0.
|
|
3
|
+
requires-python = ">=3.10"
|
|
4
|
+
version = "2.0.7"
|
|
5
5
|
|
|
6
6
|
dependencies = [
|
|
7
7
|
"pytango",
|
|
@@ -21,6 +21,10 @@ version = { workspace = true }
|
|
|
21
21
|
[tool.pixi.package.build]
|
|
22
22
|
backend = { name = "pixi-build-python", version = "0.*" }
|
|
23
23
|
|
|
24
|
+
[tool.pixi.package.build.config]
|
|
25
|
+
# run dependencies are mapped from [project.dependencies]
|
|
26
|
+
ignore-pypi-mapping = false
|
|
27
|
+
|
|
24
28
|
[tool.pixi.package.host-dependencies]
|
|
25
29
|
hatchling = "==1.26.3"
|
|
26
30
|
|
|
@@ -56,20 +56,24 @@ class Dante(McaBase):
|
|
|
56
56
|
# for a fixed amount of time -- avoids racing against slow thread
|
|
57
57
|
# scheduling on the server side, which could otherwise let a stale
|
|
58
58
|
# prior status (e.g. READY) slip past the checks below undetected.
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
t0 = time.time()
|
|
60
|
+
start_deadline = t0 + self.CONFIG_LOAD_START_WAIT
|
|
61
|
+
# read the status once per check: re-reading it between checks races
|
|
62
|
+
# with the server switching UNINITIALIZED -> FAULT on a fast failure
|
|
63
|
+
status = proxy.mca_status
|
|
64
|
+
while status not in ("UNINITIALIZED", "FAULT") and time.time() < start_deadline:
|
|
61
65
|
time.sleep(0.1)
|
|
66
|
+
status = proxy.mca_status
|
|
62
67
|
|
|
63
|
-
if
|
|
68
|
+
if status == "FAULT":
|
|
64
69
|
raise RuntimeError(
|
|
65
70
|
f"Failed to load config [{configuration}]. Please check server logs."
|
|
66
71
|
)
|
|
67
72
|
|
|
68
|
-
if
|
|
73
|
+
if status != "UNINITIALIZED":
|
|
69
74
|
raise RuntimeError(
|
|
70
75
|
f"Server did not start processing config [{configuration}] "
|
|
71
|
-
f"(mca_status still {
|
|
72
|
-
f"{self.CONFIG_LOAD_START_WAIT}s)."
|
|
76
|
+
f"(mca_status still {status!r} after {time.time() - t0:.1f}s)."
|
|
73
77
|
)
|
|
74
78
|
|
|
75
79
|
deadline = time.time() + self.CONFIG_LOAD_TIMEOUT
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from .xia import Xia
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class XMap(Xia):
|
|
7
|
+
def filter_parameters(self,
|
|
8
|
+
acq_realtime=None,
|
|
9
|
+
block_size=None,
|
|
10
|
+
trigger_mode=None,
|
|
11
|
+
**kwargs):
|
|
12
|
+
""" Computes block_size if not provided:
|
|
13
|
+
* block_size: 1 <= 1 / acq_realtime <= 1020
|
|
14
|
+
Attention: block_size is not changed if acq_realtime
|
|
15
|
+
is None or nul!
|
|
16
|
+
"""
|
|
17
|
+
params = super().filter_parameters(**kwargs)
|
|
18
|
+
|
|
19
|
+
acq_realtime = params.get("acq_realtime", acq_realtime)
|
|
20
|
+
block_size = params.get("block_size", block_size)
|
|
21
|
+
trigger_mode = params.get("trigger_mode", trigger_mode)
|
|
22
|
+
|
|
23
|
+
if trigger_mode == "INT_TRIG_READOUT":
|
|
24
|
+
params["acq_nb_points"] = 1
|
|
25
|
+
|
|
26
|
+
if block_size is None and acq_realtime:
|
|
27
|
+
if trigger_mode in ("GATE", "EXT_TRIG"):
|
|
28
|
+
# aiming for a buffer swap every second
|
|
29
|
+
block_size = np.clip(1. / acq_realtime, 1, 1020)
|
|
30
|
+
params["block_size"] = int(block_size)
|
|
31
|
+
|
|
32
|
+
return params
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Mca = XMap
|
|
@@ -8,11 +8,18 @@ import logging
|
|
|
8
8
|
from ruamel.yaml import YAML
|
|
9
9
|
import numpy as np
|
|
10
10
|
from tango import DeviceProxy
|
|
11
|
+
from collections import namedtuple
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
logger = logging.getLogger(__name__)
|
|
14
15
|
|
|
15
16
|
|
|
17
|
+
def _counters(counters: dict):
|
|
18
|
+
keys = counters.keys()
|
|
19
|
+
return namedtuple('Counters', keys)(*map(int, counters.values()))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
16
23
|
import h5py
|
|
17
24
|
# TODO: allow reading from closed files
|
|
18
25
|
if h5py.version.version_tuple < (3, 12):
|
|
@@ -61,9 +68,6 @@ class Reader:
|
|
|
61
68
|
"""
|
|
62
69
|
|
|
63
70
|
def __init__(self, tango_url, acq_id: int=None):
|
|
64
|
-
# TEMPORARILY DISABLING ACQ ID until this is implemented server side
|
|
65
|
-
acq_id = None
|
|
66
|
-
# =========
|
|
67
71
|
self._acq_id = acq_id
|
|
68
72
|
self._tango_url = tango_url
|
|
69
73
|
self._proxy = None
|
|
@@ -90,7 +94,7 @@ class Reader:
|
|
|
90
94
|
def metadata(self):
|
|
91
95
|
if self._acq_metadata is None:
|
|
92
96
|
if self._acq_id:
|
|
93
|
-
metadata = self.proxy.
|
|
97
|
+
metadata = self.proxy.acqid_metadata(self._acq_id)
|
|
94
98
|
else:
|
|
95
99
|
metadata = self.proxy.metadata()
|
|
96
100
|
metadata = YAML().load(metadata)
|
|
@@ -130,6 +134,17 @@ class Reader:
|
|
|
130
134
|
self._rois_shape = (metadata["data"]["rois"]["n_rois"], -1)
|
|
131
135
|
return self._rois_shape
|
|
132
136
|
|
|
137
|
+
def counters(self):
|
|
138
|
+
if self._acq_id is not None:
|
|
139
|
+
counters = self.proxy.acqid_counters(self._acq_id)
|
|
140
|
+
counters = YAML().load(counters)
|
|
141
|
+
else:
|
|
142
|
+
counters = {"triggered": self.proxy.n_triggered_points,
|
|
143
|
+
"read": self.proxy.n_read_points,
|
|
144
|
+
"available": self.proxy.n_available_points,
|
|
145
|
+
"saved": self.proxy.n_saved_points}
|
|
146
|
+
return _counters(counters)
|
|
147
|
+
|
|
133
148
|
@property
|
|
134
149
|
def n_triggered_points(self):
|
|
135
150
|
"""
|
|
@@ -138,10 +153,7 @@ class Reader:
|
|
|
138
153
|
|
|
139
154
|
(n_triggered >= n_read >= n_available)
|
|
140
155
|
"""
|
|
141
|
-
|
|
142
|
-
return self.proxy.acq_n_triggered_points(self._acq_id)
|
|
143
|
-
else:
|
|
144
|
-
return self.proxy.n_triggered_points
|
|
156
|
+
return self.counters().triggered
|
|
145
157
|
|
|
146
158
|
@property
|
|
147
159
|
def n_read_points(self):
|
|
@@ -150,10 +162,7 @@ class Reader:
|
|
|
150
162
|
|
|
151
163
|
(n_triggered >= n_read >= n_available)
|
|
152
164
|
"""
|
|
153
|
-
|
|
154
|
-
return self.proxy.acq_n_read_points(self._acq_id)
|
|
155
|
-
else:
|
|
156
|
-
return self.proxy.n_read_points
|
|
165
|
+
return self.counters().read
|
|
157
166
|
|
|
158
167
|
@property
|
|
159
168
|
def n_available_points(self):
|
|
@@ -163,10 +172,7 @@ class Reader:
|
|
|
163
172
|
|
|
164
173
|
(n_triggered >= n_read >= n_available >= n_saved)
|
|
165
174
|
"""
|
|
166
|
-
|
|
167
|
-
return self.proxy.acq_n_available_points(self._acq_id)
|
|
168
|
-
else:
|
|
169
|
-
return self.proxy.n_available_points
|
|
175
|
+
return self.counters().available
|
|
170
176
|
|
|
171
177
|
@property
|
|
172
178
|
def n_saved_points(self):
|
|
@@ -175,10 +181,7 @@ class Reader:
|
|
|
175
181
|
|
|
176
182
|
(n_triggered >= n_read >= n_available >= n_saved)
|
|
177
183
|
"""
|
|
178
|
-
|
|
179
|
-
return self.proxy.acq_n_saved_points(self._acq_id)
|
|
180
|
-
else:
|
|
181
|
-
return self.proxy.n_saved_points
|
|
184
|
+
return self.counters().saved
|
|
182
185
|
|
|
183
186
|
# @property
|
|
184
187
|
# def n_zarr_saved_points(self):
|
|
@@ -189,7 +192,7 @@ class Reader:
|
|
|
189
192
|
args = [first]
|
|
190
193
|
args += [last] if last is not None else []
|
|
191
194
|
if self._acq_id:
|
|
192
|
-
spectra = self.proxy.
|
|
195
|
+
spectra = self.proxy.acqid_read_spectra([self._acq_id] + args)
|
|
193
196
|
else:
|
|
194
197
|
spectra = self.proxy.read_spectra(args)
|
|
195
198
|
spectra = spectra.reshape(self.spectra_shape)
|
|
@@ -204,7 +207,7 @@ class Reader:
|
|
|
204
207
|
args += [last] if last is not None else []
|
|
205
208
|
|
|
206
209
|
if self._acq_id:
|
|
207
|
-
stats = self.proxy.
|
|
210
|
+
stats = self.proxy.acqid_read_stats([self._acq_id] + args)
|
|
208
211
|
else:
|
|
209
212
|
stats = self.proxy.read_stats(args)
|
|
210
213
|
return stats.reshape(self.stats_shape)
|
|
@@ -213,7 +216,7 @@ class Reader:
|
|
|
213
216
|
args = [first]
|
|
214
217
|
args += [last] if last is not None else []
|
|
215
218
|
if self._acq_id:
|
|
216
|
-
rois = self.proxy.
|
|
219
|
+
rois = self.proxy.acqid_read_rois([self._acq_id] + args)
|
|
217
220
|
else:
|
|
218
221
|
rois = self.proxy.read_rois(args)
|
|
219
222
|
return rois.reshape(self.rois_shape)
|
|
@@ -371,8 +374,7 @@ class MixedReader:
|
|
|
371
374
|
raise ValueError(f"MixedReader.read_spectra do not support relative indices (last={last}).")
|
|
372
375
|
|
|
373
376
|
if _ALLOW_H5 and self.reader.metadata()["data"]["saving"]["enabled"]:
|
|
374
|
-
n_saved = self.reader.
|
|
375
|
-
n_avail = self.reader.n_available_points
|
|
377
|
+
_, _, n_avail, n_saved = self.reader.counters()
|
|
376
378
|
if last is None:
|
|
377
379
|
last = n_avail
|
|
378
380
|
if first < n_saved:
|
|
@@ -510,13 +512,14 @@ class Poller:
|
|
|
510
512
|
# keep that order, status needs to be retrieved
|
|
511
513
|
# before the point counters
|
|
512
514
|
status = reader.acquisition_status()
|
|
513
|
-
|
|
515
|
+
counters = reader.counters()
|
|
516
|
+
triggered = counters.triggered
|
|
517
|
+
available = counters.available
|
|
518
|
+
saved = counters.saved
|
|
514
519
|
# available points -> processed points (except saving)
|
|
515
|
-
read = reader.n_available_points
|
|
516
|
-
saved = reader.n_saved_points
|
|
517
520
|
# zarr_saved = reader.n_zarr_saved_points
|
|
518
521
|
|
|
519
|
-
new_points =
|
|
522
|
+
new_points = available != self._poll_read
|
|
520
523
|
|
|
521
524
|
# did anything change since last poll?
|
|
522
525
|
changed = (new_points
|
|
@@ -534,7 +537,7 @@ class Poller:
|
|
|
534
537
|
# new points available, notifying observers, downloading rois and stats
|
|
535
538
|
if new_points:
|
|
536
539
|
from_index = self._poll_read
|
|
537
|
-
to_index =
|
|
540
|
+
to_index = available
|
|
538
541
|
|
|
539
542
|
if read_spectra:
|
|
540
543
|
spectra = reader.read_spectra(from_index, to_index)
|
|
@@ -549,7 +552,7 @@ class Poller:
|
|
|
549
552
|
|
|
550
553
|
self._poll_triggered = triggered
|
|
551
554
|
self._poll_status = status
|
|
552
|
-
self._poll_read =
|
|
555
|
+
self._poll_read = available
|
|
553
556
|
self._poll_saved = saved
|
|
554
557
|
# self._poll_zarr_saved = zarr_saved
|
|
555
558
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from dataclasses import dataclass, asdict
|
|
2
3
|
from ruamel.yaml import YAML
|
|
3
4
|
|
|
@@ -104,6 +105,30 @@ class Rois:
|
|
|
104
105
|
"""
|
|
105
106
|
self._set(name, bin_range, *detectors)
|
|
106
107
|
|
|
108
|
+
def __setitem__(self, name, value):
|
|
109
|
+
""" rois[name] = (start, stop) or rois[name] = (start, stop, *detectors)
|
|
110
|
+
is equivalent to rois.set(name, (start, stop), *detectors).
|
|
111
|
+
|
|
112
|
+
Deprecated: use `.set()` instead. """
|
|
113
|
+
warnings.warn(
|
|
114
|
+
"Rois.__setitem__ (rois[name] = ...) is deprecated, use .set() instead.",
|
|
115
|
+
DeprecationWarning,
|
|
116
|
+
stacklevel=2,
|
|
117
|
+
)
|
|
118
|
+
start, stop, *detectors = value
|
|
119
|
+
self.set(name, (start, stop), *detectors)
|
|
120
|
+
|
|
121
|
+
def __delitem__(self, name):
|
|
122
|
+
""" del rois[name] is equivalent to rois.remove(name).
|
|
123
|
+
|
|
124
|
+
Deprecated: use `.remove()` instead. """
|
|
125
|
+
warnings.warn(
|
|
126
|
+
"Rois.__delitem__ (del rois[name]) is deprecated, use .remove() instead.",
|
|
127
|
+
DeprecationWarning,
|
|
128
|
+
stacklevel=2,
|
|
129
|
+
)
|
|
130
|
+
self.remove(name)
|
|
131
|
+
|
|
107
132
|
def set_sum(self, name, bin_range, *detectors):
|
|
108
133
|
"""
|
|
109
134
|
Add sum of rois on the provided detectors, or on all
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|