Skip to content

Commit

Permalink
revert back dev changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jan 7, 2025
1 parent c35bc97 commit 9a9b9b7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions pioreactor/calibrations/stirring_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,20 @@ def run_stirring_calibration(
)
raise ValueError("Not enough RPMs were measured.")

# since in practice, we want a look up from RPM -> required DC, we
# set x=measure_rpms, y=dcs
(rpm_coef, rpm_coef_std), (intercept, intercept_std) = simple_linear_regression(
filtered_dcs, filtered_measured_rpms
)
logger.debug(f"{rpm_coef=}, {rpm_coef_std=}, {intercept=}, {intercept_std=}")
(alpha, _), (beta, _) = simple_linear_regression(filtered_dcs, filtered_measured_rpms)
logger.debug(f"rpm = {alpha:.2f} * dc% + {beta:.2f}")

if rpm_coef <= 0:
if alpha <= 0:
logger.warning("Something went wrong - detected negative correlation between RPM and stirring.")
raise ValueError("Negative correlation between RPM and stirring.")

elif intercept <= 0:
logger.warning("Something went wrong - the intercept should be greater than 0.")
raise ValueError("Intercept should be greater than 0.")

return SimpleStirringCalibration(
pwm_hz=config.getfloat("stirring.config", "pwm_hz"),
voltage=voltage_in_aux(),
calibration_name=f"stirring-calibration-{current_utc_datetime().strftime('%Y-%m-%d_%H-%M-%S')}",
calibrated_on_pioreactor_unit=unit,
created_at=current_utc_datetime(),
curve_data_=[rpm_coef, intercept],
curve_data_=[alpha, beta],
curve_type="poly",
recorded_data={"x": list(filtered_dcs), "y": list(filtered_measured_rpms)},
)

0 comments on commit 9a9b9b7

Please sign in to comment.