pep8 + added option for plotting confidence interval in plotesf

master
Per A Brodtkorb 8 years ago
parent deef6c4994
commit f69683428a

@ -1094,14 +1094,14 @@ def findrfc_astm(tp):
sig_rfc[:,2] Cycle type, half (=0.5) or full (=1.0) sig_rfc[:,2] Cycle type, half (=0.5) or full (=1.0)
""" """
return numba_misc.findrfc_astm(tp) return numba_misc.findrfc_astm(tp)
y1 = atleast_1d(tp).ravel() # y1 = atleast_1d(tp).ravel()
sig_rfc, cnr = clib.findrfc3_astm(y1) # sig_rfc, cnr = clib.findrfc3_astm(y1)
# the sig_rfc was constructed too big in rainflow.rf3, so # # the sig_rfc was constructed too big in rainflow.rf3, so
# reduce the sig_rfc array as done originally by a matlab mex c function # # reduce the sig_rfc array as done originally by a matlab mex c function
n = len(sig_rfc) # n = len(sig_rfc)
# sig_rfc = sig_rfc.__getslice__(0, n - cnr[0]) # # sig_rfc = sig_rfc.__getslice__(0, n - cnr[0])
# sig_rfc holds the actual rainflow counted cycles, not the indices # # sig_rfc holds the actual rainflow counted cycles, not the indices
return sig_rfc[:n - cnr[0]] # return sig_rfc[:n - cnr[0]]
def findrfc(tp, h=0.0, method='clib'): def findrfc(tp, h=0.0, method='clib'):
@ -1404,18 +1404,20 @@ def mctp2tc(f_Mm, utc, param, f_mM=None):
if dim_m == 1: if dim_m == 1:
tempm[0, 0] = (Bm / (1 - Am * Bm) * em) tempm[0, 0] = (Bm / (1 - Am * Bm) * em)
else: else:
tempm = np.dot(Bm, rh = Im - np.dot(Am, Bm)
linalg.lstsq(Im-np.dot(Am, Bm), em)[0]) tempm = np.dot(Bm, linalg.lstsq(rh, em)[0])
# end # end
# end # end
# end # end
if (j > ntc) and (i < ntc): if (j > ntc) and (i < ntc):
a = np.dot(np.dot(tempp.T, f_mM[i:ntc-1, n-ntc:-1:n-j+1]), a = np.dot(np.dot(tempp.T,
f_mM[i:ntc - 1, n - ntc:-1:n - j + 1]),
tempm) tempm)
b = np.dot(np.dot(tempp.T, f_mM[i:ntc - 1, n - j:-1:1]), b = np.dot(np.dot(tempp.T, f_mM[i:ntc - 1, n - j:-1:1]),
ones((n - j, 1))) ones((n - j, 1)))
c = np.dot(np.dot(ones((1, i-1)), f_mM[1:i-1, n-ntc:-1:n-j+1]), c = np.dot(np.dot(ones((1, i - 1)),
f_mM[1:i - 1, n - ntc:-1:n - j + 1]),
tempm) tempm)
F[i, n - j + 1] = F[i, n - j + 1] + a + b + c F[i, n - j + 1] = F[i, n - j + 1] + a + b + c
# end # end
@ -1428,7 +1430,8 @@ def mctp2tc(f_Mm, utc, param, f_mM=None):
# end # end
# end # end
if (j > ntc) and (i == ntc): if (j > ntc) and (i == ntc):
c = np.dot(np.dot(ones((1, i-1)), f_mM[1:i-1, n-ntc:-1:n-j+1]), c = np.dot(np.dot(ones((1, i - 1)),
f_mM[1:i - 1, n - ntc:-1:n - j + 1]),
tempm) tempm)
F[i, n - j + 1] = F[i, n - j + 1] + c F[i, n - j + 1] = F[i, n - j + 1] + c
for k in range(ntc, n): for k in range(ntc, n):
@ -3109,7 +3112,8 @@ def test_docstrings():
# np.set_printoptions(precision=6) # np.set_printoptions(precision=6)
import doctest import doctest
print('Testing docstrings in %s' % __file__) print('Testing docstrings in %s' % __file__)
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS) doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE |
doctest.ELLIPSIS)
if __name__ == "__main__": if __name__ == "__main__":

@ -1407,7 +1407,7 @@ class FitDistribution(rv_frozen):
except Exception: except Exception:
pass pass
def plotesf(self, symb1='r-', symb2='b.', axis=None): def plotesf(self, symb1='r-', symb2='b.', axis=None, plot_ci=False):
''' Plot Empirical and fitted Survival Function ''' Plot Empirical and fitted Survival Function
The purpose of the plot is to graphically assess whether The purpose of the plot is to graphically assess whether
@ -1422,7 +1422,7 @@ class FitDistribution(rv_frozen):
axis.semilogy(self.data, sf, symb2, axis.semilogy(self.data, sf, symb2,
self.data, self.sf(self.data), symb1) self.data, self.sf(self.data), symb1)
if True: if plot_ci:
low = int(np.log10(1.0/n)-0.7) - 1 low = int(np.log10(1.0/n)-0.7) - 1
sf1 = np.logspace(low, -0.5, 7)[::-1] sf1 = np.logspace(low, -0.5, 7)[::-1]
ci1 = self.ci_sf(sf, alpha=0.05, i=2) ci1 = self.ci_sf(sf, alpha=0.05, i=2)

Loading…
Cancel
Save