Skip to content

Commit cb989b2

Browse files
move this downstream
1 parent 2d4e807 commit cb989b2

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
- An `Event Logs` page for seeing the logs generated by your Pioreactors
66
- A detailed overview of your cluster's leader-specific duties on the new `Leader`'s page.
77
- See the Leader's filesystem, logs, update cluster clocks, and view important running jobs.
8-
- View different Pioreactors' plugins on the `Plugins` page, and install to specific Pioreactor vs entire cluster.
9-
- Manage your calibrations from the UI's new `Calibrations` page.
10-
- View existing calibrations, set active calibrations, and download calibration files.
8+
- View different Pioreactors' plugins on the `Plugins` page, and install to specific Pioreactor vs entire cluster.
9+
- Manage your calibrations from the UI's new `Calibrations` page.
10+
- View existing calibrations, set active calibrations, and download calibration files.
1111
- New calibrations API. A calibration now creates a YAML file as an artifact, stored in `~/.pioreactor/calibrations`. This makes editing, creating, sharing, and transferring calibrations much easier.
1212
- There's also a new CLI for calibrations:
1313
```
@@ -24,6 +24,7 @@
2424
list List existing calibrations for the given device.
2525
run Run an interactive calibration assistant for a specific device.
2626
set-active Mark a specific calibration as 'active' for that device
27+
analyze Analyze the data from a calibration.
2728
```
2829
2930
For example, to run a pump calibration, use `pio calibrations run --device media_pump`. View all your media pump calibrations with: `pio calibrations list --device media_pump`. And to duplicate a
@@ -70,6 +71,7 @@
7071
### Enhancements
7172
- new SQL table for `historical_experiment_assignments` that stores historical assignments to experiments.
7273
- UI performance improvements
74+
- Better terminal plots
7375
7476
### Breaking changes
7577
- `use_calibration` under `od_reading.config` is deprecated. Use the calibrations "active" state instead.
@@ -97,9 +99,9 @@
9799
- removed `pioreactor.utils.gpio_helpers`
98100

99101
### Bug fixes
100-
- fix PWM3 not cleaning up correctly
101-
- fixed Stirring not updating to best DC % when using a calibration after changing target RPM
102-
102+
- Fix PWM3 not cleaning up correctly
103+
- Fixed Stirring not updating to best DC % when using a calibration after changing target RPM
104+
- Fixed a bug that could cause OD calibrations to map a small voltage value to a max OD.
103105

104106
### 24.12.10
105107
- Hotfix for UI settings bug

pioreactor/background_jobs/od_reading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def hydate_models(self, calibration_data: structs.ODCalibration | None) -> None:
660660
f"Using OD calibration `{name}` for channel {channel}, {calibration_data.curve_type=}, {calibration_data.curve_data_=}"
661661
)
662662

663-
def _hydrate_model(self, calibration_data: structs.ODCalibration) -> Callable[[float], float]:
663+
def _hydrate_model(self, calibration_data: structs.ODCalibration) -> Callable[[pt.Voltage], pt.OD]:
664664
if calibration_data.curve_type == "poly":
665665
"""
666666
Finds the smallest root in the range [minOD, maxOD] calibrated against.

pioreactor/calibrations/utils.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def calculate_poly_curve_of_best_fit(x: list[float], y: list[float], degree: int
3131
weights = np.ones_like(x)
3232
weights[0] = n / 2
3333

34-
x, y = zip(*sorted(zip(x, y), key=lambda t: t[0]))
34+
x, y = zip(*sorted(zip(x, y), key=lambda t: t[0])) # type: ignore
3535

3636
try:
3737
coefs = np.polyfit(x, y, deg=degree, w=weights)
@@ -65,6 +65,17 @@ def curve_callable(x):
6565
raise NotImplementedError()
6666

6767

68+
def linspace(start: float, stop: float, num: int = 50):
69+
num = int(num)
70+
start = start * 1.0
71+
stop = stop * 1.0
72+
73+
step = (stop - start) / (num - 1)
74+
75+
for i in range(num):
76+
yield start + step * i
77+
78+
6879
def plot_data(
6980
x: list[float],
7081
y: list[float],
@@ -81,7 +92,10 @@ def plot_data(
8192
plt.clf()
8293

8394
if interpolation_curve:
84-
plt.plot(sorted(x), [interpolation_curve(x_) for x_ in sorted(x)], color=204)
95+
x_min, x_max = min(x) - 0.1, max(x) + 0.1
96+
xs = list(linspace(x_min, x_max, num=100))
97+
ys = [interpolation_curve(x_) for x_ in xs]
98+
plt.plot(xs, ys, color=204)
8599
plt.plot_size(145, 26)
86100

87101
plt.scatter(x, y, marker="hd")

pioreactor/structs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def ipredict(self, y: Y, enforce_bounds=False) -> X:
205205
from pioreactor.utils.math_helpers import closest_point_to_domain
206206

207207
poly = self.curve_data_
208-
min_X, max_X = min(self.recorded_data["x"]), max(self.recorded_data["x"])
209208

210209
coef_shift = zeros_like(poly)
211210
coef_shift[-1] = y
@@ -221,6 +220,7 @@ def ipredict(self, y: Y, enforce_bounds=False) -> X:
221220
if not enforce_bounds:
222221
return sol
223222

223+
min_X, max_X = min(self.recorded_data["x"]), max(self.recorded_data["x"])
224224
# if we are here, we let the downstream user decide how to proceed
225225
if min_X <= sol <= max_X:
226226
return sol

pioreactor/tests/test_od_calibration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def test_linear_data_produces_linear_curve_in_range_even_if_high_degree() -> Non
2929

3030

3131
def test_mandys_data_for_pathological_poly() -> None:
32+
# https://forum.pioreactor.com/t/very-low-od-readings-map-to-max/630/5
3233
od = [0.0, 0.139, 0.155, 0.378, 0.671, 0.993, 1.82, 4.061]
3334
v = [0.0, 0.0158, 0.0322, 0.0589, 0.1002, 0.1648, 0.4045, 0.5463]
3435

0 commit comments

Comments
 (0)