Skip to content

Commit

Permalink
Merge pull request #67 from MET-OM/optimization
Browse files Browse the repository at this point in the history
Optimization
  • Loading branch information
KonstantinChri authored Nov 25, 2024
2 parents dc73eaa + 5ec62da commit 7675609
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1,167 deletions.
15 changes: 9 additions & 6 deletions metocean_stats/stats/aux_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,15 @@ def find_percentile(data,pdf_Hs_Tp,h,t,p,periods,interval):
for i in range(index_X):
pdf_Hs_Tp_X = pdf_Hs_Tp[i,:] # Find pdf at RVE of X year
sum_pdf = sum(pdf_Hs_Tp_X)
for j in range(len(pdf_Hs_Tp_X)):
if (sum(pdf_Hs_Tp_X[:j])/sum_pdf <= p/100) and (sum(pdf_Hs_Tp_X[:j+1])/sum_pdf >= p/100) :
#print (i, h[i],j,t[j])
t1.append(t[j])
h1.append(h[i])
break

# Create a normalized cumulative array of pdf_Hs_Tp_X
cumulative_pdf = np.cumsum(pdf_Hs_Tp_X) / np.sum(pdf_Hs_Tp_X)

# Find the location where p/100 fits in the array
j = np.searchsorted(cumulative_pdf,p/100)

t1.append(t[j])
h1.append(h[i])
h1=np.asarray(h1)
t1=np.asarray(t1)

Expand Down
Loading

0 comments on commit 7675609

Please sign in to comment.