Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: better calibration error tolerance checks #39

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/actipy/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,19 @@ def calibrate_gravity(data, calib_cube=0.3, calib_min_samples=50, window='10s',

# Check that we have sufficiently uniformly distributed points:
# need at least one point outside each face of the cube
if (np.max(xyz, axis=0) < calib_cube).any() \
or (np.min(xyz, axis=0) > -calib_cube).any():
if (np.max(xyz, axis=0) < calib_cube).any() or (np.min(xyz, axis=0) > -calib_cube).any():
info['CalibOK'] = 0
info['CalibErrorAfter(mg)'] = init_err * 1000

return data, info

# If initial error is already below threshold, skip and return
if init_err < ERR_TOL:
info['CalibOK'] = 1
info['CalibErrorAfter(mg)'] = init_err * 1000

return data, info

for it in range(MAXITER):

# Weighting. Outliers are zeroed out
Expand Down Expand Up @@ -369,7 +375,7 @@ def calibrate_gravity(data, calib_cube=0.3, calib_min_samples=50, window='10s',

info['CalibErrorAfter(mg)'] = best_err * 1000

if (best_err > ERR_TOL) or (it + 1 == MAXITER):
if (best_err >= ERR_TOL) or (it + 1 >= MAXITER):
info['CalibOK'] = 0

return data, info
Expand Down
Loading