|
11 | 11 | import numpy as np |
12 | 12 | from bluesky.callbacks import CallbackBase, LiveFitPlot |
13 | 13 | from bluesky.callbacks import LiveFit as _DefaultLiveFit |
14 | | -from bluesky.callbacks.core import CollectThenCompute, make_class_safe |
| 14 | +from bluesky.callbacks.core import make_class_safe |
15 | 15 | from event_model import Event, EventDescriptor, RunStart, RunStop |
16 | 16 | from lmfit import Parameter |
17 | 17 | from matplotlib.axes import Axes |
|
26 | 26 | get_instrument, |
27 | 27 | ) |
28 | 28 | from ibex_bluesky_core.fitting import FitMethod |
29 | | -from ibex_bluesky_core.utils import center_of_mass_of_area_under_curve |
30 | 29 |
|
31 | 30 | logger = logging.getLogger(__name__) |
32 | 31 |
|
33 | | -__all__ = ["CentreOfMass", "ChainedLiveFit", "LiveFit", "LiveFitLogger"] |
| 32 | +__all__ = ["ChainedLiveFit", "LiveFit", "LiveFitLogger"] |
34 | 33 |
|
35 | 34 |
|
36 | 35 | @make_class_safe(logger=logger) # pyright: ignore (pyright doesn't understand this decorator) |
@@ -256,54 +255,6 @@ def write_fields_table_uncertainty(self) -> None: |
256 | 255 | self.csvwriter.writerows(rows) |
257 | 256 |
|
258 | 257 |
|
259 | | -class CentreOfMass(CollectThenCompute): |
260 | | - """Compute centre of mass after a run finishes. |
261 | | -
|
262 | | - Calculates the CoM of the 2D region bounded by min(y), min(x), max(x), |
263 | | - and straight-line segments joining (x, y) data points with their nearest |
264 | | - neighbours along the x axis. |
265 | | - """ |
266 | | - |
267 | | - def __init__(self, x: str, y: str) -> None: |
268 | | - """Initialise the callback. |
269 | | -
|
270 | | - Args: |
271 | | - x: Name of independent variable in event data |
272 | | - y: Name of dependent variable in event data |
273 | | -
|
274 | | - """ |
275 | | - super().__init__() |
276 | | - self.x: str = x |
277 | | - self.y: str = y |
278 | | - self._result: float | None = None |
279 | | - |
280 | | - @property |
281 | | - def result(self) -> float | None: |
282 | | - return self._result |
283 | | - |
284 | | - def compute(self) -> None: |
285 | | - """Calculate statistics at the end of the run.""" |
286 | | - x_values = [] |
287 | | - y_values = [] |
288 | | - |
289 | | - for event in self._events: |
290 | | - if self.x not in event["data"]: |
291 | | - raise OSError(f"{self.x} is not in event document.") |
292 | | - |
293 | | - if self.y not in event["data"]: |
294 | | - raise OSError(f"{self.y} is not in event document.") |
295 | | - |
296 | | - x_values.append(event["data"][self.x]) |
297 | | - y_values.append(event["data"][self.y]) |
298 | | - |
299 | | - if not x_values: |
300 | | - return |
301 | | - |
302 | | - x_data = np.array(x_values, dtype=np.float64) |
303 | | - y_data = np.array(y_values, dtype=np.float64) |
304 | | - (self._result, _) = center_of_mass_of_area_under_curve(x_data, y_data) |
305 | | - |
306 | | - |
307 | 258 | class ChainedLiveFit(CallbackBase): |
308 | 259 | """Processes multiple LiveFits, each fit's results inform the next, with optional plotting. |
309 | 260 |
|
|
0 commit comments