Skip to content

Internal Decompression Simulation & Tissue Visualization#245

Merged
kargig merged 2 commits into
mainfrom
feat/calculate_ceiling
Jun 3, 2026
Merged

Internal Decompression Simulation & Tissue Visualization#245
kargig merged 2 commits into
mainfrom
feat/calculate_ceiling

Conversation

@kargig

@kargig kargig commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

This PR integrates the octo-deco library into the Divemap backend to enable internal decompression model simulations using the Bühlmann ZH-L16 algorithm. This allows the system to automatically generate safety ceilings and rich tissue saturation analytics for dives where the computer telemetry is missing or incomplete (e.g., Suunto FIT exports or historical Subsurface XMLs).

Changes Made

Backend & Algorithm

  • Deco Service: Created deco_service.py to calculate time-series ceilings and 16-compartment tissue saturation (GF99) using octo-deco.
  • Automatic Backfilling: Implemented automatic deco generation during import and profile retrieval if data is missing.
  • GF Parsing: Added regex-based parsing to extract Gradient Factors (e.g., "GF 30/70") from dive descriptions for accurate simulations.
  • Robust FIT Importer: Hardened the Garmin FIT parser to handle missing fields gracefully and improved metadata extraction for non-Garmin devices.
  • Security Hardening: Enforced a 15MB file size limit for all dive profile and FIT uploads to mitigate memory-exhaustion DoS attacks.

Infrastructure

  • Multi-Stage Build: Refactored backend/Dockerfile to use a builder stage for compiling Cython extensions, keeping the final runtime image lean.
  • CI/CD Support: Updated docker-test-github-actions.sh to include compilers required for new dependencies.

Frontend & UI

  • Tissue Heatmap: Added a new component visualizing the evolution of saturation across all 16 Bühlmann compartments throughout the dive.
  • Saturation Chart: Added a bar chart showing the final tissue state after surfacing.
  • "Calculated" Indicators: Updated the profile chart and legend to explicitly label simulated safety data.
  • UI Compactness: Refined chart legends and vertical spacing for better visual correlation between depth and loading.

Testing

  • Added test_deco_service.py to verify the accuracy of the ZH-L16 implementation.
  • Added test_garmin_suunto_import.py to verify the robust parsing and backfilling logic.

Testing

  • Automated Tests: All new and existing tests passed in the isolated Docker environment (./docker-test-github-actions.sh).
  • Manual Verification: Successfully imported and visualized "lite" Suunto FIT files and historical Subsurface logs.
  • Comparison: Verified that calculated ceilings align with Subsurface's model while providing earlier "safety envelope" warnings.

Related Issues

  • Resolves crashes during Suunto FIT file imports.
  • Addresses missing decompression visualization for certain device exports.

Additional Notes

  • Deployment: The build process now requires gcc and build-essential in the builder stage.
  • Performance: Implemented intelligent downsampling in the frontend heatmap to maintain responsiveness with high-frequency logs.

kargig added 2 commits June 3, 2026 00:44
Enable internal Bühlmann ZH-L16 decompression simulations using the
`octo-deco` library. This allows Divemap to generate safety ceilings
for dives where the computer telemetry is missing (e.g., Suunto FIT
exports).

Key changes:
- Create `deco_service.py` to calculate time-series ceilings.
- Automate deco backfilling during import and profile retrieval.
- Parse Gradient Factors (GF) from dive descriptions as a fallback.
- Robustify Garmin FIT parser to handle missing fields gracefully.
- Refactor `Dockerfile` to multi-stage build for efficient compilation
  of Cython extensions without bloating the runtime image.
- Remove `--only-binary=all` to support source package installation.
- Display "Calculated" indicators in the frontend profile chart.
- Add unit tests for deco logic and Suunto-style imports.
- Adjust TissueHeatmap height and color scale for better visibility
  of ongassing activity across all compartments.
- Align tissue graphs horizontally with the main dive profile chart
  by accounting for the temperature axis margin.
- Reduce vertical spacing and borders in DiveDetail to bring
  simulated safety data closer to the depth profile.
- Apply minor formatting fixes to App.jsx routing.
@kargig kargig force-pushed the feat/calculate_ceiling branch from ac54009 to fdebe4b Compare June 3, 2026 06:20
@kargig kargig merged commit 35af1d5 into main Jun 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant