virocon.utils module¶
Various functions that do not fit in an existing module.
- virocon.utils.calculate_design_conditions(contour, steps: list | int = None, swap_axis=False) ArrayLike[source]¶
Calculates design conditions (relevant points for structural analysis) for a contour.
For example, in a sea state contour, one is interested in the upper Hs part for a given Tz/Tp. And one often likes to have points that are evenly spaced in the Tz/Tp direction, e.g. one Hs-Tz design condition per 0.5 s of Tz.
- Parameters:
contour (Contour) – Environmental conntour object.
steps (list of floats or int, optional) – Either a list of design conditoin x-values or the number how many steps shall be used (then the x-values will be evenly spaced). Defaults to None.
swap_axis (bool, optional) – Wheter x and y shall be swapped. Defaults to False.
- Returns:
design conditions (points for structural analysis calculations).
- Return type:
npt.ArrayLike
- virocon.utils.read_ec_benchmark_dataset(file_path=None)[source]¶
Reads an EC benchmark dataset.
Reads a text/csv file as it is used in the EC benchmark: https://github.com/ec-benchmark-organizers/ec-benchmark
- Parameters:
file_path (str) – Path to the dataset file. Defaults to the example dataset A.
- Returns:
dataset – The dataset stored in a pandas DataFrame. Use dataset.values to access the underlying numpy array.
- Return type:
pandas.DataFrame
- virocon.utils.sort_points_to_form_continuous_line(x, y, search_for_optimal_start=False)[source]¶
Sorts contour points to form a a continous line / contour.
This function simply sorts 2 dimensional points. The points are given by x and y coordinates. This function is used to sort the coordinates of 2 dimensional contours.
Thanks to https://stackoverflow.com/a/37744549
- Parameters:
x (array_like) – x-coordinate of contour points.
y (array_like) – y-coordinate of contour points.
search_for_optimal_start (boolean, optional) – If True, the algorithm also searches for the ideal starting node, see the stackoverflow link for more info. Defaults to False.
- Returns:
sorted_points – The sorted points.
- Return type:
tuple of array_like floats