compilert fortran/c-kode for windows
pep8 Moved smoothn from kdetools to sg_filter.py Simplified sg_filter.py, dctpack.py added autumn.gif Fixed the imports in wafo.objectsmaster
parent
18a50edb23
commit
abb0c8cd1f
Binary file not shown.
After Width: | Height: | Size: 240 KiB |
Binary file not shown.
Binary file not shown.
@ -1,442 +1,464 @@
|
|||||||
"""
|
"""
|
||||||
Data package in WAFO Toolbox.
|
Data package in WAFO Toolbox.
|
||||||
|
|
||||||
Contents
|
Contents
|
||||||
--------
|
--------
|
||||||
atlantic - Significant wave-height data recorded in the Atlantic Ocean
|
atlantic - Significant wave-height data recorded in the Atlantic Ocean
|
||||||
gfaks89 - Surface elevation measured at Gullfaks C 24.12.1989
|
gfaks89 - Surface elevation measured at Gullfaks C 24.12.1989
|
||||||
gfaksr89 - Reconstructed surface elevation measured at Gullfaks C 24.12.1989.
|
gfaksr89 - Reconstructed surface elevation measured at Gullfaks C 24.12.1989.
|
||||||
japansea - coastline map of The Japan Sea
|
japansea - coastline map of The Japan Sea
|
||||||
northsea - coastline map of The Nortsea
|
northsea - coastline map of The Nortsea
|
||||||
sea - Surface elevation dataset used in WAT version 1.1.
|
sea - Surface elevation dataset used in WAT version 1.1.
|
||||||
sfa89 - Wind measurements at Statfjord A 24.12.1989
|
sfa89 - Wind measurements at Statfjord A 24.12.1989
|
||||||
sn - Fatigue experiment, constant-amplitude loading.
|
sn - Fatigue experiment, constant-amplitude loading.
|
||||||
yura87 - Surface elevation measured off the coast of Yura
|
yura87 - Surface elevation measured off the coast of Yura
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This module gives gives detailed information and easy access to all datasets
|
This module gives gives detailed information and easy access to all datasets
|
||||||
included in WAFO
|
included in WAFO
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from numpy import (loadtxt, nan)
|
from numpy import (loadtxt, nan)
|
||||||
import os
|
import os
|
||||||
__path2data = os.path.dirname(os.path.realpath(__file__))
|
__path2data = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
__all__ = ['atlantic', 'gfaks89', 'gfaksr89', 'japansea', 'northsea', 'sea',
|
__all__ = ['atlantic', 'gfaks89', 'gfaksr89', 'japansea', 'northsea', 'sea',
|
||||||
'sfa89', 'sn', 'yura87']
|
'sfa89', 'sn', 'yura87']
|
||||||
|
|
||||||
_NANS = set(['nan', 'NaN', '-1.#IND00+00', '1.#IND00+00', '-1.#INF00+00'])
|
_NANS = set(['nan', 'NaN', '-1.#IND00+00', '1.#IND00+00', '-1.#INF00+00'])
|
||||||
|
|
||||||
def _tofloat(x):
|
|
||||||
return nan if x in _NANS else float(x or 0)
|
def _tofloat(x):
|
||||||
|
return nan if x in _NANS else float(x or 0)
|
||||||
_MYCONVERTER = {}
|
|
||||||
for i in range(2):
|
|
||||||
_MYCONVERTER[i] = _tofloat
|
_MYCONVERTER = {}
|
||||||
|
for i in range(2):
|
||||||
def _load(file):
|
_MYCONVERTER[i] = _tofloat
|
||||||
""" local load function
|
|
||||||
"""
|
|
||||||
return loadtxt(os.path.join(__path2data, file))
|
def _load(file): # @ReservedAssignment
|
||||||
|
""" local load function
|
||||||
def _loadnan(file):
|
"""
|
||||||
""" local load function accepting nan's
|
return loadtxt(os.path.join(__path2data, file))
|
||||||
"""
|
|
||||||
return loadtxt(os.path.join(__path2data, file), converters=_MYCONVERTER)
|
|
||||||
|
def _loadnan(file): # @ReservedAssignment
|
||||||
def atlantic():
|
""" local load function accepting nan's
|
||||||
"""
|
"""
|
||||||
Return Significant wave-height data recorded in the Atlantic Ocean
|
return loadtxt(os.path.join(__path2data, file), converters=_MYCONVERTER)
|
||||||
|
|
||||||
Data summary
|
|
||||||
------------
|
def atlantic():
|
||||||
Size : 582 X 1
|
"""
|
||||||
Sampling Rate : ~ 14 times a month
|
Return Significant wave-height data recorded in the Atlantic Ocean
|
||||||
Device :
|
|
||||||
Source :
|
Data summary
|
||||||
Format : ascii
|
------------
|
||||||
|
Size : 582 X 1
|
||||||
Description
|
Sampling Rate : ~ 14 times a month
|
||||||
------------
|
Device :
|
||||||
atlantic.dat contains average significant wave-height data recorded
|
Source :
|
||||||
approximately 14 times a month in December-February during 7 years and
|
Format : ascii
|
||||||
at 2 locations in the Atlantic Ocean
|
|
||||||
|
Description
|
||||||
Example
|
------------
|
||||||
--------
|
atlantic.dat contains average significant wave-height data recorded
|
||||||
>>> import pylab
|
approximately 14 times a month in December-February during 7 years and
|
||||||
>>> import wafo
|
at 2 locations in the Atlantic Ocean
|
||||||
>>> Hs = wafo.data.atlantic()
|
|
||||||
>>> h = pylab.plot(Hs)
|
Example
|
||||||
|
--------
|
||||||
Acknowledgement:
|
>>> import pylab
|
||||||
---------------
|
>>> import wafo
|
||||||
This dataset were made available by Dr. David Carter
|
>>> Hs = wafo.data.atlantic()
|
||||||
and Dr. David Cotton, Satellite Observing Systems, UK.
|
>>> h = pylab.plot(Hs)
|
||||||
"""
|
|
||||||
return _load('atlantic.dat')
|
Acknowledgement:
|
||||||
def gfaks89():
|
---------------
|
||||||
"""
|
This dataset were made available by Dr. David Carter
|
||||||
Return Surface elevation measured at Gullfaks C 24.12.1989
|
and Dr. David Cotton, Satellite Observing Systems, UK.
|
||||||
|
"""
|
||||||
Data summary
|
return _load('atlantic.dat')
|
||||||
------------
|
|
||||||
Size : 39000 X 2
|
|
||||||
Sampling Rate : 2.5 Hz
|
def gfaks89():
|
||||||
Device : EMI laser
|
"""
|
||||||
Source : STATOIL
|
Return Surface elevation measured at Gullfaks C 24.12.1989
|
||||||
Format : ascii, c1: time c2: surface elevation
|
|
||||||
|
Data summary
|
||||||
Description
|
------------
|
||||||
------------
|
Size : 39000 X 2
|
||||||
The wave data was measured 24th December 1989 at the Gullfaks C platform
|
Sampling Rate : 2.5 Hz
|
||||||
in the North Sea from 17.00 to 21.20. The period from 20.00 to 20.20
|
Device : EMI laser
|
||||||
is missing and contains NaNs. The water depth of 218 m is
|
Source : STATOIL
|
||||||
regarded as deep water for the most important wave components.
|
Format : ascii, c1: time c2: surface elevation
|
||||||
There are two EMI laser sensors named 219 and 220. This data set is
|
|
||||||
obtained from sensor 219, which is located in the Northwest
|
Description
|
||||||
corner approximately two platform leg diameters away from
|
------------
|
||||||
the closest leg.
|
The wave data was measured 24th December 1989 at the Gullfaks C platform
|
||||||
Thus the wave elevation is not expected to be significantly
|
in the North Sea from 17.00 to 21.20. The period from 20.00 to 20.20
|
||||||
affected by diffraction effects for incoming waves in the western sector.
|
is missing and contains NaNs. The water depth of 218 m is
|
||||||
The wind direction for this period is from the south.
|
regarded as deep water for the most important wave components.
|
||||||
Some difficulties in calibration of the instruments have been reported
|
There are two EMI laser sensors named 219 and 220. This data set is
|
||||||
resulting in several consecutive measured values being equal or almost equal
|
obtained from sensor 219, which is located in the Northwest
|
||||||
in the observed data set.
|
corner approximately two platform leg diameters away from
|
||||||
|
the closest leg.
|
||||||
This dataset is for non-commercial use only.
|
Thus the wave elevation is not expected to be significantly
|
||||||
|
affected by diffraction effects for incoming waves in the western sector.
|
||||||
Hm0 = 6.8m, Tm02 = 8s, Tp = 10.5
|
The wind direction for this period is from the south.
|
||||||
|
Some difficulties in calibration of the instruments have been reported
|
||||||
Example
|
resulting in several consecutive measured values being equal or almost
|
||||||
-------
|
equal in the observed data set.
|
||||||
>>> import pylab
|
|
||||||
>>> import wafo
|
This dataset is for non-commercial use only.
|
||||||
>>> x = wafo.data.gfaks89()
|
|
||||||
>>> h = pylab.plot(x[:,0],x[:,1])
|
Hm0 = 6.8m, Tm02 = 8s, Tp = 10.5
|
||||||
|
|
||||||
Acknowledgement:
|
Example
|
||||||
---------------
|
-------
|
||||||
This dataset were prepared and made available by Dr. S. Haver,
|
>>> import pylab
|
||||||
STATOIL, Norway
|
>>> import wafo
|
||||||
|
>>> x = wafo.data.gfaks89()
|
||||||
See also
|
>>> h = pylab.plot(x[:,0],x[:,1])
|
||||||
--------
|
|
||||||
gfaksr89, northsea
|
Acknowledgement:
|
||||||
|
---------------
|
||||||
"""
|
This dataset were prepared and made available by Dr. S. Haver,
|
||||||
return _loadnan('gfaks89.dat')
|
STATOIL, Norway
|
||||||
def gfaksr89():
|
|
||||||
"""
|
See also
|
||||||
Return a reconstruction of surface elevation measured at Gullfaks C 24.12.1989.
|
--------
|
||||||
|
gfaksr89, northsea
|
||||||
|
|
||||||
Data summary
|
"""
|
||||||
------------
|
return _loadnan('gfaks89.dat')
|
||||||
Size : 39000 X 2
|
|
||||||
Sampling Rate : 2.5 Hz
|
|
||||||
Device : EMI laser
|
def gfaksr89():
|
||||||
Source : STATOIL
|
"""
|
||||||
Format : ascii, c1: time c2: surface elevation
|
Return a reconstruction of surface elevation measured at Gullfaks C
|
||||||
|
24.12.1989.
|
||||||
Description
|
|
||||||
-----------
|
|
||||||
This is a reconstructed version of the data in the GFAKS89.DAT file.
|
Data summary
|
||||||
The following calls were made to reconstruct the data:
|
------------
|
||||||
|
Size : 39000 X 2
|
||||||
inds = findoutliers(gfaks89,.02,2,1.23);
|
Sampling Rate : 2.5 Hz
|
||||||
gfaksr89 = reconstruct(gfaks89,inds,6);
|
Device : EMI laser
|
||||||
|
Source : STATOIL
|
||||||
The wave data was measured 24th December 1989 at the Gullfaks C platform
|
Format : ascii, c1: time c2: surface elevation
|
||||||
in the North Sea from 17.00 to 21.20. The period from 20.00 to 20.20
|
|
||||||
is missing in the original data. The water depth of 218 m is
|
Description
|
||||||
regarded as deep water for the most important wave components.
|
-----------
|
||||||
There are two EMI laser sensors named 219 and 220. This data set is
|
This is a reconstructed version of the data in the GFAKS89.DAT file.
|
||||||
obtained from sensor 219, which is located in the Northwest
|
The following calls were made to reconstruct the data:
|
||||||
corner approximately two platform leg diameters away from
|
|
||||||
the closest leg.
|
inds = findoutliers(gfaks89,.02,2,1.23);
|
||||||
Thus the wave elevation is not expected to be significantly
|
gfaksr89 = reconstruct(gfaks89,inds,6);
|
||||||
affected by diffraction effects for incoming waves in the western sector.
|
|
||||||
The wind direction for this period is from the south.
|
The wave data was measured 24th December 1989 at the Gullfaks C platform
|
||||||
Some difficulties in calibration of the instruments have been reported
|
in the North Sea from 17.00 to 21.20. The period from 20.00 to 20.20
|
||||||
resulting in several consecutive measured values being equal or almost equal
|
is missing in the original data. The water depth of 218 m is
|
||||||
in the observed data set.
|
regarded as deep water for the most important wave components.
|
||||||
|
There are two EMI laser sensors named 219 and 220. This data set is
|
||||||
Hm0 = 6.8m, Tm02 = 8s, Tp = 10.5
|
obtained from sensor 219, which is located in the Northwest
|
||||||
|
corner approximately two platform leg diameters away from
|
||||||
|
the closest leg.
|
||||||
Example
|
Thus the wave elevation is not expected to be significantly
|
||||||
-------
|
affected by diffraction effects for incoming waves in the western sector.
|
||||||
>>> import pylab
|
The wind direction for this period is from the south.
|
||||||
>>> import wafo
|
Some difficulties in calibration of the instruments have been reported
|
||||||
>>> x = wafo.data.gfaksr89()
|
resulting in several consecutive measured values being equal or almost
|
||||||
>>> h = pylab.plot(x[:,0],x[:,1])
|
equal in the observed data set.
|
||||||
|
|
||||||
|
Hm0 = 6.8m, Tm02 = 8s, Tp = 10.5
|
||||||
See also
|
|
||||||
--------
|
|
||||||
gfaks89
|
Example
|
||||||
"""
|
-------
|
||||||
return _loadnan('gfaksr89.dat')
|
>>> import pylab
|
||||||
def japansea():
|
>>> import wafo
|
||||||
"""
|
>>> x = wafo.data.gfaksr89()
|
||||||
Return coastline map of The Japan Sea
|
>>> h = pylab.plot(x[:,0],x[:,1])
|
||||||
|
|
||||||
|
|
||||||
Data summary
|
See also
|
||||||
------------
|
--------
|
||||||
Size : 692 X 2
|
gfaks89
|
||||||
Sampling Rate :
|
"""
|
||||||
Device :
|
return _loadnan('gfaksr89.dat')
|
||||||
Source : http://crusty.er.usgs.gov/coast/getcoast.html
|
|
||||||
Format : ascii, c1: longitude c2: latitude
|
|
||||||
|
def japansea():
|
||||||
Description
|
"""
|
||||||
-----------
|
Return coastline map of The Japan Sea
|
||||||
JAPANSEA.DAT contains data for plotting a map of The Japan Sea.
|
|
||||||
The data is obtained from USGS coastline extractor.
|
|
||||||
|
Data summary
|
||||||
Example:
|
------------
|
||||||
-------
|
Size : 692 X 2
|
||||||
#the map is seen by
|
Sampling Rate :
|
||||||
|
Device :
|
||||||
>>> import pylab
|
Source : http://crusty.er.usgs.gov/coast/getcoast.html
|
||||||
>>> import wafo
|
Format : ascii, c1: longitude c2: latitude
|
||||||
>>> map1 = wafo.data.japansea()
|
|
||||||
>>> h = pylab.plot(map1[:,0],map1[:,1])
|
Description
|
||||||
>>> lon_loc = [131,132,132,135,139.5,139]
|
-----------
|
||||||
>>> lat_loc = [46, 43, 40, 35, 38.3, 35.7]
|
JAPANSEA.DAT contains data for plotting a map of The Japan Sea.
|
||||||
>>> loc = ['China','Vladivostok','Japan Sea', 'Japan', 'Yura','Tokyo']
|
The data is obtained from USGS coastline extractor.
|
||||||
>>> algn = 'right'
|
|
||||||
>>> for lon, lat, name in zip(lon_loc,lat_loc,loc):
|
Example:
|
||||||
pylab.text(lon,lat,name,horizontalalignment=algn)
|
-------
|
||||||
|
#the map is seen by
|
||||||
|
|
||||||
# If you have the m_map toolbox (see http://www.ocgy.ubc.ca/~rich/):
|
>>> import pylab
|
||||||
m_proj('lambert','long',[130 148],'lat',[30 48]);
|
>>> import wafo
|
||||||
m_line(map(:,1),map(:,2));
|
>>> map1 = wafo.data.japansea()
|
||||||
m_grid('box','fancy','tickdir','out');
|
>>> h = pylab.plot(map1[:,0],map1[:,1])
|
||||||
m_text(131,46,'China');
|
>>> lon_loc = [131,132,132,135,139.5,139]
|
||||||
m_text(132,43,'Vladivostok');
|
>>> lat_loc = [46, 43, 40, 35, 38.3, 35.7]
|
||||||
m_text(132,40,'Japan Sea');
|
>>> loc = ['China','Vladivostok','Japan Sea', 'Japan', 'Yura','Tokyo']
|
||||||
m_text(135,35,'Japan');
|
>>> algn = 'right'
|
||||||
m_text(139.5,38.3,'Yura');
|
>>> for lon, lat, name in zip(lon_loc,lat_loc,loc):
|
||||||
m_text(139,35.7,'Tokyo');
|
pylab.text(lon,lat,name,horizontalalignment=algn)
|
||||||
"""
|
|
||||||
return _loadnan('japansea.dat')
|
|
||||||
def northsea():
|
# If you have the m_map toolbox (see http://www.ocgy.ubc.ca/~rich/):
|
||||||
"""
|
m_proj('lambert','long',[130 148],'lat',[30 48]);
|
||||||
NORTHSEA coastline map of The Nortsea
|
m_line(map(:,1),map(:,2));
|
||||||
|
m_grid('box','fancy','tickdir','out');
|
||||||
Data summary
|
m_text(131,46,'China');
|
||||||
-------------
|
m_text(132,43,'Vladivostok');
|
||||||
Size : 60646 X 2
|
m_text(132,40,'Japan Sea');
|
||||||
Sampling Rate :
|
m_text(135,35,'Japan');
|
||||||
Device :
|
m_text(139.5,38.3,'Yura');
|
||||||
Source : http://crusty.er.usgs.gov/coast/getcoast.html
|
m_text(139,35.7,'Tokyo');
|
||||||
Format : ascii, c1: longitude c2: latitude
|
"""
|
||||||
|
return _loadnan('japansea.dat')
|
||||||
Description
|
|
||||||
-----------
|
|
||||||
NORTHSEA.DAT contains data for plotting a map of The Northsea.
|
def northsea():
|
||||||
The data is obtained from USGS coastline extractor.
|
"""
|
||||||
|
NORTHSEA coastline map of The Nortsea
|
||||||
Example
|
|
||||||
-------
|
Data summary
|
||||||
# the map is seen by
|
-------------
|
||||||
|
Size : 60646 X 2
|
||||||
>>> import pylab
|
Sampling Rate :
|
||||||
>>> import wafo
|
Device :
|
||||||
>>> map1 = wafo.data.northsea()
|
Source : http://crusty.er.usgs.gov/coast/getcoast.html
|
||||||
>>> h = pylab.plot(map1[:,0],map1[:,1])
|
Format : ascii, c1: longitude c2: latitude
|
||||||
>>> lon_pltfrm = [1.8, 2.3, 2., 1.9, 2.6]
|
|
||||||
>>> lat_pltfrm = [61.2, 61.2, 59.9, 58.4, 57.7]
|
Description
|
||||||
>>> pltfrm = ['Statfjord A', 'Gullfaks C', 'Frigg', 'Sleipner', 'Draupner']
|
-----------
|
||||||
>>> h = pylab.scatter(lon_pltfrm,lat_pltfrm);
|
NORTHSEA.DAT contains data for plotting a map of The Northsea.
|
||||||
>>> algn = 'right'
|
The data is obtained from USGS coastline extractor.
|
||||||
>>> for lon, lat, name in zip(lon_pltfrm,lat_pltfrm,pltfrm):
|
|
||||||
pylab.text(lon,lat,name,horizontalalignment=algn); algn = 'left'
|
Example
|
||||||
|
-------
|
||||||
|
# the map is seen by
|
||||||
>>> lon_city = [10.8, 10.8, 5.52, 5.2]
|
|
||||||
>>> lat_city = [59.85, 63.4, 58.9, 60.3]
|
>>> import pylab
|
||||||
>>> city = ['Oslo','Trondheim','Stavanger', 'Bergen']
|
>>> import wafo
|
||||||
>>> h = pylab.scatter(lon_city,lat_city);
|
>>> map1 = wafo.data.northsea()
|
||||||
>>> algn = 'right'
|
>>> h = pylab.plot(map1[:,0],map1[:,1])
|
||||||
>>> for lon, lat, name in zip(lon_city,lat_city,city):
|
>>> lon_pltfrm = [1.8, 2.3, 2., 1.9, 2.6]
|
||||||
pylab.text(lon,lat,name,horizontalalignment=algn)
|
>>> lat_pltfrm = [61.2, 61.2, 59.9, 58.4, 57.7]
|
||||||
|
>>> pltfrm = ['Statfjord A', 'Gullfaks C', 'Frigg', 'Sleipner', 'Draupner']
|
||||||
# If you have the mpl_toolkits.basemap installed
|
>>> h = pylab.scatter(lon_pltfrm,lat_pltfrm);
|
||||||
>>> from mpl_toolkits.basemap import Basemap
|
>>> algn = 'right'
|
||||||
>>> import matplotlib.pyplot as plt
|
>>> for lon, lat, name in zip(lon_pltfrm,lat_pltfrm,pltfrm):
|
||||||
|
pylab.text(lon,lat,name,horizontalalignment=algn); algn = 'left'
|
||||||
# setup Lambert Conformal basemap.
|
|
||||||
>>> m = Basemap(width=1200000,height=900000,projection='lcc',
|
|
||||||
resolution='f',lat_1=56.,lat_2=64,lat_0=58,lon_0=5.)
|
>>> lon_city = [10.8, 10.8, 5.52, 5.2]
|
||||||
>>> m.drawcoastlines()
|
>>> lat_city = [59.85, 63.4, 58.9, 60.3]
|
||||||
>>> h = m.scatter(lon_pltfrm,lat_pltfrm);
|
>>> city = ['Oslo','Trondheim','Stavanger', 'Bergen']
|
||||||
>>> algn = 'right'
|
>>> h = pylab.scatter(lon_city,lat_city);
|
||||||
>>> for lon, lat, name in zip(lon_pltfrm,lat_pltfrm,pltfrm):
|
>>> algn = 'right'
|
||||||
m.text(lon,lat,name,horizontalalignment=algn); algn = 'left'
|
>>> for lon, lat, name in zip(lon_city,lat_city,city):
|
||||||
>>> m.scatter(lon_city,lat_city)
|
pylab.text(lon,lat,name,horizontalalignment=algn)
|
||||||
>>> algn = 'right'
|
|
||||||
>>> for lon, lat, name in zip(lon_city,lat_city,city):
|
# If you have the mpl_toolkits.basemap installed
|
||||||
m.text(lon,lat,name,horizontalalignment=algn)
|
>>> from mpl_toolkits.basemap import Basemap
|
||||||
"""
|
>>> import matplotlib.pyplot as plt
|
||||||
return _loadnan('northsea.dat')
|
|
||||||
def sea():
|
# setup Lambert Conformal basemap.
|
||||||
"""
|
>>> m = Basemap(width=1200000,height=900000,projection='lcc',
|
||||||
Return Surface elevation dataset used in WAT version 1.1.
|
resolution='f',lat_1=56.,lat_2=64,lat_0=58,lon_0=5.)
|
||||||
|
>>> m.drawcoastlines()
|
||||||
Data summary
|
>>> h = m.scatter(lon_pltfrm,lat_pltfrm);
|
||||||
------------
|
>>> algn = 'right'
|
||||||
Size : 9524 X 2
|
>>> for lon, lat, name in zip(lon_pltfrm,lat_pltfrm,pltfrm):
|
||||||
Sampling Rate : 4.0 Hz
|
m.text(lon,lat,name,horizontalalignment=algn); algn = 'left'
|
||||||
Device : unknown
|
>>> m.scatter(lon_city,lat_city)
|
||||||
Source : unknown
|
>>> algn = 'right'
|
||||||
Format : ascii, c1: time c2: surface elevation
|
>>> for lon, lat, name in zip(lon_city,lat_city,city):
|
||||||
|
m.text(lon,lat,name,horizontalalignment=algn)
|
||||||
Description
|
"""
|
||||||
-----------
|
return _loadnan('northsea.dat')
|
||||||
The wave data was used in one of WAFO predecessors, i.e. the Wave
|
|
||||||
Analysis Toolbox version 1.1 (WAT)
|
|
||||||
Hm0 = 1.9m, Tm02 = 4.0s, Tp2 = 11.5s Tp1=5.6s
|
def sea():
|
||||||
|
"""
|
||||||
Example
|
Return Surface elevation dataset used in WAT version 1.1.
|
||||||
-------
|
|
||||||
>>> import pylab
|
Data summary
|
||||||
>>> import wafo
|
------------
|
||||||
>>> x = wafo.data.sea()
|
Size : 9524 X 2
|
||||||
>>> h = pylab.plot(x[:,0],x[:,1])
|
Sampling Rate : 4.0 Hz
|
||||||
"""
|
Device : unknown
|
||||||
return _load('sea.dat')
|
Source : unknown
|
||||||
def sfa89():
|
Format : ascii, c1: time c2: surface elevation
|
||||||
"""
|
|
||||||
Return Wind measurements at Statfjord A 24.12.1989
|
Description
|
||||||
|
-----------
|
||||||
Data summary
|
The wave data was used in one of WAFO predecessors, i.e. the Wave
|
||||||
------------
|
Analysis Toolbox version 1.1 (WAT)
|
||||||
Size : 144 X 3
|
Hm0 = 1.9m, Tm02 = 4.0s, Tp2 = 11.5s Tp1=5.6s
|
||||||
Sampling Rate : 1/600 Hz
|
|
||||||
Device :
|
Example
|
||||||
Source : DNMI (The Norwegian Meteorological Institute)
|
-------
|
||||||
Format : ascii, c1: time (hours)
|
>>> import pylab
|
||||||
c2: velocity (m/s)
|
>>> import wafo
|
||||||
c3: direction (degrees)
|
>>> x = wafo.data.sea()
|
||||||
Description
|
>>> h = pylab.plot(x[:,0],x[:,1])
|
||||||
-----------
|
"""
|
||||||
The registration of wind speeds at the Gullfaks field
|
return _load('sea.dat')
|
||||||
started up on Statfjord A in 1978 and continued until 1990.
|
|
||||||
The dataregistration was transferred to Gullfaks C in Nov 1989.
|
|
||||||
Due to some difficulties of the windregistration on Gullfaks C in
|
def sfa89():
|
||||||
the beginning, they continued to use the registered data from
|
"""
|
||||||
Statfjord A.
|
Return Wind measurements at Statfjord A 24.12.1989
|
||||||
The windspeed is measured in (meter/second), 110 m above mean water
|
|
||||||
level (MWL) and the wind direction is given in degrees for the data.
|
Data summary
|
||||||
The data are a mean value of every 10 minutes.
|
------------
|
||||||
Wind directions are defined in the meteorological convention, i.e.,
|
Size : 144 X 3
|
||||||
0 degrees = wind approaching from North, 90 degrees = wind from East, etc.
|
Sampling Rate : 1/600 Hz
|
||||||
This dataset is for non-commercial use only.
|
Device :
|
||||||
|
Source : DNMI (The Norwegian Meteorological Institute)
|
||||||
Example
|
Format : ascii, c1: time (hours)
|
||||||
-------
|
c2: velocity (m/s)
|
||||||
>>> import pylab
|
c3: direction (degrees)
|
||||||
>>> import wafo
|
Description
|
||||||
>>> x = wafo.data.sfa89()
|
-----------
|
||||||
>>> h = pylab.plot(x[:,0],x[:,1])
|
The registration of wind speeds at the Gullfaks field
|
||||||
|
started up on Statfjord A in 1978 and continued until 1990.
|
||||||
Acknowledgement
|
The dataregistration was transferred to Gullfaks C in Nov 1989.
|
||||||
----------------
|
Due to some difficulties of the windregistration on Gullfaks C in
|
||||||
These data are made available by Knut A. Iden, DNMI.
|
the beginning, they continued to use the registered data from
|
||||||
|
Statfjord A.
|
||||||
See also
|
The windspeed is measured in (meter/second), 110 m above mean water
|
||||||
--------
|
level (MWL) and the wind direction is given in degrees for the data.
|
||||||
northsea
|
The data are a mean value of every 10 minutes.
|
||||||
"""
|
Wind directions are defined in the meteorological convention, i.e.,
|
||||||
return _load('sfa89.dat')
|
0 degrees = wind approaching from North, 90 degrees = wind from East, etc.
|
||||||
def sn():
|
This dataset is for non-commercial use only.
|
||||||
"""
|
|
||||||
Return SN Fatigue experiment, constant-amplitude loading.
|
Example
|
||||||
|
-------
|
||||||
|
>>> import pylab
|
||||||
Data summary
|
>>> import wafo
|
||||||
------------
|
>>> x = wafo.data.sfa89()
|
||||||
Size : 40 X 2
|
>>> h = pylab.plot(x[:,0],x[:,1])
|
||||||
Source : unknown
|
|
||||||
Format : ascii, c1: Amplitude MPa c2: Number of cycles
|
Acknowledgement
|
||||||
|
----------------
|
||||||
Description
|
These data are made available by Knut A. Iden, DNMI.
|
||||||
-----------
|
|
||||||
A fatigue experiment with constant amplitudes at five levels:
|
See also
|
||||||
10,15,20,25 and 30 MPa. For each level is related 8 observations of
|
--------
|
||||||
the number of cycles to failure.
|
northsea
|
||||||
|
"""
|
||||||
The origin of the data is unknown.
|
return _load('sfa89.dat')
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
def sn():
|
||||||
>>> import pylab
|
"""
|
||||||
>>> import wafo
|
Return SN Fatigue experiment, constant-amplitude loading.
|
||||||
>>> x = wafo.data.sn()
|
|
||||||
>>> h = pylab.plot(x[:,0],x[:,1])
|
|
||||||
|
Data summary
|
||||||
See also
|
------------
|
||||||
--------
|
Size : 40 X 2
|
||||||
The same data appear in the directory wdemos/itmkurs/
|
Source : unknown
|
||||||
as SN.mat.
|
Format : ascii, c1: Amplitude MPa c2: Number of cycles
|
||||||
|
|
||||||
"""
|
Description
|
||||||
return _load('sn.dat')
|
-----------
|
||||||
def yura87():
|
A fatigue experiment with constant amplitudes at five levels:
|
||||||
"""
|
10,15,20,25 and 30 MPa. For each level is related 8 observations of
|
||||||
Return Surface elevation measured off the coast of Yura.
|
the number of cycles to failure.
|
||||||
|
|
||||||
|
The origin of the data is unknown.
|
||||||
Data summary
|
|
||||||
-----------
|
Example
|
||||||
Size : 85547 X 4
|
-------
|
||||||
Sampling Rate : 1 Hz
|
>>> import pylab
|
||||||
Device : ultrasonic wave gauges
|
>>> import wafo
|
||||||
Source : SRI, Ministry of Transport, Japan
|
>>> x = wafo.data.sn()
|
||||||
Format : ascii, c1: time (sec) c2-4: surface elevation (m)
|
>>> h = pylab.plot(x[:,0],x[:,1])
|
||||||
|
|
||||||
Description
|
See also
|
||||||
-----------
|
--------
|
||||||
The wave data was measured at the Poseidon platform
|
The same data appear in the directory wdemos/itmkurs/
|
||||||
in the Japan Sea from 24th November 1987 08.12 hours to 25th November
|
as SN.mat.
|
||||||
1987 07.57 hours. Poseidon was located 3 km off the coast of Yura
|
|
||||||
in the Yamagata prefecture, in the Japan Sea during the measurements.
|
"""
|
||||||
The most important wave components are to some extent influenced by the
|
return _load('sn.dat')
|
||||||
water depth of 42 m. The data are measured with three ultrasonic wave
|
|
||||||
gauges located at the sea floor and the relative coordinates of the
|
|
||||||
gauges are as follows (x-axis points to the East, y-axis points to
|
def yura87():
|
||||||
the North):
|
"""
|
||||||
X (m) Y (m)
|
Return Surface elevation measured off the coast of Yura.
|
||||||
c2: -4.93, 25.02
|
|
||||||
c3: 5.80, 92.12
|
|
||||||
c4: 0.00, 0.00
|
Data summary
|
||||||
|
-----------
|
||||||
This dataset is for non-commercial use only.
|
Size : 85547 X 4
|
||||||
|
Sampling Rate : 1 Hz
|
||||||
Hm0 = 5.1m, Tm02 = 7.7s, Tp = 12.8s
|
Device : ultrasonic wave gauges
|
||||||
Example
|
Source : SRI, Ministry of Transport, Japan
|
||||||
-------
|
Format : ascii, c1: time (sec) c2-4: surface elevation (m)
|
||||||
>>> import pylab
|
|
||||||
>>> import wafo
|
Description
|
||||||
>>> x = wafo.data.yura87()
|
-----------
|
||||||
>>> h = pylab.plot(x[:,0],x[:,1])
|
The wave data was measured at the Poseidon platform
|
||||||
|
in the Japan Sea from 24th November 1987 08.12 hours to 25th November
|
||||||
Acknowledgement:
|
1987 07.57 hours. Poseidon was located 3 km off the coast of Yura
|
||||||
-----------------
|
in the Yamagata prefecture, in the Japan Sea during the measurements.
|
||||||
This dataset were prepared and made available by Dr. Sc. H. Tomita,
|
The most important wave components are to some extent influenced by the
|
||||||
Ship Research Institute, Ministry of Transport, Japan.
|
water depth of 42 m. The data are measured with three ultrasonic wave
|
||||||
|
gauges located at the sea floor and the relative coordinates of the
|
||||||
See also
|
gauges are as follows (x-axis points to the East, y-axis points to
|
||||||
--------
|
the North):
|
||||||
japansea
|
X (m) Y (m)
|
||||||
"""
|
c2: -4.93, 25.02
|
||||||
return _load('yura87.dat')
|
c3: 5.80, 92.12
|
||||||
if __name__ == '__main__':
|
c4: 0.00, 0.00
|
||||||
import doctest
|
|
||||||
doctest.testmod()
|
This dataset is for non-commercial use only.
|
||||||
|
|
||||||
|
Hm0 = 5.1m, Tm02 = 7.7s, Tp = 12.8s
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
>>> import pylab
|
||||||
|
>>> import wafo
|
||||||
|
>>> x = wafo.data.yura87()
|
||||||
|
>>> h = pylab.plot(x[:,0],x[:,1])
|
||||||
|
|
||||||
|
Acknowledgement:
|
||||||
|
-----------------
|
||||||
|
This dataset were prepared and made available by Dr. Sc. H. Tomita,
|
||||||
|
Ship Research Institute, Ministry of Transport, Japan.
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
japansea
|
||||||
|
"""
|
||||||
|
return _load('yura87.dat')
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import doctest
|
||||||
|
doctest.testmod()
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,386 +1,408 @@
|
|||||||
'''
|
'''
|
||||||
Created on 20. nov. 2010
|
Created on 20. nov. 2010
|
||||||
|
|
||||||
@author: pab
|
@author: pab
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import numpy as np #@UnusedImport
|
import numpy as np # @UnusedImport
|
||||||
from numpy import array #@UnusedImport
|
from numpy import array # @UnusedImport
|
||||||
import wafo.kdetools as wk #@UnusedImport
|
import wafo.kdetools as wk # @UnusedImport
|
||||||
#import pylab as plb
|
# import pylab as plb
|
||||||
|
|
||||||
def test0_KDE1D():
|
|
||||||
'''
|
def test0_KDE1D():
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
'''
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
>>> data = array([0.75355792, 0.72779194, 0.94149169, 0.07841119,
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
... 2.32291887, 1.10419995, 0.77055114, 0.60288273,
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
... 1.36883635, 1.74754326, 1.09547561, 1.01671133,
|
||||||
|
... 0.73211143, 0.61891719, 0.75903487, 1.8919469,
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
... 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
||||||
>>> import wafo.kdetools as wk
|
|
||||||
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
||||||
|
>>> import wafo.kdetools as wk
|
||||||
>>> kde0 = wk.KDE(data, hs=0.5, alpha=0.0, inc=16)
|
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
||||||
|
|
||||||
>>> kde0.eval_grid(x)
|
>>> kde0 = wk.KDE(data, hs=0.5, alpha=0.0, inc=16)
|
||||||
array([ 0.2039735 , 0.40252503, 0.54595078, 0.52219649, 0.3906213 ,
|
|
||||||
0.26381501, 0.16407362, 0.08270612, 0.02991145, 0.00720821])
|
>>> kde0.eval_grid(x)
|
||||||
>>> kde0.eval_grid_fast(x)
|
array([ 0.2039735 , 0.40252503, 0.54595078, 0.52219649, 0.3906213 ,
|
||||||
array([ 0.20729484, 0.39865044, 0.53716945, 0.5169322 , 0.39060223,
|
0.26381501, 0.16407362, 0.08270612, 0.02991145, 0.00720821])
|
||||||
0.26441126, 0.16388801, 0.08388527, 0.03227164, 0.00883579])
|
>>> kde0.eval_grid_fast(x)
|
||||||
|
array([ 0.20729484, 0.39865044, 0.53716945, 0.5169322 , 0.39060223,
|
||||||
>>> f = kde0.eval_grid_fast(); f
|
0.26441126, 0.16388801, 0.08388527, 0.03227164, 0.00883579])
|
||||||
array([ 0.01149411, 0.03485467, 0.08799292, 0.18568718, 0.32473136,
|
|
||||||
0.46543163, 0.54532016, 0.53005828, 0.44447651, 0.34119612,
|
>>> f = kde0.eval_grid_fast(); f
|
||||||
0.25103852, 0.1754952 , 0.11072989, 0.05992731, 0.02687784,
|
array([ 0.06807544, 0.12949095, 0.21985421, 0.33178031, 0.44334874,
|
||||||
0.00974983])
|
0.52429234, 0.55140336, 0.52221323, 0.45500674, 0.3752208 ,
|
||||||
>>> np.trapz(f,kde0.args)
|
0.30046799, 0.235667 , 0.17854402, 0.12721305, 0.08301993,
|
||||||
array([ 0.99500101])
|
0.04862324])
|
||||||
'''
|
>>> np.allclose(np.trapz(f,kde0.args), array([ 0.96716261]))
|
||||||
def test1_TKDE1D():
|
True
|
||||||
'''
|
'''
|
||||||
N = 20
|
|
||||||
data = np.random.rayleigh(1, size=(N,))
|
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
def test1_TKDE1D():
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
'''
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
N = 20
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
data = np.random.rayleigh(1, size=(N,))
|
||||||
|
>>> data = array([0.75355792, 0.72779194, 0.94149169, 0.07841119,
|
||||||
>>> x = np.linspace(0.01, max(data.ravel()) + 1, 10)
|
... 2.32291887, 1.10419995, 0.77055114, 0.60288273,
|
||||||
>>> kde = wk.TKDE(data, hs=0.5, L2=0.5)
|
... 1.36883635, 1.74754326, 1.09547561, 1.01671133,
|
||||||
>>> f = kde(x)
|
... 0.73211143, 0.61891719, 0.75903487, 1.8919469,
|
||||||
>>> f
|
... 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
||||||
array([ 1.03982714, 0.45839018, 0.39514782, 0.32860602, 0.26433318,
|
|
||||||
0.20717946, 0.15907684, 0.1201074 , 0.08941027, 0.06574882])
|
>>> x = np.linspace(0.01, max(data.ravel()) + 1, 10)
|
||||||
|
>>> kde = wk.TKDE(data, hs=0.5, L2=0.5)
|
||||||
>>> np.trapz(f, x)
|
>>> f = kde(x)
|
||||||
0.94787730659349068
|
>>> f
|
||||||
|
array([ 1.03982714, 0.45839018, 0.39514782, 0.32860602, 0.26433318,
|
||||||
h1 = plb.plot(x, f) # 1D probability density plot
|
0.20717946, 0.15907684, 0.1201074 , 0.08941027, 0.06574882])
|
||||||
'''
|
|
||||||
def test1_KDE1D():
|
>>> np.trapz(f, x)
|
||||||
'''
|
0.94787730659349068
|
||||||
N = 20
|
|
||||||
data = np.random.rayleigh(1, size=(N,))
|
h1 = plb.plot(x, f) # 1D probability density plot
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
'''
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
def test1_KDE1D():
|
||||||
|
'''
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
N = 20
|
||||||
>>> kde = wk.KDE(data, hs=0.5)
|
data = np.random.rayleigh(1, size=(N,))
|
||||||
>>> f = kde(x)
|
>>> data = array([0.75355792, 0.72779194, 0.94149169, 0.07841119,
|
||||||
>>> f
|
... 2.32291887, 1.10419995, 0.77055114, 0.60288273,
|
||||||
array([ 0.2039735 , 0.40252503, 0.54595078, 0.52219649, 0.3906213 ,
|
... 1.36883635, 1.74754326, 1.09547561, 1.01671133,
|
||||||
0.26381501, 0.16407362, 0.08270612, 0.02991145, 0.00720821])
|
... 0.73211143, 0.61891719, 0.75903487, 1.8919469,
|
||||||
|
... 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
||||||
>>> np.trapz(f, x)
|
|
||||||
0.92576174424281876
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
||||||
|
>>> kde = wk.KDE(data, hs=0.5)
|
||||||
h1 = plb.plot(x, f) # 1D probability density plot
|
>>> f = kde(x)
|
||||||
'''
|
>>> f
|
||||||
def test2_KDE1D():
|
array([ 0.2039735 , 0.40252503, 0.54595078, 0.52219649, 0.3906213 ,
|
||||||
'''
|
0.26381501, 0.16407362, 0.08270612, 0.02991145, 0.00720821])
|
||||||
N = 20
|
|
||||||
data = np.random.rayleigh(1, size=(N,))
|
>>> np.trapz(f, x)
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
0.92576174424281876
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
h1 = plb.plot(x, f) # 1D probability density plot
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
'''
|
||||||
|
|
||||||
>>> data = np.asarray([1,2])
|
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
def test2_KDE1D():
|
||||||
>>> kde = wk.KDE(data, hs=0.5)
|
'''
|
||||||
>>> f = kde(x)
|
N = 20
|
||||||
>>> f
|
data = np.random.rayleigh(1, size=(N,))
|
||||||
array([ 0.0541248 , 0.16555235, 0.33084399, 0.45293325, 0.48345808,
|
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119,
|
||||||
0.48345808, 0.45293325, 0.33084399, 0.16555235, 0.0541248 ])
|
... 2.32291887, 1.10419995, 0.77055114, 0.60288273, 1.36883635,
|
||||||
|
... 1.74754326, 1.09547561, 1.01671133, 0.73211143, 0.61891719,
|
||||||
>>> np.trapz(f, x)
|
... 0.75903487, 1.8919469, 0.72433808, 1.92973094, 0.44749838,
|
||||||
0.97323338046725172
|
... 1.36508452])
|
||||||
|
|
||||||
h1 = plb.plot(x, f) # 1D probability density plot
|
>>> data = np.asarray([1,2])
|
||||||
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
||||||
'''
|
>>> kde = wk.KDE(data, hs=0.5)
|
||||||
|
>>> f = kde(x)
|
||||||
def test1a_KDE1D():
|
>>> f
|
||||||
'''
|
array([ 0.0541248 , 0.16555235, 0.33084399, 0.45293325, 0.48345808,
|
||||||
N = 20
|
0.48345808, 0.45293325, 0.33084399, 0.16555235, 0.0541248 ])
|
||||||
data = np.random.rayleigh(1, size=(N,))
|
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
>>> np.trapz(f, x)
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
0.97323338046725172
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
h1 = plb.plot(x, f) # 1D probability density plot
|
||||||
|
'''
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
|
||||||
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
|
||||||
>>> f = kde(x)
|
def test1a_KDE1D():
|
||||||
>>> f
|
'''
|
||||||
array([ 0.17252055, 0.41014271, 0.61349072, 0.57023834, 0.37198073,
|
N = 20
|
||||||
0.21409279, 0.12738463, 0.07460326, 0.03956191, 0.01887164])
|
data = np.random.rayleigh(1, size=(N,))
|
||||||
|
>>> data = array([
|
||||||
>>> np.trapz(f, x)
|
... 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
||||||
0.92938023659047952
|
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
||||||
|
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
||||||
h1 = plb.plot(x, f) # 1D probability density plot
|
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
||||||
|
|
||||||
'''
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
||||||
def test2a_KDE1D():
|
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
||||||
'''
|
>>> f = kde(x)
|
||||||
N = 20
|
>>> f
|
||||||
data = np.random.rayleigh(1, size=(N,))
|
array([ 0.17252055, 0.41014271, 0.61349072, 0.57023834, 0.37198073,
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
0.21409279, 0.12738463, 0.07460326, 0.03956191, 0.01887164])
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
>>> np.trapz(f, x)
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
0.92938023659047952
|
||||||
|
|
||||||
>>> data = np.asarray([1,2])
|
h1 = plb.plot(x, f) # 1D probability density plot
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
'''
|
||||||
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
|
||||||
>>> f = kde(x)
|
|
||||||
>>> f
|
def test2a_KDE1D():
|
||||||
array([ 0.0541248 , 0.16555235, 0.33084399, 0.45293325, 0.48345808,
|
'''
|
||||||
0.48345808, 0.45293325, 0.33084399, 0.16555235, 0.0541248 ])
|
N = 20
|
||||||
|
data = np.random.rayleigh(1, size=(N,))
|
||||||
>>> np.trapz(f, x)
|
>>> data = array([
|
||||||
0.97323338046725172
|
... 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
||||||
|
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
||||||
h1 = plb.plot(x, f) # 1D probability density plot
|
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
||||||
'''
|
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
||||||
|
|
||||||
def test_KDE2D():
|
>>> data = np.asarray([1,2])
|
||||||
'''
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
||||||
N = 20
|
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
||||||
data = np.random.rayleigh(1, size=(2, N))
|
>>> f = kde(x)
|
||||||
>>> data = array([[ 0.38103275, 0.35083136, 0.90024207, 1.88230239, 0.96815399,
|
>>> f
|
||||||
... 0.57392873, 1.63367908, 1.20944125, 2.03887811, 0.81789145,
|
array([ 0.0541248 , 0.16555235, 0.33084399, 0.45293325, 0.48345808,
|
||||||
... 0.69302049, 1.40856592, 0.92156032, 2.14791432, 2.04373821,
|
0.48345808, 0.45293325, 0.33084399, 0.16555235, 0.0541248 ])
|
||||||
... 0.69800708, 0.58428735, 1.59128776, 2.05771405, 0.87021964],
|
|
||||||
... [ 1.44080694, 0.39973751, 1.331243 , 2.48895822, 1.18894158,
|
>>> np.trapz(f, x)
|
||||||
... 1.40526085, 1.01967897, 0.81196474, 1.37978932, 2.03334689,
|
0.97323338046725172
|
||||||
... 0.870329 , 1.25106862, 0.5346619 , 0.47541236, 1.51930093,
|
|
||||||
... 0.58861519, 1.19780448, 0.81548296, 1.56859488, 1.60653533]])
|
h1 = plb.plot(x, f) # 1D probability density plot
|
||||||
|
'''
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 3)
|
|
||||||
|
|
||||||
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
def test_KDE2D():
|
||||||
|
'''
|
||||||
>>> kde0 = wk.KDE(data, hs=0.5, alpha=0.0, inc=16)
|
N = 20
|
||||||
|
data = np.random.rayleigh(1, size=(2, N))
|
||||||
>>> kde0.eval_grid(x, x)
|
>>> data = array([[
|
||||||
array([[ 3.27260963e-02, 4.21654678e-02, 5.85338634e-04],
|
... 0.38103275, 0.35083136, 0.90024207, 1.88230239, 0.96815399,
|
||||||
[ 6.78845466e-02, 1.42195839e-01, 1.41676003e-03],
|
... 0.57392873, 1.63367908, 1.20944125, 2.03887811, 0.81789145,
|
||||||
[ 1.39466746e-04, 4.26983850e-03, 2.52736185e-05]])
|
... 0.69302049, 1.40856592, 0.92156032, 2.14791432, 2.04373821,
|
||||||
>>> kde0.eval_grid_fast(x, x)
|
... 0.69800708, 0.58428735, 1.59128776, 2.05771405, 0.87021964],
|
||||||
array([[ 0.04435061, 0.06433531, 0.00413538],
|
... [1.44080694, 0.39973751, 1.331243 , 2.48895822, 1.18894158,
|
||||||
[ 0.07218297, 0.12358196, 0.00928889],
|
... 1.40526085, 1.01967897, 0.81196474, 1.37978932, 2.03334689,
|
||||||
[ 0.00161333, 0.00794858, 0.00058748]])
|
... 0.870329 , 1.25106862, 0.5346619 , 0.47541236, 1.51930093,
|
||||||
|
... 0.58861519, 1.19780448, 0.81548296, 1.56859488, 1.60653533]])
|
||||||
'''
|
|
||||||
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 3)
|
||||||
def test_smooth_params():
|
|
||||||
'''
|
>>> kde = wk.KDE(data, hs=0.5, alpha=0.5)
|
||||||
>>> data = np.array([[ 0.932896 , 0.89522635, 0.80636346, 1.32283371, 0.27125435,
|
|
||||||
... 1.91666304, 2.30736635, 1.13662384, 1.73071287, 1.06061127,
|
>>> kde0 = wk.KDE(data, hs=0.5, alpha=0.0, inc=16)
|
||||||
... 0.99598512, 2.16396591, 1.23458213, 1.12406686, 1.16930431,
|
|
||||||
... 0.73700592, 1.21135139, 0.46671506, 1.3530304 , 0.91419104],
|
>>> kde0.eval_grid(x, x)
|
||||||
... [ 0.62759088, 0.23988169, 2.04909823, 0.93766571, 1.19343762,
|
array([[ 3.27260963e-02, 4.21654678e-02, 5.85338634e-04],
|
||||||
... 1.94954931, 0.84687514, 0.49284897, 1.05066204, 1.89088505,
|
[ 6.78845466e-02, 1.42195839e-01, 1.41676003e-03],
|
||||||
... 0.840738 , 1.02901457, 1.0758625 , 1.76357967, 0.45792897,
|
[ 1.39466746e-04, 4.26983850e-03, 2.52736185e-05]])
|
||||||
... 1.54488066, 0.17644313, 1.6798871 , 0.72583514, 2.22087245],
|
>>> kde0.eval_grid_fast(x, x)
|
||||||
... [ 1.69496432, 0.81791905, 0.82534709, 0.71642389, 0.89294732,
|
array([[ 0.04435061, 0.06433531, 0.00413538],
|
||||||
... 1.66888649, 0.69036947, 0.99961448, 0.30657267, 0.98798713,
|
[ 0.07218297, 0.12358196, 0.00928889],
|
||||||
... 0.83298728, 1.83334948, 1.90144186, 1.25781913, 0.07122458,
|
[ 0.00161333, 0.00794858, 0.00058748]])
|
||||||
... 2.42340852, 2.41342037, 0.87233305, 1.17537114, 1.69505988]])
|
|
||||||
|
'''
|
||||||
>>> gauss = wk.Kernel('gaussian')
|
|
||||||
>>> gauss.hns(data)
|
|
||||||
array([ 0.18154437, 0.36207987, 0.37396219])
|
def test_smooth_params():
|
||||||
>>> gauss.hos(data)
|
'''
|
||||||
array([ 0.195209 , 0.3893332 , 0.40210988])
|
>>> data = np.array([[
|
||||||
>>> gauss.hmns(data)
|
... 0.932896 , 0.89522635, 0.80636346, 1.32283371, 0.27125435,
|
||||||
array([[ 3.25196193e-01, -2.68892467e-02, 3.18932448e-04],
|
... 1.91666304, 2.30736635, 1.13662384, 1.73071287, 1.06061127,
|
||||||
[ -2.68892467e-02, 3.91283306e-01, 2.38654678e-02],
|
... 0.99598512, 2.16396591, 1.23458213, 1.12406686, 1.16930431,
|
||||||
[ 3.18932448e-04, 2.38654678e-02, 4.05123874e-01]])
|
... 0.73700592, 1.21135139, 0.46671506, 1.3530304 , 0.91419104],
|
||||||
>>> gauss.hscv(data)
|
... [ 0.62759088, 0.23988169, 2.04909823, 0.93766571, 1.19343762,
|
||||||
array([ 0.16858959, 0.32739383, 0.3046287 ])
|
... 1.94954931, 0.84687514, 0.49284897, 1.05066204, 1.89088505,
|
||||||
|
... 0.840738 , 1.02901457, 1.0758625 , 1.76357967, 0.45792897,
|
||||||
>>> gauss.hstt(data)
|
... 1.54488066, 0.17644313, 1.6798871 , 0.72583514, 2.22087245],
|
||||||
array([ 0.18099075, 0.50409881, 0.11018912])
|
... [ 1.69496432, 0.81791905, 0.82534709, 0.71642389, 0.89294732,
|
||||||
|
... 1.66888649, 0.69036947, 0.99961448, 0.30657267, 0.98798713,
|
||||||
>>> gauss.hste(data)
|
... 0.83298728, 1.83334948, 1.90144186, 1.25781913, 0.07122458,
|
||||||
array([ 0.16750009, 0.29059113, 0.17994255])
|
... 2.42340852, 2.41342037, 0.87233305, 1.17537114, 1.69505988]])
|
||||||
|
|
||||||
>>> gauss.hldpi(data)
|
>>> gauss = wk.Kernel('gaussian')
|
||||||
array([ 0.1732289 , 0.33159097, 0.3107633 ])
|
>>> gauss.hns(data)
|
||||||
|
array([ 0.18154437, 0.36207987, 0.37396219])
|
||||||
|
>>> gauss.hos(data)
|
||||||
>>> gauss.hisj(data)
|
array([ 0.195209 , 0.3893332 , 0.40210988])
|
||||||
array([ 0.24222479, 0.74277133, 0.15492661])
|
>>> gauss.hmns(data)
|
||||||
|
array([[ 3.25196193e-01, -2.68892467e-02, 3.18932448e-04],
|
||||||
>>> data = np.array([0.753557920000000, 0.727791940000000, 0.941491690000000,
|
[ -2.68892467e-02, 3.91283306e-01, 2.38654678e-02],
|
||||||
... 0.078411190000000, 2.322918870000000, 1.104199950000000, 0.770551140000000,
|
[ 3.18932448e-04, 2.38654678e-02, 4.05123874e-01]])
|
||||||
... 0.602882730000000, 1.368836350000000, 1.747543260000000, 1.095475610000000,
|
>>> gauss.hscv(data)
|
||||||
... 1.016711330000000, 0.732111430000000, 0.618917190000000, 0.759034870000000,
|
array([ 0.16858959, 0.32739383, 0.3046287 ])
|
||||||
... 1.891946900000000, 0.724338080000000, 1.929730940000000, 0.447498380000000, 1.365084520000000])
|
|
||||||
|
>>> gauss.hstt(data)
|
||||||
|
array([ 0.18099075, 0.50409881, 0.11018912])
|
||||||
|
|
||||||
'''
|
>>> gauss.hste(data)
|
||||||
def test_gridcount_1D():
|
array([ 0.16750009, 0.29059113, 0.17994255])
|
||||||
'''
|
|
||||||
N = 20
|
>>> gauss.hldpi(data)
|
||||||
data = np.random.rayleigh(1, size=(N,))
|
array([ 0.1732289 , 0.33159097, 0.3107633 ])
|
||||||
>>> data = array([ 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
|
||||||
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
>>> np.allclose(gauss.hisj(data),
|
||||||
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
... array([ 0.29542502, 0.74277133, 0.51899114]))
|
||||||
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
True
|
||||||
|
'''
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
|
||||||
>>> dx = x[1] - x[0]
|
|
||||||
>>> c = wk.gridcount(data, x)
|
def test_gridcount_1D():
|
||||||
>>> c
|
'''
|
||||||
array([ 0.78762626, 1.77520717, 7.99190087, 4.04054449, 1.67156643,
|
N = 20
|
||||||
2.38228499, 1.05933195, 0.29153785, 0. , 0. ])
|
data = np.random.rayleigh(1, size=(N,))
|
||||||
|
>>> data = array([
|
||||||
h = plb.plot(x, c, '.') # 1D histogram
|
... 0.75355792, 0.72779194, 0.94149169, 0.07841119, 2.32291887,
|
||||||
|
... 1.10419995, 0.77055114, 0.60288273, 1.36883635, 1.74754326,
|
||||||
h1 = plb.plot(x, c / dx / N) # 1D probability density plot
|
... 1.09547561, 1.01671133, 0.73211143, 0.61891719, 0.75903487,
|
||||||
t = np.trapz(c / dx / N, x)
|
... 1.8919469 , 0.72433808, 1.92973094, 0.44749838, 1.36508452])
|
||||||
print(t)
|
|
||||||
'''
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 10)
|
||||||
|
>>> dx = x[1] - x[0]
|
||||||
def test_gridcount_2D():
|
>>> c = wk.gridcount(data, x)
|
||||||
'''
|
>>> c
|
||||||
N = 20
|
array([ 0.78762626, 1.77520717, 7.99190087, 4.04054449, 1.67156643,
|
||||||
data = np.random.rayleigh(1, size=(2, N))
|
2.38228499, 1.05933195, 0.29153785, 0. , 0. ])
|
||||||
>>> data = array([[ 0.38103275, 0.35083136, 0.90024207, 1.88230239, 0.96815399,
|
|
||||||
... 0.57392873, 1.63367908, 1.20944125, 2.03887811, 0.81789145,
|
h = plb.plot(x, c, '.') # 1D histogram
|
||||||
... 0.69302049, 1.40856592, 0.92156032, 2.14791432, 2.04373821,
|
|
||||||
... 0.69800708, 0.58428735, 1.59128776, 2.05771405, 0.87021964],
|
h1 = plb.plot(x, c / dx / N) # 1D probability density plot
|
||||||
... [ 1.44080694, 0.39973751, 1.331243 , 2.48895822, 1.18894158,
|
t = np.trapz(c / dx / N, x)
|
||||||
... 1.40526085, 1.01967897, 0.81196474, 1.37978932, 2.03334689,
|
print(t)
|
||||||
... 0.870329 , 1.25106862, 0.5346619 , 0.47541236, 1.51930093,
|
'''
|
||||||
... 0.58861519, 1.19780448, 0.81548296, 1.56859488, 1.60653533]])
|
|
||||||
|
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 5)
|
def test_gridcount_2D():
|
||||||
>>> dx = x[1] - x[0]
|
'''
|
||||||
>>> X = np.vstack((x, x))
|
N = 20
|
||||||
>>> c = wk.gridcount(data, X)
|
data = np.random.rayleigh(1, size=(2, N))
|
||||||
>>> c
|
>>> data = array([[
|
||||||
array([[ 0.38922806, 0.8987982 , 0.34676493, 0.21042807, 0. ],
|
... 0.38103275, 0.35083136, 0.90024207, 1.88230239, 0.96815399,
|
||||||
[ 1.15012203, 5.16513541, 3.19250588, 0.55420752, 0. ],
|
... 0.57392873, 1.63367908, 1.20944125, 2.03887811, 0.81789145,
|
||||||
[ 0.74293418, 3.42517219, 1.97923195, 0.76076621, 0. ],
|
... 0.69302049, 1.40856592, 0.92156032, 2.14791432, 2.04373821,
|
||||||
[ 0.02063536, 0.31054405, 0.71865964, 0.13486633, 0. ],
|
... 0.69800708, 0.58428735, 1.59128776, 2.05771405, 0.87021964],
|
||||||
[ 0. , 0. , 0. , 0. , 0. ]])
|
... [ 1.44080694, 0.39973751, 1.331243 , 2.48895822, 1.18894158,
|
||||||
|
... 1.40526085, 1.01967897, 0.81196474, 1.37978932, 2.03334689,
|
||||||
h = plb.plot(x, c, '.') # 1D histogram
|
... 0.870329 , 1.25106862, 0.5346619 , 0.47541236, 1.51930093,
|
||||||
|
... 0.58861519, 1.19780448, 0.81548296, 1.56859488, 1.60653533]])
|
||||||
h1 = plb.plot(x, c / dx / N) # 1D probability density plot
|
|
||||||
t = np.trapz(c / dx / N, x)
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 5)
|
||||||
print(t)
|
>>> dx = x[1] - x[0]
|
||||||
'''
|
>>> X = np.vstack((x, x))
|
||||||
def test_gridcount_3D():
|
>>> c = wk.gridcount(data, X)
|
||||||
'''
|
>>> c
|
||||||
N = 20
|
array([[ 0.38922806, 0.8987982 , 0.34676493, 0.21042807, 0. ],
|
||||||
data = np.random.rayleigh(1, size=(3, N))
|
[ 1.15012203, 5.16513541, 3.19250588, 0.55420752, 0. ],
|
||||||
>>> data = np.array([[ 0.932896 , 0.89522635, 0.80636346, 1.32283371, 0.27125435,
|
[ 0.74293418, 3.42517219, 1.97923195, 0.76076621, 0. ],
|
||||||
... 1.91666304, 2.30736635, 1.13662384, 1.73071287, 1.06061127,
|
[ 0.02063536, 0.31054405, 0.71865964, 0.13486633, 0. ],
|
||||||
... 0.99598512, 2.16396591, 1.23458213, 1.12406686, 1.16930431,
|
[ 0. , 0. , 0. , 0. , 0. ]])
|
||||||
... 0.73700592, 1.21135139, 0.46671506, 1.3530304 , 0.91419104],
|
|
||||||
... [ 0.62759088, 0.23988169, 2.04909823, 0.93766571, 1.19343762,
|
h = plb.plot(x, c, '.') # 1D histogram
|
||||||
... 1.94954931, 0.84687514, 0.49284897, 1.05066204, 1.89088505,
|
|
||||||
... 0.840738 , 1.02901457, 1.0758625 , 1.76357967, 0.45792897,
|
h1 = plb.plot(x, c / dx / N) # 1D probability density plot
|
||||||
... 1.54488066, 0.17644313, 1.6798871 , 0.72583514, 2.22087245],
|
t = np.trapz(c / dx / N, x)
|
||||||
... [ 1.69496432, 0.81791905, 0.82534709, 0.71642389, 0.89294732,
|
print(t)
|
||||||
... 1.66888649, 0.69036947, 0.99961448, 0.30657267, 0.98798713,
|
'''
|
||||||
... 0.83298728, 1.83334948, 1.90144186, 1.25781913, 0.07122458,
|
|
||||||
... 2.42340852, 2.41342037, 0.87233305, 1.17537114, 1.69505988]])
|
|
||||||
|
def test_gridcount_3D():
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 3)
|
'''
|
||||||
>>> dx = x[1] - x[0]
|
N = 20
|
||||||
>>> X = np.vstack((x, x, x))
|
data = np.random.rayleigh(1, size=(3, N))
|
||||||
>>> c = wk.gridcount(data, X)
|
>>> data = np.array([[
|
||||||
>>> c
|
... 0.932896 , 0.89522635, 0.80636346, 1.32283371, 0.27125435,
|
||||||
array([[[ 8.74229894e-01, 1.27910940e+00, 1.42033973e-01],
|
... 1.91666304, 2.30736635, 1.13662384, 1.73071287, 1.06061127,
|
||||||
[ 1.94778915e+00, 2.59536282e+00, 3.28213680e-01],
|
... 0.99598512, 2.16396591, 1.23458213, 1.12406686, 1.16930431,
|
||||||
[ 1.08429416e-01, 1.69571495e-01, 7.48896775e-03]],
|
... 0.73700592, 1.21135139, 0.46671506, 1.3530304 , 0.91419104],
|
||||||
<BLANKLINE>
|
... [ 0.62759088, 0.23988169, 2.04909823, 0.93766571, 1.19343762,
|
||||||
[[ 1.44969128e+00, 2.58396370e+00, 2.45459949e-01],
|
... 1.94954931, 0.84687514, 0.49284897, 1.05066204, 1.89088505,
|
||||||
[ 2.28951650e+00, 4.49653348e+00, 2.73167915e-01],
|
... 0.840738 , 1.02901457, 1.0758625 , 1.76357967, 0.45792897,
|
||||||
[ 1.10905565e-01, 3.18733817e-01, 1.12880816e-02]],
|
... 1.54488066, 0.17644313, 1.6798871 , 0.72583514, 2.22087245],
|
||||||
<BLANKLINE>
|
... [ 1.69496432, 0.81791905, 0.82534709, 0.71642389, 0.89294732,
|
||||||
[[ 7.49265424e-02, 2.18142488e-01, 0.00000000e+00],
|
... 1.66888649, 0.69036947, 0.99961448, 0.30657267, 0.98798713,
|
||||||
[ 8.53886762e-02, 3.73415131e-01, 0.00000000e+00],
|
... 0.83298728, 1.83334948, 1.90144186, 1.25781913, 0.07122458,
|
||||||
[ 4.16196568e-04, 1.62218824e-02, 0.00000000e+00]]])
|
... 2.42340852, 2.41342037, 0.87233305, 1.17537114, 1.69505988]])
|
||||||
|
|
||||||
'''
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 3)
|
||||||
def test_gridcount_4D():
|
>>> dx = x[1] - x[0]
|
||||||
'''
|
>>> X = np.vstack((x, x, x))
|
||||||
N = 20
|
>>> c = wk.gridcount(data, X)
|
||||||
data = np.random.rayleigh(1, size=(2, N))
|
>>> c
|
||||||
>>> data = array([[ 0.38103275, 0.35083136, 0.90024207, 1.88230239, 0.96815399,
|
array([[[ 8.74229894e-01, 1.27910940e+00, 1.42033973e-01],
|
||||||
... 0.57392873, 1.63367908, 1.20944125, 2.03887811, 0.81789145],
|
[ 1.94778915e+00, 2.59536282e+00, 3.28213680e-01],
|
||||||
... [ 0.69302049, 1.40856592, 0.92156032, 2.14791432, 2.04373821,
|
[ 1.08429416e-01, 1.69571495e-01, 7.48896775e-03]],
|
||||||
... 0.69800708, 0.58428735, 1.59128776, 2.05771405, 0.87021964],
|
<BLANKLINE>
|
||||||
... [ 1.44080694, 0.39973751, 1.331243 , 2.48895822, 1.18894158,
|
[[ 1.44969128e+00, 2.58396370e+00, 2.45459949e-01],
|
||||||
... 1.40526085, 1.01967897, 0.81196474, 1.37978932, 2.03334689],
|
[ 2.28951650e+00, 4.49653348e+00, 2.73167915e-01],
|
||||||
... [ 0.870329 , 1.25106862, 0.5346619 , 0.47541236, 1.51930093,
|
[ 1.10905565e-01, 3.18733817e-01, 1.12880816e-02]],
|
||||||
... 0.58861519, 1.19780448, 0.81548296, 1.56859488, 1.60653533]])
|
<BLANKLINE>
|
||||||
|
[[ 7.49265424e-02, 2.18142488e-01, 0.00000000e+00],
|
||||||
>>> x = np.linspace(0, max(data.ravel()) + 1, 3)
|
[ 8.53886762e-02, 3.73415131e-01, 0.00000000e+00],
|
||||||
>>> dx = x[1] - x[0]
|
[ 4.16196568e-04, 1.62218824e-02, 0.00000000e+00]]])
|
||||||
>>> X = np.vstack((x, x, x, x))
|
|
||||||
>>> c = wk.gridcount(data, X)
|
'''
|
||||||
>>> c
|
|
||||||
array([[[[ 1.77163904e-01, 1.87720108e-01, 0.00000000e+00],
|
|
||||||
[ 5.72573585e-01, 6.09557834e-01, 0.00000000e+00],
|
def test_gridcount_4D():
|
||||||
[ 3.48549923e-03, 4.05931870e-02, 0.00000000e+00]],
|
'''
|
||||||
<BLANKLINE>
|
N = 20
|
||||||
[[ 1.83770124e-01, 2.56357594e-01, 0.00000000e+00],
|
data = np.random.rayleigh(1, size=(2, N))
|
||||||
[ 4.35845892e-01, 6.14958970e-01, 0.00000000e+00],
|
>>> data = array([[
|
||||||
[ 3.07662204e-03, 3.58312786e-02, 0.00000000e+00]],
|
... 0.38103275, 0.35083136, 0.90024207, 1.88230239, 0.96815399,
|
||||||
<BLANKLINE>
|
... 0.57392873, 1.63367908, 1.20944125, 2.03887811, 0.81789145],
|
||||||
[[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
... [ 0.69302049, 1.40856592, 0.92156032, 2.14791432, 2.04373821,
|
||||||
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
... 0.69800708, 0.58428735, 1.59128776, 2.05771405, 0.87021964],
|
||||||
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]]],
|
... [ 1.44080694, 0.39973751, 1.331243 , 2.48895822, 1.18894158,
|
||||||
<BLANKLINE>
|
... 1.40526085, 1.01967897, 0.81196474, 1.37978932, 2.03334689],
|
||||||
<BLANKLINE>
|
... [ 0.870329 , 1.25106862, 0.5346619 , 0.47541236, 1.51930093,
|
||||||
[[[ 3.41883175e-01, 5.97977973e-01, 0.00000000e+00],
|
... 0.58861519, 1.19780448, 0.81548296, 1.56859488, 1.60653533]])
|
||||||
[ 5.72071865e-01, 8.58566538e-01, 0.00000000e+00],
|
|
||||||
[ 3.46939323e-03, 4.04056116e-02, 0.00000000e+00]],
|
>>> x = np.linspace(0, max(data.ravel()) + 1, 3)
|
||||||
<BLANKLINE>
|
>>> dx = x[1] - x[0]
|
||||||
[[ 3.58861043e-01, 6.28962785e-01, 0.00000000e+00],
|
>>> X = np.vstack((x, x, x, x))
|
||||||
[ 8.80697705e-01, 1.47373158e+00, 0.00000000e+00],
|
>>> c = wk.gridcount(data, X)
|
||||||
[ 2.22868504e-01, 1.18008528e-01, 0.00000000e+00]],
|
>>> c
|
||||||
<BLANKLINE>
|
array([[[[ 1.77163904e-01, 1.87720108e-01, 0.00000000e+00],
|
||||||
[[ 2.91835067e-03, 2.60268355e-02, 0.00000000e+00],
|
[ 5.72573585e-01, 6.09557834e-01, 0.00000000e+00],
|
||||||
[ 3.63686503e-02, 1.07959459e-01, 0.00000000e+00],
|
[ 3.48549923e-03, 4.05931870e-02, 0.00000000e+00]],
|
||||||
[ 1.88555613e-02, 7.06358976e-03, 0.00000000e+00]]],
|
<BLANKLINE>
|
||||||
<BLANKLINE>
|
[[ 1.83770124e-01, 2.56357594e-01, 0.00000000e+00],
|
||||||
<BLANKLINE>
|
[ 4.35845892e-01, 6.14958970e-01, 0.00000000e+00],
|
||||||
[[[ 3.13810608e-03, 2.11731327e-02, 0.00000000e+00],
|
[ 3.07662204e-03, 3.58312786e-02, 0.00000000e+00]],
|
||||||
[ 6.71606255e-03, 4.53139824e-02, 0.00000000e+00],
|
<BLANKLINE>
|
||||||
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]],
|
[[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
||||||
<BLANKLINE>
|
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
|
||||||
[[ 7.05946179e-03, 5.44614852e-02, 0.00000000e+00],
|
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]]],
|
||||||
[ 1.09099593e-01, 1.95935584e-01, 0.00000000e+00],
|
<BLANKLINE>
|
||||||
[ 6.61257395e-02, 2.47717418e-02, 0.00000000e+00]],
|
<BLANKLINE>
|
||||||
<BLANKLINE>
|
[[[ 3.41883175e-01, 5.97977973e-01, 0.00000000e+00],
|
||||||
[[ 6.38695629e-04, 5.69610302e-03, 0.00000000e+00],
|
[ 5.72071865e-01, 8.58566538e-01, 0.00000000e+00],
|
||||||
[ 1.00358265e-02, 2.44053065e-02, 0.00000000e+00],
|
[ 3.46939323e-03, 4.04056116e-02, 0.00000000e+00]],
|
||||||
[ 5.67244468e-03, 2.12498697e-03, 0.00000000e+00]]]])
|
<BLANKLINE>
|
||||||
|
[[ 3.58861043e-01, 6.28962785e-01, 0.00000000e+00],
|
||||||
h = plb.plot(x, c, '.') # 1D histogram
|
[ 8.80697705e-01, 1.47373158e+00, 0.00000000e+00],
|
||||||
|
[ 2.22868504e-01, 1.18008528e-01, 0.00000000e+00]],
|
||||||
h1 = plb.plot(x, c / dx / N) # 1D probability density plot
|
<BLANKLINE>
|
||||||
t = np.trapz(x, c / dx / N)
|
[[ 2.91835067e-03, 2.60268355e-02, 0.00000000e+00],
|
||||||
print(t)
|
[ 3.63686503e-02, 1.07959459e-01, 0.00000000e+00],
|
||||||
'''
|
[ 1.88555613e-02, 7.06358976e-03, 0.00000000e+00]]],
|
||||||
|
<BLANKLINE>
|
||||||
def test_docstrings():
|
<BLANKLINE>
|
||||||
import doctest
|
[[[ 3.13810608e-03, 2.11731327e-02, 0.00000000e+00],
|
||||||
doctest.testmod()
|
[ 6.71606255e-03, 4.53139824e-02, 0.00000000e+00],
|
||||||
|
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]],
|
||||||
if __name__ == '__main__':
|
<BLANKLINE>
|
||||||
test_docstrings()
|
[[ 7.05946179e-03, 5.44614852e-02, 0.00000000e+00],
|
||||||
|
[ 1.09099593e-01, 1.95935584e-01, 0.00000000e+00],
|
||||||
|
[ 6.61257395e-02, 2.47717418e-02, 0.00000000e+00]],
|
||||||
|
<BLANKLINE>
|
||||||
|
[[ 6.38695629e-04, 5.69610302e-03, 0.00000000e+00],
|
||||||
|
[ 1.00358265e-02, 2.44053065e-02, 0.00000000e+00],
|
||||||
|
[ 5.67244468e-03, 2.12498697e-03, 0.00000000e+00]]]])
|
||||||
|
|
||||||
|
h = plb.plot(x, c, '.') # 1D histogram
|
||||||
|
|
||||||
|
h1 = plb.plot(x, c / dx / N) # 1D probability density plot
|
||||||
|
t = np.trapz(x, c / dx / N)
|
||||||
|
print(t)
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def test_docstrings():
|
||||||
|
import doctest
|
||||||
|
print('Testing docstrings in %s' % __file__)
|
||||||
|
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test_docstrings()
|
||||||
|
Loading…
Reference in New Issue