Moved quadratic function to utilities file

This commit is contained in:
Chish36 2025-07-29 12:28:20 +01:00 committed by Julian Stirling
parent d494761cbb
commit 38906c8fff
2 changed files with 12 additions and 11 deletions

View file

@ -13,6 +13,7 @@ import cv2
import json
from PIL import Image
import time
from ..utilities import quadratic
from scipy.optimize import curve_fit
from camera_stage_mapping import fft_image_tracking
from labthings_fastapi.thing import Thing
@ -30,17 +31,6 @@ CamDep = direct_thing_client_dependency(StreamingPiCamera2, "/camera/")
CSMDep = direct_thing_client_dependency(CameraStageMapper, "/camera_stage_mapping/")
AutofocusDep = direct_thing_client_dependency(AutofocusThing, "/autofocus/")
def quadratic(x, a, b, c):
"""Quadratic function. Used for predicting z.
:param x: The points at which to evaluate the quadratic.
:param a: The coefficient of x^2.
:param b: The coefficient of x.
:param c: The constant coefficient.
:return: The quadratic, evaluated at each point in ``x``
"""
return a * x**2 + b * x + c
def generate_move_dicts(fov_perc: int, stream_resolution: list[int], direction: int, factor: float = 1) -> dict[str, float]:
"""Create a single dictionary of x and y moves for moving in image coordinates.

View file

@ -327,3 +327,14 @@ def _get_version_from_toml(toml_path: str) -> str:
except (IOError, ValueError, KeyError):
LOGGER.error("Problem opening pyproject.toml")
return "Undefined"
def quadratic(x, a, b, c):
"""Quadratic function. Used for predicting z.
:param x: The points at which to evaluate the quadratic.
:param a: The coefficient of x^2.
:param b: The coefficient of x.
:param c: The constant coefficient.
:return: The quadratic, evaluated at each point in ``x``
"""
return a * x**2 + b * x + c