Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/matplotlib/__pycache__/mlab.cpython-37.pyc

945 lines
40 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
U<>]G<><00> @s<>dZddlZddlZddlZddlmZddlmZdd<05>Z dd<07>Z
d@dd <09>Z dAd
d <0B>Z ej d d d<0E>dBdd<10><01>ZdCdd <0A>ZdDdd<13>Zdd<15>ZdEdd<17>ZdFdd<19>ZdGdd<1B>ZdHdd<1D>Zejje<02>d<1E>d<1F>ejje<02>d <20>d!<21>ejje<02>d"<22>d#<23>ejdId$d%<25><01>ZejdJd&d'<27><01>ZejdKd(d)<29><01>ZejdLd*d+<2B><01>ZejdMd,d-<2D><01>ZejdNd.d/<2F><01>ZejdOd0d1<64><01>Z d2Z!ejd3d4ee ddd5dfd6d7<64><01>Z"dPd<d=<3D>Z#Gd>d?<3F>d?e$<24>Z%dS)Qa
Numerical python functions written for compatibility with MATLAB
commands with the same names. Most numerical python functions can be found in
the `numpy` and `scipy` libraries. What remains here is code for performing
spectral computations.
Spectral functions
-------------------
`cohere`
Coherence (normalized cross spectral density)
`csd`
Cross spectral density using Welch's average periodogram
`detrend`
Remove the mean or best fit line from an array
`psd`
Power spectral density using Welch's average periodogram
`specgram`
Spectrogram (spectrum over segments of time)
`complex_spectrum`
Return the complex-valued frequency spectrum of a signal
`magnitude_spectrum`
Return the magnitude of the frequency spectrum of a signal
`angle_spectrum`
Return the angle (wrapped phase) of the frequency spectrum of a signal
`phase_spectrum`
Return the phase (unwrapped angle) of the frequency spectrum of a signal
`detrend_mean`
Remove the mean from a line.
`detrend_linear`
Remove the best fit line from a line.
`detrend_none`
Return the original line.
`stride_windows`
Get all windows in an array in a memory-efficient manner
`stride_repeat`
Repeat an array in a memory-efficient manner
`apply_window`
Apply a window along a given axis
<EFBFBD>N)<01> docstringcCst<00>t|<00><01>|S)z}
Return x times the hanning window of len(x).
See Also
--------
window_none : Another window algorithm.
)<03>npZhanning<6E>len)<01>x<>r<00>7/tmp/pip-install-i8dhxrtk/matplotlib/matplotlib/mlab.py<70>window_hanningAsrcCs|S)zx
No window function; simply return x.
See Also
--------
window_hanning : Another window algorithm.
r)rrrr<00> window_noneLsr c
Cs<>t<00>|<00>}|jdks|jdkr&td<03><01>|d|jkr@td|<00><01>t|j<05>}|<04>|<02>}t<00>|<01>rxt|<01>|krrtd<05><01>|}n|tj ||j
d<06><02>}|jdkr<>|r<>|||fS||S|<04><06>}|dd}t |||d<07>} |r<>| ||fS| |SdS) a
Apply the given window to the given 1D or 2D array along the given axis.
Parameters
----------
x : 1D or 2D array or sequence
Array or sequence containing the data.
window : function or array.
Either a function to generate a window or an array with length
*x*.shape[*axis*]
axis : integer
The axis over which to do the repetition.
Must be 0 or 1. The default is 0
return_window : bool
If true, also return the 1D values of the window that was applied
<20><00>z only 1D or 2D arrays can be usedzaxis(=%s) out of boundszFThe len(window) must be the same as the shape of x for the chosen axis)<01>dtype)<01>axisN) r<00>asarray<61>ndim<69>
ValueError<EFBFBD>list<73>shape<70>pop<6F>iterablerZonesr <00> stride_repeat)
r<00>windowr <00> return_windowZxshapeZ
xshapetarg<EFBFBD>
windowValsZ xshapeotherZ otheraxisZ windowValsReprrr<00> apply_windowWs,
 


 
   rcCs<>|dks|dkrt|t|d<03>S|dkr4t|t|d<03>S|dkrJt|t|d<03>St|t<05>r`td|<00><01>t|<01>sttd|<00><01>t<08> |<00>}|dk r<>|d|j
kr<>td|<00><01>|dkr<>|j
d ks<>|s<>|j
dkr<>||<00>Sy |||d
<EFBFBD>St k
<EFBFBD>r<>tj |||d <0B>SXdS) a<>
Return x with its trend removed.
Parameters
----------
x : array or sequence
Array or sequence containing the data.
key : [ 'default' | 'constant' | 'mean' | 'linear' | 'none'] or function
Specifies the detrend algorithm to use. 'default' is 'mean', which is
the same as `detrend_mean`. 'constant' is the same. 'linear' is
the same as `detrend_linear`. 'none' is the same as
`detrend_none`. The default is 'mean'. See the corresponding
functions for more details regarding the algorithms. Can also be a
function that carries out the detrend operation.
axis : integer
The axis along which to do the detrending.
See Also
--------
detrend_mean : Implementation of the 'mean' algorithm.
detrend_linear : Implementation of the 'linear' algorithm.
detrend_none : Implementation of the 'none' algorithm.
N)Zconstant<6E>mean<61>default)<02>keyr Zlinear<61>nonez`Unknown value for key %s, must be one of: 'default', 'constant', 'mean', 'linear', or a functionr
zaxis(=%s) out of boundsr)r )r Zarr) <0A>detrend<6E> detrend_mean<61>detrend_linear<61> detrend_none<6E>
isinstance<EFBFBD>strr<00>callablerrr<00> TypeErrorZapply_along_axis)rrr rrrr<00>s*

   rz3.1r)<01> alternativecCs t||d<01>S)a<>
Return x minus its mean along the specified axis.
Parameters
----------
x : array or sequence
Array or sequence containing the data
Can have any dimensionality
axis : integer
The axis along which to take the mean. See numpy.mean for a
description of this argument.
See Also
--------
detrend_mean : Same as `demean` except for the default *axis*.
)r )r)rr rrr<00>demean<61>sr'cCs>t<00>|<00>}|dk r,|d|jkr,td|<00><01>||j|dd<05>S)a<>
Return x minus the mean(x).
Parameters
----------
x : array or sequence
Array or sequence containing the data
Can have any dimensionality
axis : integer
The axis along which to take the mean. See numpy.mean for a
description of this argument.
See Also
--------
detrend_linear : Another detrend algorithm.
detrend_none : Another detrend algorithm.
detrend : A wrapper around all the detrend algorithms.
Nr
zaxis(=%s) out of boundsT)Zkeepdims)rrrrr)rr rrrr<00>s
 cCs|S)a<>
Return x: no detrending.
Parameters
----------
x : any object
An object containing the data
axis : integer
This parameter is ignored.
It is included for compatibility with detrend_mean
See Also
--------
detrend_mean : Another detrend algorithm.
detrend_linear : Another detrend algorithm.
detrend : A wrapper around all the detrend algorithms.
r)rr rrrr!<00>sr!cCs<>t<00>|<00>}|jdkrtd<02><01>|js2tjd|jd<04>Stj|jtd<04>}tj ||dd<05>}|d|d}|<00>
<EFBFBD>||<01>
<EFBFBD>}||||S)a<>
Return x minus best fit line; 'linear' detrending.
Parameters
----------
y : 0-D or 1-D array or sequence
Array or sequence containing the data
axis : integer
The axis along which to take the mean. See numpy.mean for a
description of this argument.
See Also
--------
detrend_mean : Another detrend algorithm.
detrend_none : Another detrend algorithm.
detrend : A wrapper around all the detrend algorithms.
r
zy cannot have ndim > 1g)r )<01>bias)rr
)rr) rrrr<00>arrayr <00>arange<67>size<7A>float<61>covr)<05>yr<00>C<>b<>arrrr s

r cCs|dkr d}||krtd<03><01>|dkr,td<05><01>t<01>|<00>}|jdkrHtd<06><01>|dkrx|dkrx|dkrj|tjS|tj<00><05>S||jkr<>td<07><01>t|<02>}t|<01>}||}|dkr<>||jd||f}|j d||j df}n.|jd|||f}||j d|j df}tj
j j |||d <09>S)
a~
Get all windows of x with length n as a single array,
using strides to avoid data duplication.
.. warning::
It is not safe to write to the output array. Multiple
elements may point to the same piece of memory,
so modifying one value may change others.
Parameters
----------
x : 1D array or sequence
Array or sequence containing the data.
n : integer
The number of data points in each window.
noverlap : integer
The overlap between adjacent windows.
Default is 0 (no overlap)
axis : integer
The axis along which the windows will run.
References
----------
`stackoverflow: Rolling window for 1D arrays in Numpy?
<http://stackoverflow.com/a/6811241>`_
`stackoverflow: Using strides for an efficient moving average filter
<http://stackoverflow.com/a/4947453>`_
Nrznoverlap must be less than nr
zn cannot be less than 1z%only 1-dimensional arrays can be usedz(n cannot be greater than the length of x<><78><EFBFBD><EFBFBD><EFBFBD>)r<00>strides) rrrr<00>newaxisZ transposer+<00>intrr3<00>lib<69> stride_tricks<6B>
as_strided)r<00>n<>noverlapr <00>steprr3rrr<00>stride_windows7s0!



