Skip to content

Commit

Permalink
Merge pull request #1 from ssolson/loads
Browse files Browse the repository at this point in the history
Loads Review
  • Loading branch information
hivanov-nrel authored Jun 23, 2020
2 parents 921a493 + 11955bf commit 398f5af
Show file tree
Hide file tree
Showing 19 changed files with 660,383 additions and 31,581 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1,242 changes: 1,178 additions & 64 deletions examples/loads_example.ipynb

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions mhkit/loads.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# import statements
import pandas as pd
import numpy as np
import fatpack #### this is a 3rd party module used for rainflow counting
from scipy.stats import binned_statistic
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import fatpack

################ general functions

def bin_stats(df,x,bin_edges,statlist=[]):
"""
Expand Down Expand Up @@ -83,7 +81,7 @@ def bin_stats(df,x,bin_edges,statlist=[]):

################ fatigue functions

def damage_equivalent_load(var, m, binNum=100, t=600):
def damage_equivalent_load(var, m, bin_num=100, t=600):
""" Calculates the damage equivalent load of a single variable
Parameters:
Expand All @@ -94,7 +92,7 @@ def damage_equivalent_load(var, m, binNum=100, t=600):
m : float/int
fatigue slope factor of material
binNum : int
bin_num : int
number of bins for rainflow counting method (minimum=100)
t : float/int
Expand All @@ -112,14 +110,14 @@ def damage_equivalent_load(var, m, binNum=100, t=600):
pass
assert isinstance(var, np.ndarray), 'var must be of type np.ndarray'
assert isinstance(m, (float,int)), 'm must be of type float or int'
assert isinstance(binNum, (float,int)), 'binNum must be of type float or int'
assert isinstance(bin_num, (float,int)), 'bin_num must be of type float or int'
assert isinstance(t, (float,int)), 't must be of type float or int'

# find rainflow ranges
ranges = fatpack.find_rainflow_ranges(var)

# find range count and bin
Nrf, Srf = fatpack.find_range_count(ranges,binNum)
Nrf, Srf = fatpack.find_range_count(ranges, bin_num)

# get DEL
DELs = Srf**m * Nrf / t
Expand All @@ -130,7 +128,7 @@ def damage_equivalent_load(var, m, binNum=100, t=600):

################ plotting functions

def statplotter(x,vmean,vmax,vmin,vstdev=[],xlabel=None,ylabel=None,title=None,savepath=None):
def plot_statistics(x,vmean,vmax,vmin,vstdev=[],xlabel=None,ylabel=None,title=None,savepath=None):
"""
plot showing standard raw statistics of variable
Expand Down Expand Up @@ -189,7 +187,7 @@ def statplotter(x,vmean,vmax,vmin,vstdev=[],xlabel=None,ylabel=None,title=None,s
plt.close()


def binplotter(bcenters,bmean,bmax,bmin,bstdmean,bstdmax,bstdmin,xlabel=None,ylabel=None,title=None,savepath=None):
def plot_bin_statistics(bcenters,bmean,bmax,bmin,bstdmean,bstdmax,bstdmin,xlabel=None,ylabel=None,title=None,savepath=None):
"""
plot showing standard binned statistics of single variable
Expand Down Expand Up @@ -235,4 +233,4 @@ def binplotter(bcenters,bmean,bmax,bmin,bstdmean,bstdmax,bstdmin,xlabel=None,yla
if savepath==None: plt.show()
else:
fig.savefig(savepath)
plt.close()
plt.close()
30,001 changes: 0 additions & 30,001 deletions mhkit/tests/data/data_loads.csv

This file was deleted.

23 changes: 0 additions & 23 deletions mhkit/tests/data/data_loads_binmaxs.csv

This file was deleted.

23 changes: 0 additions & 23 deletions mhkit/tests/data/data_loads_binmaxs_std.csv

This file was deleted.

Loading

0 comments on commit 398f5af

Please sign in to comment.