remora-kit

RemoraKit, shared dive computer engine (Buhlmann ZHL-16C + GF) and SwiftUI components for Open Remora and Open Merou
git clone https://git.schurger.org/remora-kit.git
Log | Files | Refs | README | LICENSE

commit 6da8108ca9a1a701d0401495f986eacf25e5ed80
parent 635e7affbd67c846df1669ce4fb6bd0c0dd9d432
Author: Jean Schurger <jean@schurger.org>
Date:   Mon, 23 Nov 2026 11:44:14 -0500

Shearwater comparison: one anonymous ROW line per replayed dive (diver letter and rank) for the validation report

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

Diffstat:
MTests/RemoraDecoTests/ShearwaterComparisonTests.swift | 28++++++++++++++++++++++++++++
1 file changed, 28 insertions(+), 0 deletions(-)

diff --git a/Tests/RemoraDecoTests/ShearwaterComparisonTests.swift b/Tests/RemoraDecoTests/ShearwaterComparisonTests.swift @@ -33,6 +33,7 @@ struct ShearwaterDive: Decodable { let model: String? // "GF", "VPM-B"… let mode: String? // "oc-rec", "oc-tec", "cc"… let density: Int? // kg/m³ + let computer: String? // model name let samples: [Sample] let tissues: [Tissues]? @@ -91,7 +92,12 @@ struct ShearwaterComparisonTests { var previous: (end: Date, tissues: TissueState)? var totals: [ShearwaterDive.Kind: Totals] = [:] + // Anonymous dive identifiers for the validation report: a letter per diver (SHEARWATER_DIVER) and + // the rank of the dive in the export. The ROW lines feed tools/validation_tables.py (Open Rémora). + let diver = ProcessInfo.processInfo.environment["SHEARWATER_DIVER"] ?? "A" + var rank = 0 for dive in dives where !dive.samples.isEmpty { + rank += 1 let start = try #require(dates.date(from: dive.date)) // A rebreather dive is replayed twice: as the watch would see it, then with the logged ppO2. var kinds = [dive.kind] @@ -227,6 +233,28 @@ struct ShearwaterComparisonTests { t.decoOnlyTheirs, t.decoOnlyOurs, longest.stop, longest.tts)) if ProcessInfo.processInfo.environment["SHEARWATER_ROWS"] != nil { stopRows.forEach { print($0) } } } + do { + func f(_ v: Double?) -> String { v.map { String(format: "%.1f", $0) } ?? "" } + let within2 = t.shortNDL.filter { abs($0) <= 2 }.count + let fields: [String] = [ + "ROW", String(format: "%@%03d", diver, rank), String(dive.date.prefix(4)), dive.computer ?? "", + dive.mode ?? "", dive.model ?? "GF", "\(dive.gf_low)/\(dive.gf_high)", + Set(dive.samples.map { "\($0.o2)/\($0.he ?? 0)" }).sorted().joined(separator: "+"), + String(format: "%.1f", deepest), String(format: "%.0f", Double(dive.samples.count) * step / 60), + "\(dive.surface_mbar)", "\(Int(density))", origin, "\(kind)", + "\(Int(config.deco.gradientFactors.low * 100 + 0.5))/\(Int(config.deco.gradientFactors.high * 100 + 0.5))", + "\(t.tissueErrors.count / 16)", String(format: "%.8f", t.tissueErrors.map { $0 * $0 }.reduce(0, +)), + "\(t.ndl.count)", String(format: "%.0f", t.ndl.reduce(0, +)), + "\(t.shortNDL.count)", String(format: "%.0f", t.shortNDL.reduce(0, +)), + String(format: "%.0f", t.shortNDL.map { abs($0) }.reduce(0, +)), "\(within2)", "\(t.liberal)", "\(t.zeroEarly)", + f(enter.theirs), f(enter.ours), f(leave.theirs), f(leave.ours), + "\(t.decoBoth)", "\(t.decoSameDepth)", String(format: "%.0f", t.stopMinutes.reduce(0, +)), + String(format: "%.0f", t.stopMinutes.max(by: { abs($0) < abs($1) }) ?? 0), + "\(t.decoOnlyTheirs)", "\(t.decoOnlyOurs)", "\(longest.stop)", String(format: "%.0f", longest.tts), + "\(Int(config.deco.lastStopDepth))", + ] + print(fields.joined(separator: ";")) + } if enter.theirs != nil { t.decoDivesTheirs = 1 } if enter.ours != nil { t.decoDivesOurs = 1 } if let a = enter.theirs, let b = enter.ours { t.enterDiffs.append(b - a) }