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

commit 68b8179b97246a7707db1f67471fb7589834fc45
parent 069c769dfd327b196cb19d66da45f5687d26fb96
Author: Jean Schurger <jean@schurger.org>
Date:   Mon, 23 Nov 2026 11:10:19 -0500

Shearwater decoder: imperial logs, decompression model, dive mode, water density, tissue snapshots; validation report: second data set (127 dives, rebreather and VPM-B included); stop depth rounded on screen

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYHGrz54ML6SmzKWPfS

Diffstat:
MOpenRemoraWatch/DiveView.swift | 2+-
Mdocs/VALIDATION.md | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Mtools/shearwater_decode.py | 41+++++++++++++++++++++++++++++++++++------
3 files changed, 98 insertions(+), 23 deletions(-)

diff --git a/OpenRemoraWatch/DiveView.swift b/OpenRemoraWatch/DiveView.swift @@ -169,7 +169,7 @@ private struct DimmedDivePage: View { } if let s { if let stop = s.plan.stops.first { - Text("STOP \(Int(stop.depth)) m · \(Format.clock(Double(stop.seconds ?? stop.minutes * 60)))") + Text("STOP \(Int(stop.depth.rounded())) m · \(Format.clock(Double(stop.seconds ?? stop.minutes * 60)))") .font(.system(size: 20, weight: .bold, design: .rounded)) } else if case .running(let remaining) = s.safetyStop { Text("SAFETY \(Format.clock(remaining))").font(.system(size: 20, weight: .bold, design: .rounded)) diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md @@ -1,6 +1,7 @@ # Open Rémora — decompression engine validation against a certified dive computer -Status: 14 November 2026, version 0.2. Written to support the request for the +Status: 23 November 2026, version 0.6 (first data set: 14 November; second data set and +figures of the first one recomputed from the logged starting tissues: 23 November). Written to support the request for the full *Submerged Depth and Pressure* entitlement (40 m). The design notes are in `DESIGN.md`. ## Summary @@ -12,13 +13,16 @@ algorithm family as Shearwater dive computers. We replayed ten real dives logged pressure, and compared what the engine would have displayed to what the Petrel displayed, sample by sample (one sample every 10 s, 2,545 samples). -- **Decompression stops** (3 dives, 239 samples in deco): same stop depth on 236 samples (99 %); +- **Decompression stops** (3 dives, 240 samples in deco): same stop depth on 237 samples (99 %); stop duration within 1 minute on every sample, 0.1 min shorter on average. -- **No-decompression limit** (616 samples where the Petrel shows 30 min or less): 0.26 min +- **No-decompression limit** (616 samples where the Petrel shows 30 min or less): 0.31 min shorter than the Petrel on average, within 2 minutes on 88 % of samples. - **Entering decompression**: 0.3 to 0.8 min *before* the Petrel on all three dives. - **Tissue loading**: the Petrel logs its 16 tissue pressures about every 5 minutes; replaying - the depth profile reproduces them with an RMS error of 0.004 to 0.008 bar (102 snapshots). + the depth profile reproduces them with an RMS error of 0.008 bar (102 snapshots). +- **Second diver** (127 dives, added 23 November): tissue loading confirmed on 1,264 more + snapshots, stops confirmed on 7 more dives (835 samples in deco, never more than 1 minute + apart); one display defect found and fixed. See "Second data set". The engine is tuned to stay on the conservative side of the Petrel on average. Known deviations are listed at the end. @@ -46,11 +50,13 @@ Depth range 11 to 40 m, coldest water 8 to 23 °C depending on the dive, two rep ## Method 1. `tools/shearwater_decode.py` decodes the export: for each 10-second sample, depth, gas, - no-decompression limit, next stop depth and time, time to surface; and the dive settings - (gradient factors, surface pressure). Field layout after libdivecomputer's Shearwater parser. + no-decompression limit, next stop depth and time, time to surface; the tissue snapshots; and the + dive settings (gradient factors, decompression model, dive mode, water density, units, surface + pressure). Field layout after libdivecomputer's Shearwater parser. 2. The test `ShearwaterComparisonTests` feeds each depth sample to `DiveComputer`, exactly as the watch app does with the depth sensor, with the Petrel's gradient factors, gas and - surface pressure. Repetitive dives start from the tissue state left by the previous dive. + surface pressure and water density. A dive starts from the tissues the computer logged at its + start when it logged them, otherwise from the state left by the previous dive. 3. At every sample the engine output is compared with the Petrel's display. 4. `tools/shearwater_fit.py` separately checks tissue loading against the tissue pressures the Petrel itself logged during the dive. @@ -64,9 +70,9 @@ are in it, so the comparison can be repeated on any Shearwater export. | Dive | Enters deco (Petrel / Open Rémora) | Leaves deco | Samples in deco | Same stop depth | Stop time, mean difference | |---|---|---|---|---|---| -| 190 Fer à cheval, GF 45/95 | 15.2 / 14.8 min | 29.3 / 29.0 min | 84 | 84 | −0.06 min | +| 190 Fer à cheval, GF 45/95 | 15.2 / 14.8 min | 29.3 / 29.0 min | 84 | 84 | −0.04 min | | 192 Le Rubis, GF 85/90 | 12.3 / 12.0 min | 30.0 / 29.5 min | 104 | 101 | −0.16 min | -| 193 Le Rubis EAN30, GF 85/90 | 16.3 / 15.5 min | 25.2 / 25.0 min | 51 | 51 | −0.14 min | +| 193 Le Rubis EAN30, GF 85/90 | 16.3 / 15.5 min | 25.2 / 25.0 min | 52 | 52 | −0.12 min | Stop time never differs by more than 1 minute. On dive 192 the 3 samples with a different stop depth are the transition from the 6 m stop to the 3 m stop, which Open Rémora clears a @@ -77,11 +83,50 @@ sample (10 s); the Petrel never does. | Samples | Mean difference | Mean absolute difference | Within 2 min | |---|---|---|---| -| All, Petrel shows less than 99 min, deeper than 9 m (1,100) | +0.62 min | 2.13 min | — | -| Petrel shows 30 min or less (616) | −0.26 min | 1.32 min | 88 % | +| All, Petrel shows less than 99 min, deeper than 9 m (1,100) | +0.60 min | 2.13 min | — | +| Petrel shows 30 min or less (616) | −0.31 min | 1.33 min | 88 % | A negative difference means Open Rémora shows less time than the Petrel. +### Second data set (23 November 2026) + +A second diver's Shearwater Cloud export was replayed without touching the engine settings: 127 dives +from 2018 to 2026, down to 52.8 m, fresh and salt water, surface pressure from 946 to 1030 mbar. Only +part of it runs the algorithm of the engine, so the dives are sorted by what they can tell: + +| Dives | Computer and mode | What is compared | +|---|---|---| +| 10 | Perdix AI, open circuit, GF 30/70 and 40/85, air (2018, log in feet, no tissue snapshots) | no-decompression limit, stops | +| 49 | Perdix AI, open circuit, one nitrox mix, **VPM-B** | tissue loading only (another decompression model) | +| 6 | Perdix AI, open circuit with a switch to oxygen | nothing (the engine knows one mix) | +| 62 | Petrel 2 on a rebreather, GF 30/70, 30/85, 40/65 | tissue loading, limit and stops, with the ppO2 logged in the loop (61 dives; one trimix dive left out) | + +The rebreather dives are replayed on the planner alone, with the gradient factors of the computer, the +ppO2 it logged at each sample instead of a fixed mix (a test-only path: no app offers closed circuit), +its last stop at 6 m, and the tissues it logged at the start of the dive. + +| Check | Result | +|---|---| +| Tissue loading, open circuit (567 snapshots) | RMS 0.0065 bar | +| Tissue loading, rebreather (697 snapshots) | RMS 0.0126 bar (the ppO2 is logged to 0.01 bar) | +| Stops, rebreather (6 dives, 649 samples in deco) | same stop depth on 627 samples (97 %); stop time 0.15 min shorter on average, never more than 1 min apart; enters deco 1.5 min before the Petrel on average | +| Stops, open circuit GF 30/70 (1 dive, 186 samples) | same stop depth on 184; stop time 0.35 min shorter on average, never more than 1 min apart; leaves deco 0.8 min before the Perdix | +| No-decompression limit, rebreather (1,809 samples at 30 min or less) | 1.1 min shorter than the Petrel on average, within 2 min on 81 % | +| No-decompression limit, open circuit GF (4 dives, 482 samples at 30 min or less) | **0.14 min longer** than the Perdix on average, within 2 min on 93 % | + +The last line is the only one on the liberal side. It rests on four dives from 2018 whose starting +tissues are unknown (the replay assumes a diver saturated at the surface; the tissues the Perdix carried +from earlier dives would shorten its limit), so it was not used to change the off-gassing credit. + +Every dive was also replayed the way the watch would have gone through it (one open-circuit mix, default +gradient factors 30/70), to check that the engine never gives an absurd answer on dives outside its +scope: deeper than 40 m, two hours long, on a rebreather. This found one defect, fixed the same day: a +diver exactly on a stop in fresh water could be shown a stop depth of 2.9999999999999996 m, which the +display truncated to "2 m". On a rebreather the watch, which assumes air in open circuit, asks for stops +on 23 dives where the Petrel asks for them on 7: usable, but far too conservative to be a helpful backup +there. Against VPM-B the default 30/70 enters deco 5.6 min earlier on average, but on 3 dives of 14 it +clears the last stop 1.5 to 4 min before the Perdix: the two models do not order the same way. + ### What was tuned on this data - No-stop criterion: a direct ascent must reach the surface within the high gradient factor; @@ -95,20 +140,21 @@ A negative difference means Open Rémora shows less time than the Petrel. ## Known deviations and limits -- **Late, shallow part of long dives**: on 13 of the 616 samples Open Rémora shows 5 minutes +- **Late, shallow part of long dives**: on 12 of the 616 samples Open Rémora shows 5 minutes or more above the Petrel. There the limit is driven by slow tissues and a very small - difference in tissue pressure moves it by many minutes. Largest difference: 28 min at 12 m. + difference in tissue pressure moves it by many minutes. Largest difference: 27 min at 12 m. - **Time to surface**: the Petrel shows 3 to 5 minutes more than Open Rémora, which does not include the safety stop in that figure. Not yet confirmed as the only cause. - **Leaving deco**: 15 to 30 seconds before the Petrel on the three dives. -- **Scope**: one diver, one computer, ten dives, air and one nitrox dive, no dive deeper than - 40 m, no dive at altitude. Helium is not supported by the engine. +- **Scope**: two divers, three computers (Petrel 3, Perdix AI, Petrel 2). The no-decompression + limit in open circuit rests on 14 dives; the stops on 4 open-circuit dives and 6 rebreather dives. + No dive at altitude. Helium and gas switches are not supported by the engine. - The comparison validates the algorithm on recorded profiles. It does not validate the watch's depth sensor, which has not yet been used in water with this app. ## Other safeguards in the app -- 49 unit tests on the engine (tissue equations, limits, stops, safety stop, alarms, altitude, repetitive dives, logbook). +- 69 unit tests on the engine and the dive logic (tissue equations, limits, stops, safety stop, alarms, altitude, repetitive dives, logbook). - If the depth sensor stops reporting under water (sensor limit, error, silence), the app never assumes a return to the surface: it keeps the last known depth, keeps loading the tissues and shows "depth unknown, follow your primary computer". - Being shallower than a required stop is flagged as a violation and logged; a skipped safety stop is flagged. diff --git a/tools/shearwater_decode.py b/tools/shearwater_decode.py @@ -8,6 +8,14 @@ def records(blob): data = gzip.decompress(blob[4:]) return [data[i:i + 32] for i in range(0, len(data), 32)] +def number(text): + """Shearwater Cloud writes numbers with the locale of the phone: '5,945122' on a French one.""" + try: return float(str(text).replace(",", ".")) + except ValueError: return None + +MODES = {0: "cc", 1: "oc-tec", 2: "gauge", 3: "ppo2-gauge", 4: "sc", 5: "cc2", 6: "oc-rec", 7: "freedive"} +MODELS = {0: "GF", 1: "VPM-B", 2: "VPM-B/GFS", 3: "DCIEM"} + def decode(db_path): db = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True) details = {r[0]: r for r in db.execute("select DiveId, DiveNumber, Site, Depth, DiveLengthTime, DiveDate from dive_details")} @@ -16,21 +24,41 @@ def decode(db_path): recs = records(blob) byt = {r[0]: r for r in recs if r[0] != 0x01} o0, o1, o5 = byt.get(0x10), byt.get(0x11), byt.get(0x15) + o2, o3, o4 = byt.get(0x12), byt.get(0x13), byt.get(0x14) d = details.get(log_id) dive = { "id": log_id, "file": name, "number": d[1] if d else None, "site": d[2] if d else None, - "date": d[5] if d else None, "cloud_max_depth": float(d[3]) if d else None, + "date": d[5] if d else None, "cloud_max_depth": number(d[3]) if d else None, "gf_low": o0[4], "gf_high": o0[5], "imperial": o0[8], "surface_mbar": struct.unpack(">H", o1[16:18])[0], - "sample_ms": struct.unpack(">H", o5[23:25])[0] if o5 else None, + # Deco model, water density (kg/m³) and dive mode: opening records 2, 3 and 4. + "model": MODELS.get(o2[18], str(o2[18])) if o2 else None, + "density": struct.unpack(">H", o3[3:5])[0] if o3 else None, + "mode": MODES.get(o4[1], str(o4[1])) if o4 else None, + "computer": name.split("[")[0], + "sample_ms": (struct.unpack(">H", o5[23:25])[0] if o5 else 0) or 10000, # not logged before version 9: 10 s "raw_opening": {f"{k:02x}": v.hex() for k, v in sorted(byt.items()) if k < 0x20}, - "calc": json.loads(calc) if calc else None, "samples": [], + "calc": json.loads(calc) if calc else None, "samples": [], "tissues": [], } + # Imperial logs: depths in feet (stops every 10 ft). Everything is written in metres, the stops + # on the nearest whole metre (10 ft -> 3 m) so that they compare with a 3 m grid. + unit = 0.3048 if o0[8] else 1.0 + buf = b"" for r in recs: + if 0x70 <= r[0] <= 0x75: + # Tissue snapshot, about every 5 min (log version 13 and later): 16 nitrogen pressures + # then 16 helium pressures (bar, little-endian floats) spread over six records. + buf += r[4:32] + if r[0] == 0x75: + dive["tissues"].append({"index": len(dive["samples"]), + "n2": [round(x, 5) for x in struct.unpack("<16f", buf[:64])], + "he": [round(x, 5) for x in struct.unpack("<16f", buf[64:128])]}) + buf = b"" + continue if r[0] != 0x01: continue stop_depth = struct.unpack(">H", r[3:5])[0] dive["samples"].append({ - "depth": struct.unpack(">H", r[1:3])[0] / 10, "stop_depth": stop_depth, + "depth": round(struct.unpack(">H", r[1:3])[0] / 10 * unit, 2), "stop_depth": round(stop_depth * unit), "tts": struct.unpack(">H", r[5:7])[0], "ppo2": r[7] / 100, "o2": r[8], "he": r[9], "ndl_or_stop": r[10], "status": r[12], "temp": struct.unpack("b", r[14:15])[0], "cns": r[23], "ceiling": r[24], "gf99": r[25], @@ -49,9 +77,10 @@ if __name__ == "__main__": else: for d in dives: s = d["samples"] - print(d["number"], d["date"], d["site"], "GF", d["gf_low"], d["gf_high"], "surf", d["surface_mbar"], + print(d["number"], d["date"], d["site"], d["computer"], d["mode"], d["model"], "GF", d["gf_low"], d["gf_high"], + "density", d["density"], "ft" if d["imperial"] else "m", "surf", d["surface_mbar"], "step", d["sample_ms"], "n", len(s), "max", max(x["depth"] for x in s), "cloud", d["cloud_max_depth"], - "O2", sorted({x["o2"] for x in s}), "NDLmin", min(x["ndl_or_stop"] for x in s if x["stop_depth"] == 0), + "O2/He", sorted({(x["o2"], x["he"]) for x in s}), "snapshots", len(d["tissues"]), "NDLmin", min(x["ndl_or_stop"] for x in s if x["stop_depth"] == 0), "stops", sorted({x["stop_depth"] for x in s}), "temp", min(x["temp"] for x in s)) if len(sys.argv) > 2 and not sys.argv[2].startswith("--"): json.dump(dives, open(sys.argv[2], "w"))