new calib

This commit is contained in:
awe
2026-03-12 17:47:21 +03:00
parent f6a7cb5570
commit 2c3259fc59
3 changed files with 7 additions and 2 deletions

View File

@ -76,7 +76,7 @@ def build_parser() -> argparse.ArgumentParser:
default=True,
help=(
"Новый бинарный протокол: точка несет пару int32 (avg_1, avg_2), "
"а свип считается как 10**(avg_1*0.001) - 10**(avg_2*0.001)"
"а свип считается как |10**(avg_1*0.001) - 10**(avg_2*0.001)|"
),
)
parser.add_argument(

View File

@ -27,7 +27,9 @@ def log_value_to_linear(value: int) -> float:
def log_pair_to_sweep(avg_1: int, avg_2: int) -> float:
return (log_value_to_linear(avg_1) - log_value_to_linear(avg_2)) * LOG_POSTSCALER
value_1 = log_value_to_linear(avg_1)
value_2 = log_value_to_linear(avg_2)
return abs(value_1 - value_2) * LOG_POSTSCALER
class AsciiSweepParser:

View File

@ -108,6 +108,9 @@ class SweepParserCoreTests(unittest.TestCase):
self.assertAlmostEqual(events[1].y, log_pair_to_sweep(1500, 700), places=6)
self.assertEqual(events[1].aux, (1500.0, 700.0))
def test_log_pair_to_sweep_is_order_independent(self):
self.assertAlmostEqual(log_pair_to_sweep(1500, 700), log_pair_to_sweep(700, 1500), places=6)
def test_logscale_16bit_parser_uses_last_start_channel(self):
parser = LogScale16BitX2BinaryParser()
stream = _pack_log16_start(2) + _pack_log16_point(1, 100, 90)