Skip to content

ocean-uhh/moordiag

Repository files navigation

Mooring Diagram Generator

Generate oceanographic mooring diagrams from YAML configuration files.

Setup

python -m venv venv
source venv/bin/activate  # activate before installing or running
pip install -r requirements.txt
pip install -e .          # install the moordiag CLI

Usage

The package installs a moordiag command with four subcommands.

moordiag hardware — detailed hardware diagram

Shows every component (shackles, ropes, floats, instruments, anchor) with HAB-based spacing so vertical positions reflect actual depths.

moordiag hardware config/dsK2_manual.mooring.yaml
moordiag hardware config/dsK2_manual.mooring.yaml -o output_dir
moordiag hardware config/dsK2_manual.mooring.yaml --hab
moordiag hardware config/dsK2_manual.mooring.yaml --dpi 150

Options:

Flag Default Description
-o, --output-dir diagrams/ Output directory
--hab / --no-hab on Show height-above-bottom labels (use --no-hab for depth)
--dpi 300 Output resolution
--debug off Print layout debug info

Output: <output_dir>/<mooring_name>.pdf (A4 pages assembled from sliced chunks)

moordiag single — streamlined single diagram

Shows instruments, floats, release, and anchor stacked by image size. Rope lengths do not affect spacing — useful for a compact at-a-glance view.

moordiag single config/dsK2_manual.mooring.yaml
moordiag single config/dsK2_manual.mooring.yaml -o output_dir
moordiag single config/dsK2_manual.mooring.yaml --no-hab

Options:

Flag Default Description
-o, --output-dir diagrams/ Output directory
--hab / --no-hab on Show height-above-bottom labels
--dpi 300 Output resolution
--debug off Print layout debug info

Output: <output_dir>/<mooring_name>_single.pdf

moordiag array — multi-mooring array diagram

Renders all moorings in an array config side-by-side on an A3 landscape page, with a metadata table (coordinates, waterdepth, instrument counts) below each.

moordiag array config/dsTriangles_2026.array.yaml
moordiag array config/dsTriangles_2026.array.yaml -o output_dir
moordiag array config/dsTriangles_2026.array.yaml --no-hab
moordiag array config/dsTriangles_2026.array.yaml --enrich

Options:

Flag Default Description
-o, --output-dir diagrams/ Output directory
--hab / --no-hab on Show HAB labels; --no-hab shows depth (waterdepth − hab)
--dpi 300 Output resolution
--enrich off Re-run enrichment even if enriched files already exist

Output: <output_dir>/<array_name>_array.pdf

moordiag enrich — pre-compute HAB values

Walks the inline: elements of a mooring config from anchor upward, accumulating the physical length of each component (shackles, ropes, floats, etc.) to compute where each element sits relative to the seabed. Adds hab_bottom and hab_top to every inline element and writes the result as *_enriched.yaml.

clamp: instruments already carry explicit hab: values and pass through unchanged.

The enriched file is what all diagram generators use — the drawing code needs absolute vertical positions to place elements correctly, and those only exist after enrichment.

moordiag enrich config/dsK1_manual.mooring.yaml
moordiag enrich config/ds*_manual.mooring.yaml        # multiple files
moordiag enrich config/dsK1_manual.mooring.yaml -o enriched_dir

Options:

Flag Default Description
-o, --output-dir same dir as source Write enriched files here instead of alongside source

Output: <source_dir>/<config_stem>_enriched.mooring.yaml (e.g. dsK1_manual_enriched.mooring.yaml; always overwrites)

Note: moordiag hardware and moordiag single re-enrich automatically on every run. moordiag array reuses existing enriched files unless --enrich is passed. Running moordiag enrich lets you pre-generate or refresh enriched files without producing a diagram.

Configuration format

Hardware YAML files use an inline / clamp structure:

name: dsK2
year: 2026
waterdepth: 925
cruise: MSM142

clamp:          # instruments clamped to the mooring rope
- clamp_id: '1'
  label: SM-p
  image: microcat.png
  hab: 633.9

inline:         # hardware components in-line on the rope (bottom → top)
- position: '47'
  label: Anchor
  hardware_type: anchor_weight
  image: anchor_wheel.png
  length: 1.0

See config/test_simple.mooring.yaml for a minimal example.

File structure

moordiag/    # Python package
  cli.py            # moordiag entry point
  hardware.py       # hardware diagram generator
  single.py         # streamlined diagram generator
  drawing.py        # matplotlib drawing primitives
  page_generator.py # per-page layout and rendering
  tools.py          # layout calculation utilities
  slicer.py         # tall-diagram → page-height chunks
  assembler.py      # chunks → A4 PDF
config/             # mooring YAML configs (MSM142 cruise data)
elements/           # PNG images for mooring hardware/instruments
diagrams/           # generated output (gitignored)

About

A package for drawing oceanographic mooring diagrams from yaml configuration files in a specified format.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors