Deleted misc.hypgf function

refactored:
 misc.findoutliers
objects.TimeSeries.wave_periods
master
Per A Brodtkorb 9 years ago
parent f1dc17a9fa
commit 884a5588ba

File diff suppressed because it is too large Load Diff

@ -17,7 +17,7 @@ from .transform.core import TrData
from .transform.estimation import TransformEstimator from .transform.estimation import TransformEstimator
from .stats import distributions from .stats import distributions
from .misc import (nextpow2, findtp, findrfc, findtc, findcross, from .misc import (nextpow2, findtp, findrfc, findtc, findcross,
ecross, JITImport, DotDict, gravity, findrfc_astm) ecross, JITImport, DotDict, gravity, findrfc_astm)
from .interpolate import stineman_interp from .interpolate import stineman_interp
from .containers import PlotData from .containers import PlotData
from .plotbackend import plotbackend from .plotbackend import plotbackend
@ -1657,6 +1657,58 @@ class TimeSeries(PlotData):
return S, H return S, H
@staticmethod
def _default_index(x, vh, wdef, pdef):
if pdef in ('m2m', 'm2M', 'M2m', 'M2M'):
index = findtp(x, vh, wdef)
elif pdef in ('u2u', 'u2d', 'd2u', 'd2d'):
index = findcross(x, vh, wdef)
elif pdef in ('t2t', 't2c', 'c2t', 'c2c'):
index = findtc(x, vh, wdef)[0]
elif pdef in ('d2t', 't2u', 'u2c', 'c2d', 'all'):
index, v_ind = findtc(x, vh, wdef)
# sorting crossings and tp in sequence
index = sort(r_[index, v_ind])
else:
raise ValueError('Unknown pdef option!')
return index
def _get_start_index(self, pdef, down_crossing_or_max):
if down_crossing_or_max:
if pdef in ('d2t', 'M2m', 'c2t', 'd2u', 'M2M', 'c2c', 'd2d', 'all'):
start = 1
elif pdef in ('t2u', 'm2M', 't2c', 'u2d', 'm2m', 't2t', 'u2u'):
start = 2
elif pdef in ('u2c'):
start = 3
elif pdef in ('c2d'):
start = 4
else:
raise ValueError('Unknown pdef option!')
# else first is up-crossing or min
elif pdef in ('all', 'u2c', 'm2M', 't2c', 'u2d', 'm2m', 't2t', 'u2u'):
start = 0
elif pdef in ('c2d', 'M2m', 'c2t', 'd2u', 'M2M', 'c2c', 'd2d'):
start = 1
elif pdef in ('d2t'):
start = 2
elif pdef in ('t2u'):
start = 3
else:
raise ValueError('Unknown pdef option!')
return start
def _get_step(self, pdef):
# determine the steps between wanted periods
if pdef in ('d2t', 't2u', 'u2c', 'c2d'):
step = 4
elif pdef in ('all'):
step = 1 # % secret option!
else:
step = 2
return step
def wave_periods(self, vh=None, pdef='d2d', wdef=None, index=None, rate=1): def wave_periods(self, vh=None, pdef='d2d', wdef=None, index=None, rate=1):
""" """
Return sequence of wave periods/lengths from data. Return sequence of wave periods/lengths from data.
@ -1764,50 +1816,11 @@ class TimeSeries(PlotData):
print(' The level l is set to: %g' % vh) print(' The level l is set to: %g' % vh)
if index is None: if index is None:
if pdef in ('m2m', 'm2M', 'M2m', 'M2M'): index = self._default_index(x, vh, wdef, pdef)
index = findtp(x, vh, wdef)
elif pdef in ('u2u', 'u2d', 'd2u', 'd2d'):
index = findcross(x, vh, wdef)
elif pdef in ('t2t', 't2c', 'c2t', 'c2c'):
index = findtc(x, vh, wdef)[0]
elif pdef in ('d2t', 't2u', 'u2c', 'c2d', 'all'):
index, v_ind = findtc(x, vh, wdef)
# sorting crossings and tp in sequence
index = sort(r_[index, v_ind])
else:
raise ValueError('Unknown pdef option!')
if (x[index[0]] > x[index[1]]): # % if first is down-crossing or max down_crossing_or_max = (x[index[0]] > x[index[1]])
if pdef in ('d2t', 'M2m', 'c2t', 'd2u', 'M2M', 'c2c', 'd2d', start = self._get_start_index(pdef, down_crossing_or_max)
'all'): step = self._get_step(pdef)
start = 1
elif pdef in ('t2u', 'm2M', 't2c', 'u2d', 'm2m', 't2t', 'u2u'):
start = 2
elif pdef in ('u2c'):
start = 3
elif pdef in ('c2d'):
start = 4
else:
raise ValueError('Unknown pdef option!')
# else first is up-crossing or min
elif pdef in ('all', 'u2c', 'm2M', 't2c', 'u2d', 'm2m', 't2t', 'u2u'):
start = 0
elif pdef in ('c2d', 'M2m', 'c2t', 'd2u', 'M2M', 'c2c', 'd2d'):
start = 1
elif pdef in ('d2t'):
start = 2
elif pdef in ('t2u'):
start = 3
else:
raise ValueError('Unknown pdef option!')
# determine the steps between wanted periods
if pdef in ('d2t', 't2u', 'u2c', 'c2d'):
step = 4
elif pdef in ('all'):
step = 1 # % secret option!
else:
step = 2
# determine the distance between min2min, t2t etc.. # determine the distance between min2min, t2t etc..
if pdef in ('m2m', 't2t', 'u2u', 'M2M', 'c2c', 'd2d'): if pdef in ('m2m', 't2t', 'u2u', 'M2M', 'c2c', 'd2d'):

@ -1,3 +1,4 @@
#@PydevCodeAnalysisIgnore
""" """
========================================== ==========================================
Statistical functions (:mod:`scipy.stats`) Statistical functions (:mod:`scipy.stats`)

@ -9,7 +9,7 @@ from wafo.data import sea
from wafo.misc import (JITImport, Bunch, detrendma, DotDict, findcross, ecross, from wafo.misc import (JITImport, Bunch, detrendma, DotDict, findcross, ecross,
findextrema, findrfc, rfcfilter, findtp, findtc, findextrema, findrfc, rfcfilter, findtp, findtc,
findoutliers, common_shape, argsreduce, stirlerr, findoutliers, common_shape, argsreduce, stirlerr,
getshipchar, betaloge, hygfz, getshipchar, betaloge,
gravity, nextpow2, discretize, polar2cart, gravity, nextpow2, discretize, polar2cart,
cart2polar, tranproc, cart2polar, tranproc,
rotation_matrix, rotate_2d, spaceline, rotation_matrix, rotate_2d, spaceline,
@ -296,18 +296,6 @@ def test_findoutliers():
np.array([0, 1, 2, 9521, 9522, 9523])) np.array([0, 1, 2, 9521, 9522, 9523]))
def test_hygfz():
# y = hyp2f1_taylor(-1, -4, 1, .9)
assert_equal(4.6, hygfz(-1, -4, 1, .9))
assert_almost_equal(1.0464328112173522, hygfz(0.1, 0.2, 0.3, 0.5))
assert_almost_equal(1.2027034401166194, hygfz(0.1, 0.2, 0.3, 0.95))
# assert_equal(1.661006238211309e-07, hygfz(5, -300, 10, 0.5))
# assert_equal(0.118311386286, hygfz(0.5, -99.0, 1.5, 0.5625))
# assert_equal(0.0965606007742, hygfz(0.5, -149.0, 1.5, 0.5625))
# assert_equal(0.49234384000963544 + 0.60513406166123973j,
# hygfz(1, 1, 4, 3 + 4j))
def test_common_shape(): def test_common_shape():
A = np.ones((4, 1)) A = np.ones((4, 1))
B = 2 B = 2

Loading…
Cancel
Save