r<cCs<>|dkrtd<02><01>t<01>|<00>}|jdkr,td<04><01>|dkrR|dkrFt<01>|<00>St<01>|<00>jS|dkrbtd<06><01>t|<01>}|dkr<>||jf}d|jdf}n|j|f}|jddf}tj j
j |||d<07>S)a<>
Repeat the values in an array in a memory-efficient manner. Array x is
stacked vertically n times.
.. warning::
It is not safe to write to the output array. Multiple
elements may point to the same piece of memory, so
modifying one value may change others.
Parameters
----------
x : 1D array or sequence
Array or sequence containing the data.
n : integer
The number of time to repeat the array.
axis : integer
The axis along which the data will run.
References
----------
`stackoverflow: Repeat NumPy array without replicating data?
<http://stackoverflow.com/a/5568169>`_
)rr
zaxis must be 0 or 1r
z%only 1-dimensional arrays can be usedrzn cannot be less than 1)rr3) rrrr<00>
atleast_2d<EFBFBD>Tr5r+r3r6r7r8)rr9r rr3rrrr{s$


 

rc Cs\|dkrd} n||k} |dkr"d}|dkr.d}|dkr:t}|dkrFt}|dkrRd}|
dksb|
dkrhd}
n|
dkr|td |
<00><01>| s<>|
dkr<>td
<EFBFBD><01>t<03>|<00>}| s<>t<03>|<01>}|dks<>|dkr<>t<03>|<00>r<>d }q<>d }n|d kr<>td|<00><01>t|<00>|k<00>rt|<00>} t<03>||<02>}d|| d<01><| <0B>sDt|<01>|k<00>rDt|<01>} t<03>||<02>}d|| d<01><|dk<08>rR|}|
dk<03>rbd} n| dk<08>rpd} |d k<02>r<>|} |d<00>r<>|ddd}n|d}d}n2|d k<02>r<>|d<00>r<>|dd} n |dd} d}t|||dd<13>}t ||dd<13>}t
||ddd<14>\}}tj j ||dd<15>d| <0A>dd<01>f}tj <0B> |d|<00>d| <0A>}| <0B>s<>t|||<06>}t ||dd<13>}t
||dd<13>}tj j ||dd<15>d| <0A>dd<01>f}t<03> |<10>|}nz|
dk<02>r<>t<03> |<10>|}n`|
dk<02>r<>t<03>|<10>t<03>|<11><01><0F>}n<|
dk<02>s<>|
dk<02>rt<03>|<10>}n|
dk<02>r"|t<03>|<11><01><0F>}|
dk<02>r<>|d<00>sDtddd<01>}n tddd<01>}|||9<| <09>r<>||}|t<03>|<11>d<00><0F>}n|t<03>|<11><01><0F>d}t<03>|dt|<00>|dd||<00>|}|d k<02>r t<03>||d<01>|d|<0E>f<02>}t<03>||d<01>dd<01>f|d|<0E>dd<01>ffd<04>}n|d<00>s:|dd9<|
dk<02>rRtj|dd<13>}|||fS)z<>
This is a helper function that implements the commonality between the
psd, csd, spectrogram and complex, magnitude, angle, and phase spectrums.
It is *NOT* meant to be used outside of mlab and may change at any time.
NTr r<00>r<00>psd)r@<00>complex<65> magnitude<64>angle<6C>phasezeUnknown value for mode %s, must be one of: 'default', 'psd', 'complex', 'magnitude', 'angle', 'phase'z*x and y must be equal if mode is not 'psd'<27>twosided<65>onesided)rFrEzPUnknown value for sides %s, must be one of: 'default', 'onesided', or 'twosided'Fr
g<00>?g@)r )r r)r9r rBrCrDrAr2)r!rrrrZ iscomplexobjr<00>resizer<rrZfftZfftfreqZconj<6E>abs<62>sumrC<00>slicer*Z concatenate<74>unwrap)rr.<00>NFFT<46>Fs<46> detrend_funcrr:<00>pad_to<74>sides<65> scale_by_freq<65>modeZ same_datar9ZnumFreqsZ
freqcenterZscaling_factor<6F>resultr<00>freqsZresultYZslc<6C>trrr<00>_spectral_helper<65>s<> 


    






  " "

 


 *


rVc Cs<>|dks|dks|dkr$td|<00><01>|dkr4t|<00>}t|dt|<00>|t|d||d|d<07> \}}}|dkrj|j}|jd kr<>|jd
d
kr<>|dd<01>df}||fS) z<>
This is a helper function that implements the commonality between the
complex, magnitude, angle, and phase spectrums.
It is *NOT* meant to be used outside of mlab and may change at any time.
Nr@rz2_single_spectrum_helper does not work with %s moderF) rr.rLrMrNrr:rOrPrQrRrAr r
)rrrVr!<00>realrr) rrRrMrrOrP<00>specrT<00>_rrr<00>_single_spectrum_helperPs rZa<>
Fs : scalar
The sampling frequency (samples per time unit). It is used
to calculate the Fourier frequencies, freqs, in cycles per time
unit. The default value is 2.
window : callable or ndarray
A function or a vector of length *NFFT*. To create window vectors see
`window_hanning`, `window_none`, `numpy.blackman`, `numpy.hamming`,
`numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. The
default is `window_hanning`. If a function is passed as the argument,
it must take a data segment as an argument and return the windowed
version of the segment.
sides : {'default', 'onesided', 'twosided'}
Specifies which sides of the spectrum to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. 'onesided' forces the return of a one-sided
spectrum, while 'twosided' forces two-sided.
)ZSpectrala<6C>
pad_to : int
The number of points to which the data segment is padded when
performing the FFT. While not increasing the actual resolution of
the spectrum (the minimum distance between resolvable peaks),
this can give more points in the plot, allowing for more
detail. This corresponds to the *n* parameter in the call to fft().
The default is None, which sets *pad_to* equal to the length of the
input signal (i.e. no padding).
)ZSingle_Spectruma<6D>
pad_to : int
The number of points to which the data segment is padded when
performing the FFT. This can be different from *NFFT*, which
specifies the number of data points used. While not increasing
the actual resolution of the spectrum (the minimum distance between
resolvable peaks), this can give more points in the plot,
allowing for more detail. This corresponds to the *n* parameter
in the call to fft(). The default is None, which sets *pad_to*
equal to *NFFT*
NFFT : int
The number of data points used in each block for the FFT.
A power 2 is most efficient. The default value is 256.
This should *NOT* be used to get zero padding, or the scaling of the
result will be incorrect. Use *pad_to* for this instead.
detrend : {'none', 'mean', 'linear'} or callable, default 'none'
The function applied to each segment before fft-ing, designed to
remove the mean or linear trend. Unlike in MATLAB, where the
*detrend* parameter is a vector, in Matplotlib is it a function.
The :mod:`~matplotlib.mlab` module defines `.detrend_none`,
`.detrend_mean`, and `.detrend_linear`, but you can use a custom
function as well. You can also use a string to choose one of the
functions: 'none' calls `.detrend_none`. 'mean' calls `.detrend_mean`.
'linear' calls `.detrend_linear`.
scale_by_freq : bool, optional
Specifies whether the resulting density values should be scaled
by the scaling frequency, which gives density in units of Hz^-1.
This allows for integration over the returned frequency values.
The default is True for MATLAB compatibility.
)ZPSDc Cs*t|d||||||||d<02>
\} }
| j|
fS)a<>
Compute the power spectral density.
The power spectral density :math:`P_{xx}` by Welch's average
periodogram method. The vector *x* is divided into *NFFT* length
segments. Each segment is detrended by function *detrend* and
windowed by function *window*. *noverlap* gives the length of
the overlap between segments. The :math:`|\mathrm{fft}(i)|^2`
of each segment :math:`i` are averaged to compute :math:`P_{xx}`.
If len(*x*) < *NFFT*, it will be zero padded to *NFFT*.
Parameters
----------
x : 1-D array or sequence
Array or sequence containing the data
%(Spectral)s
%(PSD)s
noverlap : integer
The number of points of overlap between segments.
The default value is 0 (no overlap).
Returns
-------
Pxx : 1-D array
The values for the power spectrum `P_{xx}` (real valued)
freqs : 1-D array
The frequencies corresponding to the elements in *Pxx*
References
----------
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
Wiley & Sons (1986)
See Also
--------
specgram
`specgram` differs in the default overlap; in not returning the mean of
the segment periodograms; and in returning the times of the segments.
magnitude_spectrum : returns the magnitude spectrum.
csd : returns the spectral density between two signals.
N)
rr.rLrMrrr:rOrPrQ)<02>csdrW) rrLrMrrr:rOrPrQ<00>PxxrTrrrr@<00>s3 r@c
Csn|dkr d}t|||||||||| dd<04> \}
} } |
jdkrf|
jddkrV|
jdd<07>}
n|
dd<01>df}
|
| fS) a
Compute the cross-spectral density.
The cross spectral density :math:`P_{xy}` by Welch's average
periodogram method. The vectors *x* and *y* are divided into
*NFFT* length segments. Each segment is detrended by function
*detrend* and windowed by function *window*. *noverlap* gives
the length of the overlap between segments. The product of
the direct FFTs of *x* and *y* are averaged over each segment
to compute :math:`P_{xy}`, with a scaling to correct for power
loss due to windowing.
If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero
padded to *NFFT*.
Parameters
----------
x, y : 1-D arrays or sequences
Arrays or sequences containing the data
%(Spectral)s
%(PSD)s
noverlap : integer
The number of points of overlap between segments.
The default value is 0 (no overlap).
Returns
-------
Pxy : 1-D array
The values for the cross spectrum `P_{xy}` before scaling (real valued)
freqs : 1-D array
The frequencies corresponding to the elements in *Pxy*
References
----------
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
Wiley & Sons (1986)
See Also
--------
psd : equivalent to setting ``y = x``.
Nr?r@) rr.rLrMrNrr:rOrPrQrRr r
)r r)rVrrr) rr.rLrMrrr:rOrPrQ<00>PxyrTrYrrrr[<00>s0

r[cCst|||||dd<02>S)aX
Compute the complex-valued frequency spectrum of *x*. Data is padded to a
length of *pad_to* and the windowing function *window* is applied to the
signal.
Parameters
----------
x : 1-D array or sequence
Array or sequence containing the data
%(Spectral)s
%(Single_Spectrum)s
Returns
-------
spectrum : 1-D array
The values for the complex spectrum (complex valued)
freqs : 1-D array
The frequencies corresponding to the elements in *spectrum*
See Also
--------
magnitude_spectrum
Returns the absolute value of this function.
angle_spectrum
Returns the angle of this function.
phase_spectrum
Returns the phase (unwrapped angle) of this function.
specgram
Can return the complex spectrum of segments within the signal.
rA)rrMrrOrPrR)rZ)rrMrrOrPrrr<00>complex_spectrum,s$
r^cCst|||||dd<02>S)a<>
Compute the magnitude (absolute value) of the frequency spectrum of
*x*. Data is padded to a length of *pad_to* and the windowing function
*window* is applied to the signal.
Parameters
----------
x : 1-D array or sequence
Array or sequence containing the data
%(Spectral)s
%(Single_Spectrum)s
Returns
-------
spectrum : 1-D array
The values for the magnitude spectrum (real valued)
freqs : 1-D array
The frequencies corresponding to the elements in *spectrum*
See Also
--------
psd
Returns the power spectral density.
complex_spectrum
This function returns the absolute value of `complex_spectrum`.
angle_spectrum
Returns the angles of the corresponding frequencies.
phase_spectrum
Returns the phase (unwrapped angle) of the corresponding frequencies.
specgram
Can return the complex spectrum of segments within the signal.
rB)rrMrrOrPrR)rZ)rrMrrOrPrrr<00>magnitude_spectrumTs&
r_cCst|||||dd<02>S)a<>
Compute the angle of the frequency spectrum (wrapped phase spectrum) of
*x*. Data is padded to a length of *pad_to* and the windowing function
*window* is applied to the signal.
Parameters
----------
x : 1-D array or sequence
Array or sequence containing the data
%(Spectral)s
%(Single_Spectrum)s
Returns
-------
spectrum : 1-D array
The values for the angle spectrum in radians (real valued)
freqs : 1-D array
The frequencies corresponding to the elements in *spectrum*
See Also
--------
complex_spectrum
This function returns the angle value of `complex_spectrum`.
magnitude_spectrum
Returns the magnitudes of the corresponding frequencies.
phase_spectrum
Returns the phase (unwrapped angle) of the corresponding frequencies.
specgram
Can return the complex spectrum of segments within the signal.
rC)rrMrrOrPrR)rZ)rrMrrOrPrrr<00>angle_spectrum~s$
r`cCst|||||dd<02>S)a<>
Compute the phase of the frequency spectrum (unwrapped angle spectrum) of
*x*. Data is padded to a length of *pad_to* and the windowing function
*window* is applied to the signal.
Parameters
----------
x : 1-D array or sequence
Array or sequence containing the data
%(Spectral)s
%(Single_Spectrum)s
Returns
-------
spectrum : 1-D array
The values for the phase spectrum in radians (real valued)
freqs : 1-D array
The frequencies corresponding to the elements in *spectrum*
See Also
--------
complex_spectrum
This function returns the phase value of `complex_spectrum`.
magnitude_spectrum
Returns the magnitudes of the corresponding frequencies.
angle_spectrum
Returns the angle (wrapped phase) of the corresponding frequencies.
specgram
Can return the complex spectrum of segments within the signal.
rD)rrMrrOrPrR)rZ)rrMrrOrPrrr<00>phase_spectrum<75>s$
rac
Csv|dkr d}|dkrd}t|<00>|kr:t<01>d|t|<00>f<00>t|d||||||||| d<05> \}
} } | dkrl|
j}
|
| | fS)a&
Compute a spectrogram.
Compute and plot a spectrogram of data in x. Data are split into
NFFT length segments and the spectrum of each section is
computed. The windowing function window is applied to each
segment, and the amount of overlap of each segment is
specified with noverlap.
Parameters
----------
x : array_like
1-D array or sequence.
%(Spectral)s
%(PSD)s
noverlap : int, optional
The number of points of overlap between blocks. The default
value is 128.
mode : str, optional
What sort of spectrum to use, default is 'psd'.
'psd'
Returns the power spectral density.
'complex'
Returns the complex-valued frequency spectrum.
'magnitude'
Returns the magnitude spectrum.
'angle'
Returns the phase spectrum without unwrapping.
'phase'
Returns the phase spectrum with unwrapping.
Returns
-------
spectrum : array_like
2-D array, columns are the periodograms of successive segments.
freqs : array_like
1-D array, frequencies corresponding to the rows in *spectrum*.
t : array_like
1-D array, the times corresponding to midpoints of segments
(i.e the columns in *spectrum*).
See Also
--------
psd : differs in the overlap and in the return values.
complex_spectrum : similar, but with complex valued frequencies.
magnitude_spectrum : similar single segment when mode is 'magnitude'.
angle_spectrum : similar to single segment when mode is 'angle'.
phase_spectrum : similar to single segment when mode is 'phase'.
Notes
-----
detrend and scale_by_freq only apply when *mode* is set to 'psd'.
N<><4E>r?zQOnly one segment is calculated since parameter NFFT (=%d) >= signal length (=%d).) rr.rLrMrNrr:rOrPrQrRrA)r<00>cbookZ_warn_externalrVrW) rrLrMrrr:rOrPrQrRrXrTrUrrr<00>specgram<61>s C 
rdzwCoherence is calculated by averaging over *NFFT*
length segments. Your signal is too short for your choice of *NFFT*.
r?r rc
 Cs<>t|<00>d|krtt<02><01>t||||||||| <09> \}
} t||||||||| <09> \} } t|||||||||| <09>
\} } t<05>| <0A>d|
| }|| fS)aH
The coherence between *x* and *y*. Coherence is the normalized
cross spectral density:
.. math::
C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}
Parameters
----------
x, y
Array or sequence containing the data
%(Spectral)s
%(PSD)s
noverlap : integer
The number of points of overlap between blocks. The default value
is 0 (no overlap).
Returns
-------
The return value is the tuple (*Cxy*, *f*), where *f* are the
frequencies of the coherence vector. For cohere, scaling the
individual densities by the sampling frequency has no effect,
since the factors cancel out.
See Also
--------
:func:`psd`, :func:`csd` :
For information about the methods used to compute :math:`P_{xy}`,
:math:`P_{xx}` and :math:`P_{yy}`.
r )rr<00>
_coh_errorr@r[rrH)rr.rLrMrrr:rOrPrQr\<00>fZPyyr]ZCxyrrr<00>cohere,s&


rg<00>#<23>,<2C>Fc s<><00>dkrt<00><00><01> dkri<00> ddl} ddl} t<03>|<00><01>t|<04>}Gdd<04>d<04>}|dkrZ|<0E><05><01>tj<07>|d<06>}<0F><05>fdd<08>}||<0F><00><08> fd d
<EFBFBD><08><07>fd d <0C><08>d d<0E><00>
| jj <09><02><02><03>fdd<10><08> <0C><12> | <0A>ddd<11><03><02> <0C>t
t j <0C><02> <0A>t d<12><02><0E>td<13><02><0F><12>
d<01><02>
<EFBFBD><02><03>fdd<15><08> <0B><12> | <0A>ddd<11><03><02> <0B>
<EFBFBD> <0B> <0C> <0A><0E>fdd<17><08>dddd<1B>}<11><00><01><06>
<EFBFBD><10>fdd<1D>}<12>dk}|<13>r^x<|D]4}t|<14><01>r<>|dk <09>r<>|d<00>|<01><01>r<><72>qf|}P<00>qfWtd<1E><01><04><04>d<1F>g<00>t<00>}x<>t|<15>D]<5D>\}}|<18><14><00><15><00>dd <20>}d<13><17>fd!d"<22>|D<00><01>}t|<18><01>s
d#|}|<11>||<18>}|<16>|d<02>}|dk<04>r@<40><10>|d$|<00>n
<EFBFBD><10>|<18>|d||<<00>q<>Wn t<1A>t<05><02>r~d%d"<22><00><10>d&<26>D<00><01>|||<01>}|dk<08>r<>td'<27><01><01><05>d<02>tj<07>|d<06>}||<0F>|<13>r<>x8t|<0F>}t|<14><01>r<>|dk <09>r<>|d<00>|<01><01>r<><72>q<>P<00>q<>Wg}g}x<>t|<0F>D]<5D>\}}t|<14><01>s"<22>q |dk <09>r@|d<00>|<01><01>r@<40>q |<14>dgt|<1A>t|<14><00>|<1B>d(d"<22>t |<1A>|<14>D<00><01>|<1C><19>fd)d"<22>t <20>|<14>D<00><01><00>q W<00><05>!<21>t|<1B><01>s<>dS| <09>r<>t <0B>"|<1C><01>r<>t j#j$j%|<1B>|d*<2A>}nt j&j%|<1B>d+<2B>}|S),a.
Load data from comma/space/tab delimited file in *fname* into a
numpy record array and return the record array.
If *names* is *None*, a header row is required to automatically
assign the recarray names. The headers will be lower cased,
spaces will be converted to underscores, and illegal attribute
name characters removed. If *names* is not *None*, it is a
sequence of names to use for the column names. In this case, it
is assumed there is no header row.
- *fname*: can be a filename or a file handle. Support for gzipped
files is automatic, if the filename ends in '.gz'
- *comments*: the character used to indicate the start of a comment
in the file, or *None* to switch off the removal of comments
- *skiprows*: is the number of rows from the top to skip
- *checkrows*: is the number of rows to check to validate the column
data type. When set to zero all rows are validated.
- *converterd*: if not *None*, is a dictionary mapping column number or
munged column name to a converter function.
- *names*: if not None, is a list of header names. In this case, no
header will be read from the file
- *missingd* is a dictionary mapping munged column names to field values
which signify that the field does not contain actual data and should
be masked, e.g., '0000-00-00' or 'unused'
- *missing*: a string whose value signals a missing field regardless of
the column it appears in
- *use_mrecords*: if True, return an mrecords.fromrecords record array if
any of the data are missing
- *dayfirst*: default is False so that MM-DD-YY has precedence over
DD-MM-YY. See
http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
for further information.
- *yearfirst*: default is False so that MM-DD-YY has precedence over
YY-MM-DD. See
http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
for further information.
If no rows are found, *None* is returned
Nrc@s@eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dS)z_csv2rec.<locals>.FHaC
For space-delimited files, we want different behavior than
comma or tab. Generally, we want multiple spaces to be
treated as a single separator, whereas with comma and tab we
want multiple commas to return multiple (empty) fields. The
join/strip trick below effects this.
cSs
||_dS)N)<01>fh)<02>selfrkrrr<00>__init__<5F>sz_csv2rec.<locals>.FH.__init__cSs|j<00><01>dS)N)rk<00>close)rlrrrrn<00>sz_csv2rec.<locals>.FH.closecSs|j<00>|<01>dS)N)rk<00>seek)rl<00>argrrrro<00>sz_csv2rec.<locals>.FH.seekcSsd<01>|<01><01><00>S)N<> )<02>join<69>split)rl<00>srrr<00>fix<69>sz_csv2rec.<locals>.FH.fixcSs|<00>t|j<02><01>S)N)ru<00>nextrk)rlrrr<00>__next__<5F>sz_csv2rec.<locals>.FH.__next__css x|jD]}|<00>|<01>VqWdS)N)rkru)rl<00>linerrr<00>__iter__<5F>s z_csv2rec.<locals>.FH.__iter__N)
<EFBFBD>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rmrnrorurwryrrrr<00>FH<46>sr~rq)<01> delimitercs0<00>r(x"t|<00>D]\}}|<01>dkrPqW<00>|fS)Nr
)<01> enumerate)<03>reader<65>i<>row)rk<00>skiprowsrr<00>process_skiprows<77>s
 z"_csv2rec.<locals>.process_skiprowscs|<01>kp|<01><01>|<00>kp|dkS)z.Should the value val in column name be masked?rj)<01>get)<02>name<6D>val)<02>missing<6E>missingdrr<00> ismissing<6E>sz_csv2rec.<locals>.ismissingcs<00><00><01>fdd<02>}|S)Ncs<00>||<01>r<0E>S<00>|<01>SdS)Nr)r<>r<>)r<00>funcr<63>rr<00>newfunc<6E>s
z5_csv2rec.<locals>.with_default_value.<locals>.newfuncr)r<>rr<>)r<>)rr<>r<00>with_default_value<75>sz$_csv2rec.<locals>.with_default_valuecSs$|dkr dS|dkrdStd<05><01>dS)N<>TrueT<65>FalseFz invalid bool)r)rrrr<00>mybool<6F>s
z_csv2rec.<locals>.myboolcs<00>|<00><01>d<01>}|S)N)<02>dayfirst<73> yearfirstr)r<00>d)<03>
dateparserr<EFBFBD>r<>rr<00> mydateparser<65>sz_csv2rec.<locals>.mydateparserr
r2rjcs<<00>|<00><01>d<01>}|jdks,|jdks,|jdkr4td<03><01>|<01><04>S)N)r<>r<>rz
not a date)<05>hour<75>minute<74>secondr<00>date)rr<>)r<>r<>r<>rr<00>mydate<74>sz_csv2rec.<locals>.mydatec s`<00><00><04><03><01><02>g}xB||<03>|<02>d<00>D],}y|||<01>Wntk
rLw$YnX|SWtd<01><01>dS)Nz,Could not find a working conversion function)<03>index<65> Exceptionr)r<><00>itemr<6D><00>funcs)r<>r<>r<><00>myfloat<61>myint<6E>mystrrr<00>get_func<6E>sz_csv2rec.<locals>.get_funcZreturn_<6E>file_<65>print_)<03>return<72>file<6C>printc s<>d}d}x<>|D]<5D>}t|<04>r2|dk r2|d<00>|<01>r2q|dkrH<72>gt|<04>}<02>rV|<03>krVP|d7}xvtt<03>|<04><02>D]d\}\}}<07><01>|<05>}|dkr<><72><01>|<06>}|dkr<>||}t|<07><05><00>|||<08>}n
<EFBFBD>|d<00>}|||<qnWqW|S)Nrr
)r<00>
startswithr<EFBFBD><00>zipr<70><00>strip) r<><00>comments<74>
convertersr<EFBFBD>r<><00>jr<6A>r<>r<>)<06> checkrows<77>
converterdr<EFBFBD>r<><00>namesr<73>rr<00>get_converters s,
 

 
z _csv2rec.<locals>.get_convertersz~!@#$%^&*()-=+~\|}[]{';: /?.>,<<3C>"rYcsg|]}|<01>kr|<01>qSrr)<02>.0<EFBFBD>c)<01>deleterr<00>
<listcomp>8sz_csv2rec.<locals>.<listcomp>zcolumn%dz_%dcSsg|] }|<01><00><00>qSr)r<>)r<>r9rrrr<>Fsriz)Could not find any valid data in CSV filecSsg|]\}}}|||<03><02>qSrr)r<>r<>r<>r<>rrrr<>fscsg|]\}}<02>||<02><02>qSrr)r<>r<>r<>)r<>rrr<>hs)r<><00>mask)r<>)'<27>dictZdateutil.parser<65>datetimercZ to_filehandler#<00>csvr<76><00>parser<65>parser,r<00>nanr5r<>rr<><00>set<65>addr<64>r<><00>lower<65>replacerrr<><00>appendr"rsrrorv<00>extendr<64>rn<00>any<6E>maZmrecordsZ fromrecordsZrec)<1E>fnamer<65>r<>r<>rr<>r<>r<>r<>Z use_mrecordsr<73>r<>Zdateutilr<6C>r~r<>r<>Zitemdr<64>Z
needheaderr<EFBFBD><00>headers<72>seenr<6E>r<>Zcntr<74>ZrowsZrowmasks<6B>rr)r<>r<>r<>r<>r<>rkr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<00>_csv2rec^s<>7
  


 


  

 





