Recalibrate Bento spreader 3

This commit is contained in:
admin committed 2026-10-07 16:11:46 +02:00
1 parent 1b3279662f
commit 824b1caca7
2 files changed
+21 -21

No files matched your search

+4 -4
View File
@@ -14,12 +14,12 @@ calibrations:
right: 1.75
bento1-spreader-3-bentonite:
type: linear_signal_discharge
value: 0.4691089108910891
value: 0.376
unit: kg_per_signal_unit_m
calibrated_at: 2026-09-08
calibrated_at: 2026-10-07
method: gravimetric_tray
description: Bento 1 spreader 3, bentonite
reference:
measured_application_g_m2: 618
signal_value: 3.03
measured_application_g_m2: 540
signal_value: 3.3032
line_speed_m_min: 2.3
+17 -17
View File
@@ -30,7 +30,7 @@ def configured_samples(width=5, gates=None):
gates = gates if gates is not None else [2.3, 0.3, 0, 2.3, 2.3, 2.3]
client.post_json.return_value.body = {'data': {
'columns': ['time', *config.application_signal_refs, config.gate_signal_ref],
'records': [[(NOW + timedelta(seconds=t)).isoformat(), 3.03, gate]
'records': [[(NOW + timedelta(seconds=t)).isoformat(), 3.3032, gate]
for t, gate in zip(times, gates, strict=True)],
}}
samples = EnlyzeApiGateway(client).get_material_samples(
@@ -49,15 +49,15 @@ def test_reference_and_zero():
config = load_material_calculation(CONFIG)
assert config.calibration_ref == 'bento1-spreader-3-bentonite'
factor = config.specific_discharge_kg_per_signal_unit_m
assert linear_signal_discharge_g_m2([3.03], factor, 2.3, 0.3) == pytest.approx(618, abs=0.002)
assert linear_signal_discharge_g_m2([3.3032], factor, 2.3, 0.3) == pytest.approx(540, abs=0.01)
assert linear_signal_discharge_g_m2([0], factor, 2.3, 0.3) == 0
@pytest.mark.parametrize('width', [1, 4.85, 5, 100])
def test_application_independent_of_width_and_consumption_formula(width):
samples = configured_samples(width)
assert samples[0].application_g_m2 == pytest.approx(618)
assert samples[0].material_rate_kg_per_hour == pytest.approx(618 * width * 2.3 / 1000 * 60)
assert samples[0].application_g_m2 == pytest.approx(540, abs=0.01)
assert samples[0].material_rate_kg_per_hour == pytest.approx(samples[0].application_g_m2 * width * 2.3 / 1000 * 60)
assert samples[1].application_g_m2 is None
assert samples[2].application_g_m2 is None
@@ -67,7 +67,7 @@ def test_gate_and_gap():
configured_samples())
# 0→10 and 61→71 only: inactive preceding gates and the 21s gap are excluded.
assert state.integrated_running_seconds == 20
assert state.cumulative_consumption_kg == pytest.approx(618 * 5 * 2.3 / 1000 * 20 / 60)
assert state.cumulative_consumption_kg == pytest.approx(3.3032 * 0.376 * 5 * 20 / 60)
@pytest.mark.parametrize('field,value,message', [
@@ -136,7 +136,7 @@ def test_runtime_isolation_and_disjoint_runs(tmp_path, monkeypatch):
def window(**kwargs):
assert kwargs['specific_discharge_kg_per_signal_unit_m'] == pytest.approx(
618 * 2.3 / (3.03 * 1000))
0.376)
from dataclasses import replace
return [replace(samples[0], timestamp=kwargs['start']),
replace(samples[0], timestamp=kwargs['end'])]
@@ -148,7 +148,7 @@ def test_runtime_isolation_and_disjoint_runs(tmp_path, monkeypatch):
service._application_writer = Mock()
result = service.poll_once(now=NOW + timedelta(seconds=25))
assert result.state.integrated_running_seconds == 20 # no bridging the 5s run gap
assert result.state.cumulative_consumption_kg == pytest.approx(618 * 5 * 2.3 / 1000 / 3)
assert result.state.cumulative_consumption_kg == pytest.approx(3.3032 * 0.376 * 5 / 3)
assert not fresh_path.exists() # no fresh-bentonite state or aggregation written
written_ids = {c.kwargs['calculation_id']
for c in service._application_writer.write.call_args_list}
@@ -163,19 +163,19 @@ def test_invalid_linear_inputs(signals, factor):
linear_signal_discharge_g_m2(signals, factor, 2.3, 0.3)
@pytest.mark.parametrize('signal,speed,expected', [(3.03, 2.3, 618),
(8.999, 4.999, 844.471112044191)])
@pytest.mark.parametrize('signal,speed,expected', [(3.3032, 2.3, 540),
(8.999, 4.999, 676.860172034407)])
def test_discharge_physics(signal, speed, expected):
from production_analytics.calculations.material_consumption import (
linear_signal_discharge_rate_kg_per_hour,
)
factor = load_material_calculation(CONFIG).specific_discharge_kg_per_signal_unit_m
assert factor == float(Fraction(2369, 5050))
assert factor == pytest.approx(0.376)
width = 5
flow = linear_signal_discharge_rate_kg_per_hour([signal], width, factor) / 60
application = linear_signal_discharge_g_m2([signal], factor, speed, 0.3)
assert application == pytest.approx(expected)
assert application == pytest.approx(expected, abs=0.01)
assert flow == pytest.approx(application * width * speed / 1000)
faster_application = linear_signal_discharge_g_m2([signal], factor, speed * 2, 0.3)
assert faster_application == pytest.approx(application / 2)
@@ -188,14 +188,14 @@ def test_discharge_physics(signal, speed, expected):
@pytest.mark.parametrize('speed', [0, -1, 0.3])
def test_inactive_speed(speed):
factor = load_material_calculation(CONFIG).specific_discharge_kg_per_signal_unit_m
assert linear_signal_discharge_g_m2([3.03], factor, speed, 0.3) is None
assert linear_signal_discharge_g_m2([3.3032], factor, speed, 0.3) is None
@pytest.mark.parametrize('speed', [float('nan'), float('inf')])
def test_invalid_speed(speed):
factor = load_material_calculation(CONFIG).specific_discharge_kg_per_signal_unit_m
with pytest.raises(ValueError, match='line speed'):
linear_signal_discharge_g_m2([3.03], factor, speed, 0.3)
linear_signal_discharge_g_m2([3.3032], factor, speed, 0.3)
@pytest.mark.parametrize('gate', [None, '', 0])
@@ -211,10 +211,10 @@ def test_missing_gate_config(tmp_path, gate):
def test_gateway_speed_changes_only_application():
samples = configured_samples(gates=[2.3, 4.6, 0, -1, 0.3, 2.3])
assert samples[0].application_g_m2 == pytest.approx(618)
assert samples[1].application_g_m2 == pytest.approx(309)
assert samples[0].application_g_m2 == pytest.approx(540, abs=0.01)
assert samples[1].application_g_m2 == pytest.approx(270, abs=0.01)
assert [sample.material_rate_kg_per_hour for sample in samples] == pytest.approx(
[3.03 * (2369 / 5050) * 5 * 60] * 6)
[3.3032 * 0.376 * 5 * 60] * 6)
assert all(sample.application_g_m2 is None for sample in samples[2:5])
@@ -233,4 +233,4 @@ def test_gateway_requires_valid_width(width):
@pytest.mark.parametrize('threshold', [0, -1, float('nan'), float('inf')])
def test_invalid_speed_threshold(threshold):
with pytest.raises(ValueError, match='speed gate threshold'):
linear_signal_discharge_g_m2([3.03], 2369 / 5050, 2.3, threshold)
linear_signal_discharge_g_m2([3.3032], 0.376, 2.3, threshold)