7
7
import matplotlib .pylab as plt
8
8
from os .path import join
9
9
from mhkit .utils import convert_to_dataarray
10
+ import warnings
10
11
11
12
12
13
def capture_length (P , J , to_pandas = True ):
@@ -99,12 +100,14 @@ def _performance_matrix(X, Y, Z, statistic, x_centers, y_centers):
99
100
100
101
# Convert bin centers to edges
101
102
xi = [np .mean ([x_centers [i ], x_centers [i + 1 ]]) for i in range (len (x_centers ) - 1 )]
102
- xi .insert (0 , - np .inf )
103
- xi .append (np .inf )
103
+ xi .insert (0 , np .float64 (0 ))
104
+ xi_end = (x_centers [- 1 ] + np .diff (x_centers [- 2 :])/ 2 )[0 ]
105
+ xi .append (xi_end )
104
106
105
107
yi = [np .mean ([y_centers [i ], y_centers [i + 1 ]]) for i in range (len (y_centers ) - 1 )]
106
- yi .insert (0 , - np .inf )
107
- yi .append (np .inf )
108
+ yi .insert (0 , np .float64 (0 ))
109
+ yi_end = (y_centers [- 1 ] + np .diff (y_centers [- 2 :])/ 2 )[0 ]
110
+ yi .append (yi_end )
108
111
109
112
# Override standard deviation with degree of freedom equal to 1
110
113
if statistic == "std" :
@@ -121,6 +124,14 @@ def _frequency(a):
121
124
X , Y , Z , statistic , bins = [xi , yi ], expand_binnumbers = False
122
125
)
123
126
127
+ # Warn if the X (Hm0) or Y (Te) spacing is greater than the IEC TS 62600-100 Ed. 2.0 en 2024 maxima (0.5m, 1.0s).
128
+ dx_edge = np .diff (x_edge )
129
+ if np .any (dx_edge > 0.5 ):
130
+ warnings .warn ("Matrix bin widths are greater than the IEC TS 62600-100 limit of 0.5 meters." )
131
+ dy_edge = np .diff (y_edge )
132
+ if np .any (dy_edge > 0.5 ):
133
+ warnings .warn ("Matrix bin widths are greater than the IEC TS 62600-100 limit of 1.0 seconds." )
134
+
124
135
M = xr .DataArray (
125
136
data = zi ,
126
137
dims = ["x_centers" , "y_centers" ],
0 commit comments