r<>c@s:eZdZdZd dd<04>Zdd<06>Zdd<08>ZeZd d
<EFBFBD>ZeZ dS) <0C> GaussianKDEa<45>
Representation of a kernel-density estimate using Gaussian kernels.
Parameters
----------
dataset : array_like
Datapoints to estimate from. In case of univariate data this is a 1-D
array, otherwise a 2-D array with shape (# of dims, # of data).
bw_method : str, scalar or callable, optional
The method used to calculate the estimator bandwidth. This can be
'scott', 'silverman', a scalar constant or a callable. If a
scalar, this will be used directly as `kde.factor`. If a
callable, it should take a `GaussianKDE` instance as only
parameter and return a scalar. If None (default), 'scott' is used.
Attributes
----------
dataset : ndarray
The dataset with which `gaussian_kde` was initialized.
dim : int
Number of dimensions.
num_dp : int
Number of datapoints.
factor : float
The bandwidth factor, obtained from `kde.covariance_factor`, with which
the covariance matrix is multiplied.
covariance : ndarray
The covariance matrix of `dataset`, scaled by the calculated bandwidth
(`kde.factor`).
inv_cov : ndarray
The inverse of `covariance`.
Methods
-------
kde.evaluate(points) : ndarray
Evaluate the estimated pdf on a provided set of points.
kde(points) : ndarray
Same as kde.evaluate(points)
NcsTt<00>|<01><01>_t<00><03>j<02>jdks&td<02><01>t<00><03>j<02>j\<02>_<07>_t <09>t
<EFBFBD>}<03>dkrPnv|rf<72>dkrf<72>j <0B>_ n`|r|<7C>dkr|<7C>j <0A>_ nJt<00><0E><00>r<>|s<>d<05>_<0F>fdd<07><08>_ n&t<10><00>r<><72><00>_<0F>fdd<07><08>_ ntd <09><01><01><01> <0C><00>_t<12>d
<EFBFBD><02>st<00>tj<13>jdd d <0C><03><01>_tj<15><16>j<14><01>_<17>j<14>jd <00>_<18>j<17>jd <00>_t<00>tj<15>d tj<00>j<00><01><01>j<00>_dS)Nr
z.`dataset` input should have multiple elements.ZscottZ silvermanz use constantcs<00>S)Nrr)<01> bw_methodrr<00><lambda><3E><00>z&GaussianKDE.__init__.<locals>.<lambda>cs
<00><00><00><00>S)N)<01>
_bw_methodr)rlrrr<><00>r<>zB`bw_method` should be 'scott', 'silverman', a scalar or a callableZ _data_inv_covF)Zrowvarr(r )rr=<00>datasetr)r+rr<00>dim<69>num_dpr"r#<00> scotts_factor<6F>covariance_factor<6F>silverman_factorZisscalarr<72>r$Zfactor<6F>hasattrr-Zdata_covarianceZlinalg<6C>invZ data_inv_covZ
covariance<EFBFBD>inv_cov<6F>sqrtZdet<65>pi<70> norm_factor)rlr<>r<>ZisStringr)r<>rlrrm<00>s> 
 
 

  zGaussianKDE.__init__cCst<00>|jd|jd<00>S)Ng<00><><EFBFBD>)r<00>powerr<72>r<>)rlrrrr<><00>szGaussianKDE.scotts_factorcCs&t<00>|j|jddd|jd<00>S)Ng@g@g<00><>r<EFBFBD>)rr<>r<>r<>)rlrrrr<><00>szGaussianKDE.silverman_factorc Cs&t<00>|<01>}t<00>|<01>j\}}||jkr6td<01>||j<04><02><01>t<00>|<03>}||jkr<>x<EFBFBD>t |j<08>D]R}|j
dd<02>|tj f|}t<00> |j |<06>}tj||dd<04>d}|t<00>| <00>}qVWnjxht |<03>D]\}|j
|dd<02>|tj f}t<00> |j |<06>}tj||dd<04>d}tjt<00>| <00>dd<04>||<q<>W||j}|S)aEvaluate the estimated pdf on a set of points.
Parameters
----------
points : (# of dimensions, # of points)-array
Alternatively, a (# of dimensions,) vector can be passed in and
treated as a single point.
Returns
-------
values : (# of points,)-array
The values at each point.
Raises
------
ValueError : if the dimensionality of the input points is different
than the dimensionality of the KDE.
z2points have dimension {}, dataset has dimension {}Nr)r g@)rr=r)rr<>r<00>format<61>zerosr<73><00>ranger<65>r4<00>dotr<74>rI<00>expr<70>) rlZpointsr<73>Znum_mrSr<>ZdiffZtdiffZenergyrrr<00>evaluate<74>s&

 


zGaussianKDE.evaluate)N)
rzr{r|r}rmr<>r<>r<>r<><00>__call__rrrrr<>vs/
+0r<30>)rN)NN)r)N)N)Nr)r)
NNNNNNNNNN)NNNN)NNNNNNNN)NNNNNNNN)NNNN)NNNN)NNNN)NNNN) NNNNNNNNN) rhrrriNNrjNFFF)&r}r<><00>inspectZnumpyrZmatplotlib.cbookrcZ
matplotlibrrr rr<00>
deprecatedr'rr!r r<rrVrZZinterpd<70>update<74>cleandocZdedent_interpdr@r[r^r_r`rardrergr<><00>objectr<74>rrrr<00><module>6sx   
8
:  

&
D
7





 7 > & ( & & X0