moordiag
moordiag — generate engineering diagrams for oceanographic moorings from YAML configuration files.
moordiag.readers
Configuration and image loading functions for mooring diagram generator.
moordiag.tools
Calculation and data processing tools for mooring diagram generator.
- moordiag.tools.calculate_element_spacing(element, prev_element, config)[source]
Calculate spacing between two elements based on depth and repeat groups.
- moordiag.tools.calculate_hardware_move_distance(current_element, prev_element, image_metadata, config)[source]
Calculate move distance for hardware elements with fixed rope/chain heights.
- moordiag.tools.calculate_hardware_spacing(element, prev_element, config)[source]
Calculate spacing between hardware elements - zero spacing except for glass spheres.
- moordiag.tools.calculate_instrument_stack_height(instruments, image_metadata, config)[source]
Calculate total height needed for a stack of instruments using mooring spacing logic.
- moordiag.tools.calculate_layout_positions(elements, image_metadata, config, direction='bottom_up')[source]
Calculate exact layout positions for elements using bottom_up logic (like original).
- moordiag.tools.calculate_layout_positions_hardware(elements, image_metadata, config)[source]
Calculate layout positions for hardware elements.
- moordiag.tools.calculate_missing_depth_or_hab(element, waterdepth)[source]
Calculate missing depth or HAB values based on waterdepth, or recalculate depth from HAB.
- moordiag.tools.calculate_move_distance(current_element, prev_element, image_metadata, config)[source]
Calculate exact move distance between two elements using original spacing logic.
- moordiag.tools.calculate_plotted_height(elements, image_metadata, config)[source]
Calculate height span from layout positions using bottom_up (standard).
- moordiag.tools.calculate_subplot_layout(positioned_elements, image_metadata, direction, center_x, config=None)[source]
Use pre-calculated positions and adjust for left/right column placement.
- moordiag.tools.expand_repeats_hardware(elements)[source]
Expand hardware elements that have ‘repeat’ field into multiple elements.
- moordiag.tools.find_column_breaks_with_positions(elements, image_metadata, config, column_height_limit)[source]
Find where to break elements into columns and return with calculated positions.
- moordiag.tools.get_deploy_status(config)[source]
Return a display string for mooring deployment status.
Uses the ‘status’ field if present (any string is accepted; unknown values trigger a warning at validation time but are still formatted as “as <value>”). Falls back to checking seabed_latitude for backwards compatibility with configs that predate the status field.
- moordiag.tools.get_element_position_value(element, use_hab=False)[source]
Get the position value for sorting - either depth or HAB.
- moordiag.tools.get_hardware_plot_height(element, image_metadata, config)[source]
Get plotting height for hardware element - use fixed height for ropes + instruments.
- moordiag.tools.group_elements_for_splitting(elements)[source]
Group elements by their original element ID to keep repeat groups together.
- moordiag.tools.sort_elements_by_depth(elements, use_hab=False)[source]
Sort elements by depth (deep to shallow for top-to-bottom display) - simplified for regular diagrams.
- moordiag.tools.sort_elements_by_position(elements)[source]
Sort hardware elements by position number (inline first, then clamp).
- moordiag.tools.split_elements_into_pages(layout_elements, image_metadata, config)[source]
Split elements into multiple pages based on actual height calculations.
moordiag.coordinates
Coordinate formatting utilities for oceanographic mooring diagrams.
Provides CoordConverter for decimal-degrees → degrees/decimal-minutes formatting. Standalone map-bounds and cruise-track helpers archived in archive/coordinates-old202607.py.
- class moordiag.coordinates.CoordConverter[source]
Bases:
objectUtility class for coordinate unit conversions.
This class provides static methods for converting between different coordinate representations commonly used in maritime and scientific contexts.
- static decimal_degrees_to_ddm(decimal_degrees: float) tuple[float, float][source]
Convert decimal degrees to degrees and decimal minutes.
- Parameters:
decimal_degrees (float) – Coordinate in decimal degrees format.
- Returns:
Tuple of (degrees, decimal_minutes).
- Return type:
tuple of float
Examples
>>> CoordConverter.decimal_degrees_to_ddm(65.7458) (65.0, 44.75)
- static format_latitude_decmin(decimal_degrees: float) str[source]
Convert latitude to decimal minutes format.
- Parameters:
decimal_degrees (float) – Latitude in decimal degrees format.
- Returns:
Latitude in “DD MM.MMM N/S” format.
- Return type:
str
Examples
>>> CoordConverter.format_latitude_decmin(65.244) "65 14.640 N" >>> CoordConverter.format_latitude_decmin(-65.244) "65 14.640 S"
- static format_longitude_decmin(decimal_degrees: float) str[source]
Convert longitude to decimal minutes format.
- Parameters:
decimal_degrees (float) – Longitude in decimal degrees format.
- Returns:
Longitude in “DDD MM.MMM E/W” format.
- Return type:
str
Examples
>>> CoordConverter.format_longitude_decmin(-31.3177) "031 19.062 W" >>> CoordConverter.format_longitude_decmin(31.3177) "031 19.062 E"
moordiag.drawing
Drawing and visualization functions for mooring diagram generator.
- moordiag.drawing.add_continuation_indicator(ax, layout, subplot_type)[source]
Add dashed line and ‘continued…’ label to indicate mooring continues.
- moordiag.drawing.add_depth_labels(ax, layout, use_hab=False, config=None)[source]
Add depth labels to the left of each image or repeat group (shows unique depth/HAB values only).
- moordiag.drawing.add_element_labels(ax, layout, show_sample_interval=False)[source]
Add element labels to the right of each image or repeat group.
- moordiag.drawing.add_metadata_box(ax, config)[source]
Add metadata box across bottom of page with title section and table.
- moordiag.drawing.add_rope_distance_markers(ax, instrument_positions, rope_start_hab, rope_end_hab, rope_center_x)[source]
Add blue distance markers showing distances from rope ends to instruments.
- moordiag.drawing.draw_instruments_on_rope(ax, rope_element, rope_item, image_metadata, config=None, current_plot_y=None)[source]
Draw instruments positioned on an extended rope section.
- moordiag.drawing.draw_mooring_line(ax, layout, is_anchor_column=False, is_topmost_column=False, config=None)[source]
Draw the continuous mooring line behind all images with appropriate extensions.
moordiag.page_generator
Page generation and layout functions for mooring diagram generator.