Mooring Module

The mooring module contains a set of functions to read MoorDyn output files and calculate lay length of a mooring line.

IO

This module provides functions to read and parse MoorDyn output files.

The main function read_moordyn takes as input the path to a MoorDyn output file and optionally the path to a MoorDyn input file. It reads the data from the output file, stores it in an xarray dataset, and then if provided, parses the input file for additional metadata to store as attributes in the dataset.

The helper function _moordyn_input is used to parse the MoorDyn output file. It loops through each line in the output file, parses various sets of properties and parameters, and stores them as attributes in the provided dataset.

Typical usage example:

dataset = read_moordyn(filepath=”FAST.MD.out”, input_file=”FAST.MD.input”)

read_moordyn

Reads in MoorDyn OUT files such as "FAST.MD.out" and "FAST.MD.Line1.out" and stores inside xarray.

mhkit.mooring.io.read_moordyn(filepath, input_file=None)[source]

Reads in MoorDyn OUT files such as “FAST.MD.out” and “FAST.MD.Line1.out” and stores inside xarray. Also allows for parsing and storage of MoorDyn input file as attributes inside the xarray.

Parameters:
  • filepath (str) – Path to MoorDyn OUT file

  • inputfile (str (optional)) – Path to MoorDyn input file

Returns:

xr.Dataset – Dataset containing parsed MoorDyn OUT file

Raises:

TypeError – Checks for correct input types for filepath and input_file

Graphics

This module provides a function for creating animated visualizations of a MoorDyn node position dataset using the matplotlib animation API.

It includes the main function animate, which creates either 2D or 3D animations depending on the input parameters.

In the animations, the position of nodes in the MoorDyn dataset are plotted over time, allowing the user to visualize how these positions change.

This module also includes several helper functions that are used by animate to validate inputs, generate lists of nodes along each axis, calculate plot limits, and set labels and titles for plots.

The user can specify various parameters for the animation such as the dimension (2D or 3D), the axes to plot along, the plot limits for each axis, the interval between frames, whether the animation repeats, and the labels and title for the plot.

Requires: - matplotlib - xarray

animate

Graphics function that creates a 2D or 3D animation of the node positions of a mooring line over time.

mhkit.mooring.graphics.animate(dsani, dimension='2d', xaxis='x', yaxis='z', zaxis='y', xlim=None, ylim=None, zlim=None, interval=10, repeat=False, xlabel=None, ylabel=None, zlabel=None, title=None)[source]

Graphics function that creates a 2D or 3D animation of the node positions of a mooring line over time.

Parameters:
  • dsani (xr.Dataset) – Xarray dataset object containing MoorDyn node variables (ie ‘Node0px’)

  • dimension (str, optional) – Dimension of animation (‘2d’ or ‘3d’), by default ‘2d’

  • xaxis (str, optional) – lowercase letter of node axis to plot along x-axis, by default ‘x’

  • yaxis (str, optional) – lowercase latter of node axis to plot along y-axis, by default ‘z’

  • zaxis (str, optional) – lowercase latter of node axis to plot along z-axis, by default ‘y’ (only used in 3d)

  • xlim (list, optional) – Two element list for plot: [min x-axis limit, max x-axis limit], by default None

  • ylim (list, optional) – Two element list for plot: [min y-axis limit, max y-axis limit], by default None

  • zlim (list, optional) – Two element list for plot: [min z-axis limit, max z-axis limit], by default None (only used in 3d)

  • interval (int, optional) – Delay between frames in milliseconds, by default 10

  • repeat (bool, optional) – Whether the animation repeats when the sequence of frames is completed, by default False

  • xlabel (str, optional) – X-label for plot, by default None

  • ylabel (str, optional) – Y-label for plot, by default None

  • zlabel (str, optional) – Z-label for plot, by default None (only used in 3d)

  • title (str, optional) – Set title of plot, by default None

Returns:

matplotlib.animation.FuncAnimation – Animation object

Raises:

TypeError – Checks for correct input types for dsani, dimension, xaxis, yaxis, zaxis, xlim, ylim, zlim, interval, repeat, xlabel, ylabel, zlabel, and title