Public Access
add FitResult fit overlays and close leaked HDF5 files after experiment stop
FitResult is a new Drawable in damaris.data with x-values independent of the measured points, so fits can be sampled on a dense grid. It is stored as its own data pool entry (e.g. "measurement/fit"), written to and read from the HDF5 data pool (damaris_type "FitResult", params as attributes), and drawn by the GUI as overlay on its measurement, including a fit parameter text box. Fits get no entry in the display tree, so measurement rows stay directly selectable. Result scripts create them via FitResult(x, y, title, source, params). Additionally, HDF5 files that experiment or result scripts left open (e.g. after a script failure) are closed when the experiment stops. pytables keeps such handles registered process-wide, which blocked reopening the dump file and the scripts' own files on the next run. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
947c4c7f8d
commit
ab943c30ae
7 files changed
+296
-5
No files matched your search
+14
-1
@@ -1,6 +1,6 @@
|
||||
import tables
|
||||
import numpy
|
||||
|
||||
# from damaris import FitResult
|
||||
r = MeasurementResult("test")
|
||||
|
||||
def result():
|
||||
@@ -16,6 +16,19 @@ def result():
|
||||
ts.write_to_hdf(h5, "/", f"adc_{num}", f"adc_{num}")
|
||||
data["fft"] = (ts+0).fft()
|
||||
r[num] = ts.y[0][0]
|
||||
if num > 4:
|
||||
x = r.get_xdata()
|
||||
y = r.get_ydata()
|
||||
coeffs = numpy.polyfit(x, y, 2)
|
||||
x_line = numpy.linspace(x.min(), x.max(), 100)
|
||||
y_line = numpy.polyval(coeffs, x_line)
|
||||
|
||||
fit = FitResult(x=x_line,
|
||||
y=y_line,
|
||||
title="Magnetization(tau) fit",
|
||||
source="test",
|
||||
params={"a": coeffs[0], "b": coeffs[1], "c": coeffs[2]})
|
||||
data["test/fit"] = fit
|
||||
data["test"] = r
|
||||
accu+=ts
|
||||
print(accu)
|
||||
|
||||
Reference in new issue
Block a user