open-remora

Open Remora, a free secondary dive computer for Apple Watch Ultra
git clone https://git.schurger.org/open-remora.git
Log | Files | Refs | README | LICENSE

shearwater_implied.py (1251B)


      1 # SPDX-License-Identifier: GPL-2.0-only
      2 """Implied surfacing GF: for each tissue snapshot, which GF reproduces the displayed no-decompression time?
      3 Usage: python3 -I shearwater_implied.py path/dive_data.db"""
      4 import os, sys
      5 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))   # tools folder, separate from the data
      6 from shearwater_fit import load, ndl
      7 
      8 dives = load(sys.argv[1])
      9 vapour, density = 0.0627, 1020
     10 bar_m = density * 9.80665 / 1e5
     11 for d in dives:
     12     seen_deco = False
     13     out = []
     14     snaps = dict(d["snaps"][1:])
     15     for i, s in enumerate(d["samples"], 1):
     16         if s["stop"]: seen_deco = True
     17         if i not in snaps or s["stop"] or not (0 < s["ndl"] < 99) or s["depth"] < 9: continue
     18         p = d["surface"] + s["depth"] * bar_m
     19         res = []
     20         for credit in (False, True):
     21             best = None
     22             for g in range(40, 131):
     23                 v = ndl(snaps[i], p, d["surface"], 1 - s["o2"], g / 100, vapour, credit, bar_m)
     24                 if best is None or abs(v - s["ndl"]) < abs(best[1] - s["ndl"]): best = (g, v)
     25             res.append(best[0])
     26         out.append(f"{'AFTER' if seen_deco else ''}{s['depth']}m/{s['ndl']}min→{res[0]}|{res[1]}")
     27     print(d["name"], "GF", d["gf"], " ".join(out))