/usr/lib/python2.7/dist-packages/pywt/data/_readers.py is in python-pywt 0.5.1-1.1ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | import os
import numpy as np
def ascent():
"""
Get an 8-bit grayscale bit-depth, 512 x 512 derived image for
easy use in demos
The image is derived from accent-to-the-top.jpg at
http://www.public-domain-image.com/people-public-domain-images-pictures/
Parameters
----------
None
Returns
-------
ascent : ndarray
convenient image to use for testing and demonstration
Examples
--------
>>> import pywt.data
>>> ascent = pywt.data.ascent()
>>> ascent.shape == (512, 512)
True
>>> ascent.max()
255
>>> import matplotlib.pyplot as plt
>>> plt.gray()
>>> plt.imshow(ascent) # doctest: +ELLIPSIS
<matplotlib.image.AxesImage object at ...>
>>> plt.show() # doctest: +SKIP
"""
fname = os.path.join(os.path.dirname(__file__), 'ascent.npz')
ascent = np.load(fname)['data']
return ascent
def aero():
"""
Get an 8-bit grayscale bit-depth, 512 x 512 derived image for
easy use in demos
Parameters
----------
None
Returns
-------
aero : ndarray
convenient image to use for testing and demonstration
Examples
--------
>>> import pywt.data
>>> aero = pywt.data.ascent()
>>> aero.shape == (512, 512)
True
>>> aero.max()
255
>>> import matplotlib.pyplot as plt
>>> plt.gray()
>>> plt.imshow(aero) # doctest: +ELLIPSIS
<matplotlib.image.AxesImage object at ...>
>>> plt.show() # doctest: +SKIP
"""
fname = os.path.join(os.path.dirname(__file__), 'aero.npz')
aero = np.load(fname)['data']
return aero
def camera():
"""
Get an 8-bit grayscale bit-depth, 512 x 512 derived image for
easy use in demos
Parameters
----------
None
Returns
-------
camera : ndarray
convenient image to use for testing and demonstration
Examples
--------
>>> import pywt.data
>>> camera = pywt.data.ascent()
>>> camera.shape == (512, 512)
True
>>> import matplotlib.pyplot as plt
>>> plt.gray()
>>> plt.imshow(camera) # doctest: +ELLIPSIS
<matplotlib.image.AxesImage object at ...>
>>> plt.show() # doctest: +SKIP
"""
fname = os.path.join(os.path.dirname(__file__), 'camera.npz')
camera = np.load(fname)['data']
return camera
def ecg():
"""
Get 1024 points of an ECG timeseries.
Parameters
----------
None
Returns
-------
ecg : ndarray
convenient timeseries to use for testing and demonstration
Examples
--------
>>> import pywt.data
>>> ecg = pywt.data.ecg()
>>> ecg.shape == (1024,)
True
>>> import matplotlib.pyplot as plt
>>> plt.plot(ecg) # doctest: +ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
>>> plt.show() # doctest: +SKIP
"""
fname = os.path.join(os.path.dirname(__file__), 'ecg.npy')
ecg = np.load(fname)
return ecg
def nino():
"""
This data contains the averaged monthly sea surface temperature in degrees
Celcius of the Pacific Ocean, between 0-10 degrees South and 90-80 degrees West, from 1950 to 2016.
This dataset is in the public domain and was obtained from NOAA.
National Oceanic and Atmospheric Administration's National Weather Service
ERSSTv4 dataset, nino 3, http://www.cpc.ncep.noaa.gov/data/indices/
Parameters
----------
None
Returns
-------
time : ndarray
convenient timeseries to use for testing and demonstration
sst : ndarray
convenient timeseries to use for testing and demonstration
Examples
--------
>>> import pywt.data
>>> time, sst = pywt.data.nino()
>>> sst.shape == (264,)
True
>>> import matplotlib.pyplot as plt
>>> plt.plot(time,sst) # doctest: +ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
>>> plt.show() # doctest: +SKIP
"""
fname = os.path.join(os.path.dirname(__file__), 'sst_nino3.npz')
sst_csv = np.load(fname)['sst_csv']
# sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True)
# take only full years
n = np.floor(sst_csv.shape[0]/12.)*12.
# Building the mean of three mounth
# the 4. column is nino 3
sst = np.mean(np.reshape(np.array(sst_csv)[:n,4],(n/3,-1)),axis=1)
sst = (sst - np.mean(sst)) / np.std(sst, ddof=1)
dt = 0.25
time = np.arange(len(sst)) * dt + 1950.0 # construct time array
return time, sst
|