partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | aic_eigen | r"""AIC order-selection using eigen values
:param s: a list of `p` sorted eigen values
:param N: the size of the input data. To be defined precisely.
:return:
* an array containing the AIC values
Given :math:`n` sorted eigen values :math:`\lambda_i` with
:math:`0 <= i < n`, the proposed c... | src/spectrum/criteria.py | def aic_eigen(s, N):
r"""AIC order-selection using eigen values
:param s: a list of `p` sorted eigen values
:param N: the size of the input data. To be defined precisely.
:return:
* an array containing the AIC values
Given :math:`n` sorted eigen values :math:`\lambda_i` with
:math:`0 ... | def aic_eigen(s, N):
r"""AIC order-selection using eigen values
:param s: a list of `p` sorted eigen values
:param N: the size of the input data. To be defined precisely.
:return:
* an array containing the AIC values
Given :math:`n` sorted eigen values :math:`\lambda_i` with
:math:`0 ... | [
"r",
"AIC",
"order",
"-",
"selection",
"using",
"eigen",
"values"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/criteria.py#L265-L310 | [
"def",
"aic_eigen",
"(",
"s",
",",
"N",
")",
":",
"import",
"numpy",
"as",
"np",
"kaic",
"=",
"[",
"]",
"n",
"=",
"len",
"(",
"s",
")",
"for",
"k",
"in",
"range",
"(",
"0",
",",
"n",
"-",
"1",
")",
":",
"ak",
"=",
"1.",
"/",
"(",
"n",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | mdl_eigen | r"""MDL order-selection using eigen values
:param s: a list of `p` sorted eigen values
:param N: the size of the input data. To be defined precisely.
:return:
* an array containing the AIC values
.. math:: MDL(k) = (n-k)N \ln \frac{g(k)}{a(k)} + 0.5k(2n-k) log(N)
.. seealso:: :func:`aic_... | src/spectrum/criteria.py | def mdl_eigen(s, N):
r"""MDL order-selection using eigen values
:param s: a list of `p` sorted eigen values
:param N: the size of the input data. To be defined precisely.
:return:
* an array containing the AIC values
.. math:: MDL(k) = (n-k)N \ln \frac{g(k)}{a(k)} + 0.5k(2n-k) log(N)
... | def mdl_eigen(s, N):
r"""MDL order-selection using eigen values
:param s: a list of `p` sorted eigen values
:param N: the size of the input data. To be defined precisely.
:return:
* an array containing the AIC values
.. math:: MDL(k) = (n-k)N \ln \frac{g(k)}{a(k)} + 0.5k(2n-k) log(N)
... | [
"r",
"MDL",
"order",
"-",
"selection",
"using",
"eigen",
"values"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/criteria.py#L313-L337 | [
"def",
"mdl_eigen",
"(",
"s",
",",
"N",
")",
":",
"import",
"numpy",
"as",
"np",
"kmdl",
"=",
"[",
"]",
"n",
"=",
"len",
"(",
"s",
")",
"for",
"k",
"in",
"range",
"(",
"0",
",",
"n",
"-",
"1",
")",
":",
"ak",
"=",
"1.",
"/",
"(",
"n",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | generate_gallery_rst | Generate the Main examples gallery reStructuredText
Start the sphinx-gallery configuration and recursively scan the examples
directories in order to populate the examples gallery | doc/sphinxext/sphinx_gallery/gen_gallery.py | def generate_gallery_rst(app):
"""Generate the Main examples gallery reStructuredText
Start the sphinx-gallery configuration and recursively scan the examples
directories in order to populate the examples gallery
"""
try:
plot_gallery = eval(app.builder.config.plot_gallery)
except TypeE... | def generate_gallery_rst(app):
"""Generate the Main examples gallery reStructuredText
Start the sphinx-gallery configuration and recursively scan the examples
directories in order to populate the examples gallery
"""
try:
plot_gallery = eval(app.builder.config.plot_gallery)
except TypeE... | [
"Generate",
"the",
"Main",
"examples",
"gallery",
"reStructuredText"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_gallery.py#L45-L101 | [
"def",
"generate_gallery_rst",
"(",
"app",
")",
":",
"try",
":",
"plot_gallery",
"=",
"eval",
"(",
"app",
".",
"builder",
".",
"config",
".",
"plot_gallery",
")",
"except",
"TypeError",
":",
"plot_gallery",
"=",
"bool",
"(",
"app",
".",
"builder",
".",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | setup | Setup sphinx-gallery sphinx extension | doc/sphinxext/sphinx_gallery/gen_gallery.py | def setup(app):
"""Setup sphinx-gallery sphinx extension"""
app.add_config_value('plot_gallery', True, 'html')
app.add_config_value('abort_on_example_error', False, 'html')
app.add_config_value('sphinx_gallery_conf', gallery_conf, 'html')
app.add_stylesheet('gallery.css')
app.connect('builder-i... | def setup(app):
"""Setup sphinx-gallery sphinx extension"""
app.add_config_value('plot_gallery', True, 'html')
app.add_config_value('abort_on_example_error', False, 'html')
app.add_config_value('sphinx_gallery_conf', gallery_conf, 'html')
app.add_stylesheet('gallery.css')
app.connect('builder-i... | [
"Setup",
"sphinx",
"-",
"gallery",
"sphinx",
"extension"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_gallery.py#L114-L123 | [
"def",
"setup",
"(",
"app",
")",
":",
"app",
".",
"add_config_value",
"(",
"'plot_gallery'",
",",
"True",
",",
"'html'",
")",
"app",
".",
"add_config_value",
"(",
"'abort_on_example_error'",
",",
"False",
",",
"'html'",
")",
"app",
".",
"add_config_value",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | CORRELATION | r"""Correlation function
This function should give the same results as :func:`xcorr` but it
returns the positive lags only. Moreover the algorithm does not use
FFT as compared to other algorithms.
:param array x: first data array of length N
:param array y: second data array of length N. If not sp... | src/spectrum/correlation.py | def CORRELATION(x, y=None, maxlags=None, norm='unbiased'):
r"""Correlation function
This function should give the same results as :func:`xcorr` but it
returns the positive lags only. Moreover the algorithm does not use
FFT as compared to other algorithms.
:param array x: first data array of length... | def CORRELATION(x, y=None, maxlags=None, norm='unbiased'):
r"""Correlation function
This function should give the same results as :func:`xcorr` but it
returns the positive lags only. Moreover the algorithm does not use
FFT as compared to other algorithms.
:param array x: first data array of length... | [
"r",
"Correlation",
"function"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/correlation.py#L37-L148 | [
"def",
"CORRELATION",
"(",
"x",
",",
"y",
"=",
"None",
",",
"maxlags",
"=",
"None",
",",
"norm",
"=",
"'unbiased'",
")",
":",
"assert",
"norm",
"in",
"[",
"'unbiased'",
",",
"'biased'",
",",
"'coeff'",
",",
"None",
"]",
"#transform lag into list if it is a... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | xcorr | Cross-correlation using numpy.correlate
Estimates the cross-correlation (and autocorrelation) sequence of a random
process of length N. By default, there is no normalisation and the output
sequence of the cross-correlation has a length 2*N+1.
:param array x: first data array of length N
:param arr... | src/spectrum/correlation.py | def xcorr(x, y=None, maxlags=None, norm='biased'):
"""Cross-correlation using numpy.correlate
Estimates the cross-correlation (and autocorrelation) sequence of a random
process of length N. By default, there is no normalisation and the output
sequence of the cross-correlation has a length 2*N+1.
:... | def xcorr(x, y=None, maxlags=None, norm='biased'):
"""Cross-correlation using numpy.correlate
Estimates the cross-correlation (and autocorrelation) sequence of a random
process of length N. By default, there is no normalisation and the output
sequence of the cross-correlation has a length 2*N+1.
:... | [
"Cross",
"-",
"correlation",
"using",
"numpy",
".",
"correlate"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/correlation.py#L151-L226 | [
"def",
"xcorr",
"(",
"x",
",",
"y",
"=",
"None",
",",
"maxlags",
"=",
"None",
",",
"norm",
"=",
"'biased'",
")",
":",
"N",
"=",
"len",
"(",
"x",
")",
"if",
"y",
"is",
"None",
":",
"y",
"=",
"x",
"assert",
"len",
"(",
"x",
")",
"==",
"len",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | MINEIGVAL | Finds the minimum eigenvalue of a Hermitian Toeplitz matrix
The classical power method is used together with a fast Toeplitz
equation solution routine. The eigenvector is normalized to unit length.
:param T0: Scalar corresponding to real matrix element t(0)
:param T: Array of M complex matrix ele... | src/spectrum/eigen.py | def MINEIGVAL(T0, T, TOL):
"""Finds the minimum eigenvalue of a Hermitian Toeplitz matrix
The classical power method is used together with a fast Toeplitz
equation solution routine. The eigenvector is normalized to unit length.
:param T0: Scalar corresponding to real matrix element t(0)
:param ... | def MINEIGVAL(T0, T, TOL):
"""Finds the minimum eigenvalue of a Hermitian Toeplitz matrix
The classical power method is used together with a fast Toeplitz
equation solution routine. The eigenvector is normalized to unit length.
:param T0: Scalar corresponding to real matrix element t(0)
:param ... | [
"Finds",
"the",
"minimum",
"eigenvalue",
"of",
"a",
"Hermitian",
"Toeplitz",
"matrix"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/eigen.py#L7-L57 | [
"def",
"MINEIGVAL",
"(",
"T0",
",",
"T",
",",
"TOL",
")",
":",
"M",
"=",
"len",
"(",
"T",
")",
"eigval",
"=",
"10",
"eigvalold",
"=",
"1",
"eigvec",
"=",
"numpy",
".",
"zeros",
"(",
"M",
"+",
"1",
",",
"dtype",
"=",
"complex",
")",
"for",
"k"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | morlet | r"""Generate the Morlet waveform
The Morlet waveform is defined as follows:
.. math:: w[x] = \cos{5x} \exp^{-x^2/2}
:param lb: lower bound
:param ub: upper bound
:param int n: waveform data samples
.. plot::
:include-source:
:width: 80%
from spectrum import morlet... | src/spectrum/waveform.py | def morlet(lb, ub, n):
r"""Generate the Morlet waveform
The Morlet waveform is defined as follows:
.. math:: w[x] = \cos{5x} \exp^{-x^2/2}
:param lb: lower bound
:param ub: upper bound
:param int n: waveform data samples
.. plot::
:include-source:
:width: 80%
... | def morlet(lb, ub, n):
r"""Generate the Morlet waveform
The Morlet waveform is defined as follows:
.. math:: w[x] = \cos{5x} \exp^{-x^2/2}
:param lb: lower bound
:param ub: upper bound
:param int n: waveform data samples
.. plot::
:include-source:
:width: 80%
... | [
"r",
"Generate",
"the",
"Morlet",
"waveform"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/waveform.py#L7-L34 | [
"def",
"morlet",
"(",
"lb",
",",
"ub",
",",
"n",
")",
":",
"if",
"n",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"n must be strictly positive\"",
")",
"x",
"=",
"numpy",
".",
"linspace",
"(",
"lb",
",",
"ub",
",",
"n",
")",
"psi",
"=",
"numpy",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | chirp | r"""Evaluate a chirp signal at time t.
A chirp signal is a frequency swept cosine wave.
.. math:: a = \pi (f_1 - f_0) / t_1
.. math:: b = 2 \pi f_0
.. math:: y = \cos\left( \pi\frac{f_1-f_0}{t_1} t^2 + 2\pi f_0 t + \rm{phase} \right)
:param array t: times at which to evaluate the chirp signal... | src/spectrum/waveform.py | def chirp(t, f0=0., t1=1., f1=100., form='linear', phase=0):
r"""Evaluate a chirp signal at time t.
A chirp signal is a frequency swept cosine wave.
.. math:: a = \pi (f_1 - f_0) / t_1
.. math:: b = 2 \pi f_0
.. math:: y = \cos\left( \pi\frac{f_1-f_0}{t_1} t^2 + 2\pi f_0 t + \rm{phase} \right)... | def chirp(t, f0=0., t1=1., f1=100., form='linear', phase=0):
r"""Evaluate a chirp signal at time t.
A chirp signal is a frequency swept cosine wave.
.. math:: a = \pi (f_1 - f_0) / t_1
.. math:: b = 2 \pi f_0
.. math:: y = \cos\left( \pi\frac{f_1-f_0}{t_1} t^2 + 2\pi f_0 t + \rm{phase} \right)... | [
"r",
"Evaluate",
"a",
"chirp",
"signal",
"at",
"time",
"t",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/waveform.py#L37-L94 | [
"def",
"chirp",
"(",
"t",
",",
"f0",
"=",
"0.",
",",
"t1",
"=",
"1.",
",",
"f1",
"=",
"100.",
",",
"form",
"=",
"'linear'",
",",
"phase",
"=",
"0",
")",
":",
"valid_forms",
"=",
"[",
"'linear'",
",",
"'quadratic'",
",",
"'logarithmic'",
"]",
"if"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | mexican | r"""Generate the mexican hat wavelet
The Mexican wavelet is:
.. math:: w[x] = \cos{5x} \exp^{-x^2/2}
:param lb: lower bound
:param ub: upper bound
:param int n: waveform data samples
:return: the waveform
.. plot::
:include-source:
:width: 80%
from spectrum impo... | src/spectrum/waveform.py | def mexican(lb, ub, n):
r"""Generate the mexican hat wavelet
The Mexican wavelet is:
.. math:: w[x] = \cos{5x} \exp^{-x^2/2}
:param lb: lower bound
:param ub: upper bound
:param int n: waveform data samples
:return: the waveform
.. plot::
:include-source:
:width: 80%... | def mexican(lb, ub, n):
r"""Generate the mexican hat wavelet
The Mexican wavelet is:
.. math:: w[x] = \cos{5x} \exp^{-x^2/2}
:param lb: lower bound
:param ub: upper bound
:param int n: waveform data samples
:return: the waveform
.. plot::
:include-source:
:width: 80%... | [
"r",
"Generate",
"the",
"mexican",
"hat",
"wavelet"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/waveform.py#L97-L123 | [
"def",
"mexican",
"(",
"lb",
",",
"ub",
",",
"n",
")",
":",
"if",
"n",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"n must be strictly positive\"",
")",
"x",
"=",
"numpy",
".",
"linspace",
"(",
"lb",
",",
"ub",
",",
"n",
")",
"psi",
"=",
"(",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | ac2poly | Convert autocorrelation sequence to prediction polynomial
:param array data: input data (list or numpy.array)
:return:
* AR parameters
* noise variance
This is an alias to::
a, e, c = LEVINSON(data)
:Example:
.. doctest::
>>> from spectrum import ac2poly
... | src/spectrum/linear_prediction.py | def ac2poly(data):
"""Convert autocorrelation sequence to prediction polynomial
:param array data: input data (list or numpy.array)
:return:
* AR parameters
* noise variance
This is an alias to::
a, e, c = LEVINSON(data)
:Example:
.. doctest::
>>> from sp... | def ac2poly(data):
"""Convert autocorrelation sequence to prediction polynomial
:param array data: input data (list or numpy.array)
:return:
* AR parameters
* noise variance
This is an alias to::
a, e, c = LEVINSON(data)
:Example:
.. doctest::
>>> from sp... | [
"Convert",
"autocorrelation",
"sequence",
"to",
"prediction",
"polynomial"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L19-L47 | [
"def",
"ac2poly",
"(",
"data",
")",
":",
"a",
",",
"e",
",",
"_c",
"=",
"LEVINSON",
"(",
"data",
")",
"a",
"=",
"numpy",
".",
"insert",
"(",
"a",
",",
"0",
",",
"1",
")",
"return",
"a",
",",
"e"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | rc2poly | convert reflection coefficients to prediction filter polynomial
:param k: reflection coefficients | src/spectrum/linear_prediction.py | def rc2poly(kr, r0=None):
"""convert reflection coefficients to prediction filter polynomial
:param k: reflection coefficients
"""
# Initialize the recursion
from .levinson import levup
p = len(kr) #% p is the order of the prediction polynomial.
a = numpy.array([1, kr[0]]) ... | def rc2poly(kr, r0=None):
"""convert reflection coefficients to prediction filter polynomial
:param k: reflection coefficients
"""
# Initialize the recursion
from .levinson import levup
p = len(kr) #% p is the order of the prediction polynomial.
a = numpy.array([1, kr[0]]) ... | [
"convert",
"reflection",
"coefficients",
"to",
"prediction",
"filter",
"polynomial"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L102-L131 | [
"def",
"rc2poly",
"(",
"kr",
",",
"r0",
"=",
"None",
")",
":",
"# Initialize the recursion",
"from",
".",
"levinson",
"import",
"levup",
"p",
"=",
"len",
"(",
"kr",
")",
"#% p is the order of the prediction polynomial.",
"a",
"=",
"numpy",
".",
"array",
"(",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | rc2ac | Convert reflection coefficients to autocorrelation sequence.
:param k: reflection coefficients
:param R0: zero-lag autocorrelation
:returns: the autocorrelation sequence
.. seealso:: :func:`ac2rc`, :func:`poly2rc`, :func:`ac2poly`, :func:`poly2rc`, :func:`rc2poly`. | src/spectrum/linear_prediction.py | def rc2ac(k, R0):
"""Convert reflection coefficients to autocorrelation sequence.
:param k: reflection coefficients
:param R0: zero-lag autocorrelation
:returns: the autocorrelation sequence
.. seealso:: :func:`ac2rc`, :func:`poly2rc`, :func:`ac2poly`, :func:`poly2rc`, :func:`rc2poly`.
"""
... | def rc2ac(k, R0):
"""Convert reflection coefficients to autocorrelation sequence.
:param k: reflection coefficients
:param R0: zero-lag autocorrelation
:returns: the autocorrelation sequence
.. seealso:: :func:`ac2rc`, :func:`poly2rc`, :func:`ac2poly`, :func:`poly2rc`, :func:`rc2poly`.
"""
... | [
"Convert",
"reflection",
"coefficients",
"to",
"autocorrelation",
"sequence",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L134-L146 | [
"def",
"rc2ac",
"(",
"k",
",",
"R0",
")",
":",
"[",
"a",
",",
"efinal",
"]",
"=",
"rc2poly",
"(",
"k",
",",
"R0",
")",
"R",
",",
"u",
",",
"kr",
",",
"e",
"=",
"rlevinson",
"(",
"a",
",",
"efinal",
")",
"return",
"R"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | rc2is | Convert reflection coefficients to inverse sine parameters.
:param k: reflection coefficients
:return: inverse sine parameters
.. seealso:: :func:`is2rc`, :func:`rc2poly`, :func:`rc2acC`, :func:`rc2lar`.
Reference: J.R. Deller, J.G. Proakis, J.H.L. Hansen, "Discrete-Time
Processing of Speech S... | src/spectrum/linear_prediction.py | def rc2is(k):
"""Convert reflection coefficients to inverse sine parameters.
:param k: reflection coefficients
:return: inverse sine parameters
.. seealso:: :func:`is2rc`, :func:`rc2poly`, :func:`rc2acC`, :func:`rc2lar`.
Reference: J.R. Deller, J.G. Proakis, J.H.L. Hansen, "Discrete-Time
P... | def rc2is(k):
"""Convert reflection coefficients to inverse sine parameters.
:param k: reflection coefficients
:return: inverse sine parameters
.. seealso:: :func:`is2rc`, :func:`rc2poly`, :func:`rc2acC`, :func:`rc2lar`.
Reference: J.R. Deller, J.G. Proakis, J.H.L. Hansen, "Discrete-Time
P... | [
"Convert",
"reflection",
"coefficients",
"to",
"inverse",
"sine",
"parameters",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L164-L180 | [
"def",
"rc2is",
"(",
"k",
")",
":",
"assert",
"numpy",
".",
"isrealobj",
"(",
"k",
")",
",",
"'Inverse sine parameters not defined for complex reflection coefficients.'",
"if",
"max",
"(",
"numpy",
".",
"abs",
"(",
"k",
")",
")",
">=",
"1",
":",
"raise",
"Va... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | rc2lar | Convert reflection coefficients to log area ratios.
:param k: reflection coefficients
:return: inverse sine parameters
The log area ratio is defined by G = log((1+k)/(1-k)) , where the K
parameter is the reflection coefficient.
.. seealso:: :func:`lar2rc`, :func:`rc2poly`, :func:`rc2ac`, :func:`r... | src/spectrum/linear_prediction.py | def rc2lar(k):
"""Convert reflection coefficients to log area ratios.
:param k: reflection coefficients
:return: inverse sine parameters
The log area ratio is defined by G = log((1+k)/(1-k)) , where the K
parameter is the reflection coefficient.
.. seealso:: :func:`lar2rc`, :func:`rc2poly`, :... | def rc2lar(k):
"""Convert reflection coefficients to log area ratios.
:param k: reflection coefficients
:return: inverse sine parameters
The log area ratio is defined by G = log((1+k)/(1-k)) , where the K
parameter is the reflection coefficient.
.. seealso:: :func:`lar2rc`, :func:`rc2poly`, :... | [
"Convert",
"reflection",
"coefficients",
"to",
"log",
"area",
"ratios",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L182-L202 | [
"def",
"rc2lar",
"(",
"k",
")",
":",
"assert",
"numpy",
".",
"isrealobj",
"(",
"k",
")",
",",
"'Log area ratios not defined for complex reflection coefficients.'",
"if",
"max",
"(",
"numpy",
".",
"abs",
"(",
"k",
")",
")",
">=",
"1",
":",
"raise",
"ValueErro... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | lar2rc | Convert log area ratios to reflection coefficients.
:param g: log area ratios
:returns: the reflection coefficients
.. seealso: :func:`rc2lar`, :func:`poly2rc`, :func:`ac2rc`, :func:`is2rc`.
:References:
[1] J. Makhoul, "Linear Prediction: A Tutorial Review," Proc. IEEE, Vol.63, No.4, pp.561... | src/spectrum/linear_prediction.py | def lar2rc(g):
"""Convert log area ratios to reflection coefficients.
:param g: log area ratios
:returns: the reflection coefficients
.. seealso: :func:`rc2lar`, :func:`poly2rc`, :func:`ac2rc`, :func:`is2rc`.
:References:
[1] J. Makhoul, "Linear Prediction: A Tutorial Review," Proc. IEEE,... | def lar2rc(g):
"""Convert log area ratios to reflection coefficients.
:param g: log area ratios
:returns: the reflection coefficients
.. seealso: :func:`rc2lar`, :func:`poly2rc`, :func:`ac2rc`, :func:`is2rc`.
:References:
[1] J. Makhoul, "Linear Prediction: A Tutorial Review," Proc. IEEE,... | [
"Convert",
"log",
"area",
"ratios",
"to",
"reflection",
"coefficients",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L206-L220 | [
"def",
"lar2rc",
"(",
"g",
")",
":",
"assert",
"numpy",
".",
"isrealobj",
"(",
"g",
")",
",",
"'Log area ratios not defined for complex reflection coefficients.'",
"# Use the relation, tanh(x) = (1-exp(2x))/(1+exp(2x))",
"return",
"-",
"numpy",
".",
"tanh",
"(",
"-",
"n... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | lsf2poly | Convert line spectral frequencies to prediction filter coefficients
returns a vector a containing the prediction filter coefficients from a vector lsf of line spectral frequencies.
.. doctest::
>>> from spectrum import lsf2poly
>>> lsf = [0.7842 , 1.5605 , 1.8776 , 1.8984, 2.3593]
... | src/spectrum/linear_prediction.py | def lsf2poly(lsf):
"""Convert line spectral frequencies to prediction filter coefficients
returns a vector a containing the prediction filter coefficients from a vector lsf of line spectral frequencies.
.. doctest::
>>> from spectrum import lsf2poly
>>> lsf = [0.7842 , 1.5605 , 1.8776... | def lsf2poly(lsf):
"""Convert line spectral frequencies to prediction filter coefficients
returns a vector a containing the prediction filter coefficients from a vector lsf of line spectral frequencies.
.. doctest::
>>> from spectrum import lsf2poly
>>> lsf = [0.7842 , 1.5605 , 1.8776... | [
"Convert",
"line",
"spectral",
"frequencies",
"to",
"prediction",
"filter",
"coefficients"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L224-L283 | [
"def",
"lsf2poly",
"(",
"lsf",
")",
":",
"# Reference: A.M. Kondoz, \"Digital Speech: Coding for Low Bit Rate Communications",
"# Systems\" John Wiley & Sons 1994 ,Chapter 4",
"# Line spectral frequencies must be real.",
"lsf",
"=",
"numpy",
".",
"array",
"(",
"lsf",
")",
"if",... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | poly2lsf | Prediction polynomial to line spectral frequencies.
converts the prediction polynomial specified by A,
into the corresponding line spectral frequencies, LSF.
normalizes the prediction polynomial by A(1).
.. doctest::
>>> from spectrum import poly2lsf
>>> a = [1.0000, 0.6149, 0.9899, ... | src/spectrum/linear_prediction.py | def poly2lsf(a):
"""Prediction polynomial to line spectral frequencies.
converts the prediction polynomial specified by A,
into the corresponding line spectral frequencies, LSF.
normalizes the prediction polynomial by A(1).
.. doctest::
>>> from spectrum import poly2lsf
>>> a = [1... | def poly2lsf(a):
"""Prediction polynomial to line spectral frequencies.
converts the prediction polynomial specified by A,
into the corresponding line spectral frequencies, LSF.
normalizes the prediction polynomial by A(1).
.. doctest::
>>> from spectrum import poly2lsf
>>> a = [1... | [
"Prediction",
"polynomial",
"to",
"line",
"spectral",
"frequencies",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L286-L341 | [
"def",
"poly2lsf",
"(",
"a",
")",
":",
"#Line spectral frequencies are not defined for complex polynomials.",
"# Normalize the polynomial",
"a",
"=",
"numpy",
".",
"array",
"(",
"a",
")",
"if",
"a",
"[",
"0",
"]",
"!=",
"1",
":",
"a",
"/=",
"a",
"[",
"0",
"]... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _swapsides | todo is it really useful ?
Swap sides
.. doctest::
>>> from spectrum import swapsides
>>> x = [-2, -1, 1, 2]
>>> swapsides(x)
array([ 2, -2, -1]) | src/spectrum/tools.py | def _swapsides(data):
"""todo is it really useful ?
Swap sides
.. doctest::
>>> from spectrum import swapsides
>>> x = [-2, -1, 1, 2]
>>> swapsides(x)
array([ 2, -2, -1])
"""
N = len(data)
return np.concatenate((data[N//2+1:], data[0:N//2])) | def _swapsides(data):
"""todo is it really useful ?
Swap sides
.. doctest::
>>> from spectrum import swapsides
>>> x = [-2, -1, 1, 2]
>>> swapsides(x)
array([ 2, -2, -1])
"""
N = len(data)
return np.concatenate((data[N//2+1:], data[0:N//2])) | [
"todo",
"is",
"it",
"really",
"useful",
"?"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L40-L54 | [
"def",
"_swapsides",
"(",
"data",
")",
":",
"N",
"=",
"len",
"(",
"data",
")",
"return",
"np",
".",
"concatenate",
"(",
"(",
"data",
"[",
"N",
"//",
"2",
"+",
"1",
":",
"]",
",",
"data",
"[",
"0",
":",
"N",
"//",
"2",
"]",
")",
")"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | twosided_2_onesided | Convert a one-sided PSD to a twosided PSD
In order to keep the power in the onesided PSD the same
as in the twosided version, the onesided values are twice
as much as in the input data (except for the zero-lag value).
::
>>> twosided_2_onesided([10, 2,3,3,2,8])
array([ 10., 4., 6.... | src/spectrum/tools.py | def twosided_2_onesided(data):
"""Convert a one-sided PSD to a twosided PSD
In order to keep the power in the onesided PSD the same
as in the twosided version, the onesided values are twice
as much as in the input data (except for the zero-lag value).
::
>>> twosided_2_onesided([10, 2,3,3... | def twosided_2_onesided(data):
"""Convert a one-sided PSD to a twosided PSD
In order to keep the power in the onesided PSD the same
as in the twosided version, the onesided values are twice
as much as in the input data (except for the zero-lag value).
::
>>> twosided_2_onesided([10, 2,3,3... | [
"Convert",
"a",
"one",
"-",
"sided",
"PSD",
"to",
"a",
"twosided",
"PSD"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L57-L75 | [
"def",
"twosided_2_onesided",
"(",
"data",
")",
":",
"assert",
"len",
"(",
"data",
")",
"%",
"2",
"==",
"0",
"N",
"=",
"len",
"(",
"data",
")",
"psd",
"=",
"np",
".",
"array",
"(",
"data",
"[",
"0",
":",
"N",
"//",
"2",
"+",
"1",
"]",
")",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | onesided_2_twosided | Convert a two-sided PSD to a one-sided PSD
In order to keep the power in the twosided PSD the same
as in the onesided version, the twosided values are 2 times
lower than the input data (except for the zero-lag and N-lag
values).
::
>>> twosided_2_onesided([10, 4, 6, 8])
array([ 10... | src/spectrum/tools.py | def onesided_2_twosided(data):
"""Convert a two-sided PSD to a one-sided PSD
In order to keep the power in the twosided PSD the same
as in the onesided version, the twosided values are 2 times
lower than the input data (except for the zero-lag and N-lag
values).
::
>>> twosided_2_ones... | def onesided_2_twosided(data):
"""Convert a two-sided PSD to a one-sided PSD
In order to keep the power in the twosided PSD the same
as in the onesided version, the twosided values are 2 times
lower than the input data (except for the zero-lag and N-lag
values).
::
>>> twosided_2_ones... | [
"Convert",
"a",
"two",
"-",
"sided",
"PSD",
"to",
"a",
"one",
"-",
"sided",
"PSD"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L78-L95 | [
"def",
"onesided_2_twosided",
"(",
"data",
")",
":",
"psd",
"=",
"np",
".",
"concatenate",
"(",
"(",
"data",
"[",
"0",
":",
"-",
"1",
"]",
",",
"cshift",
"(",
"data",
"[",
"-",
"1",
":",
"0",
":",
"-",
"1",
"]",
",",
"-",
"1",
")",
")",
")"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | twosided_2_centerdc | Convert a two-sided PSD to a center-dc PSD | src/spectrum/tools.py | def twosided_2_centerdc(data):
"""Convert a two-sided PSD to a center-dc PSD"""
N = len(data)
# could us int() or // in python 3
newpsd = np.concatenate((cshift(data[N//2:], 1), data[0:N//2]))
newpsd[0] = data[-1]
return newpsd | def twosided_2_centerdc(data):
"""Convert a two-sided PSD to a center-dc PSD"""
N = len(data)
# could us int() or // in python 3
newpsd = np.concatenate((cshift(data[N//2:], 1), data[0:N//2]))
newpsd[0] = data[-1]
return newpsd | [
"Convert",
"a",
"two",
"-",
"sided",
"PSD",
"to",
"a",
"center",
"-",
"dc",
"PSD"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L98-L104 | [
"def",
"twosided_2_centerdc",
"(",
"data",
")",
":",
"N",
"=",
"len",
"(",
"data",
")",
"# could us int() or // in python 3",
"newpsd",
"=",
"np",
".",
"concatenate",
"(",
"(",
"cshift",
"(",
"data",
"[",
"N",
"//",
"2",
":",
"]",
",",
"1",
")",
",",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | centerdc_2_twosided | Convert a center-dc PSD to a twosided PSD | src/spectrum/tools.py | def centerdc_2_twosided(data):
"""Convert a center-dc PSD to a twosided PSD"""
N = len(data)
newpsd = np.concatenate((data[N//2:], (cshift(data[0:N//2], -1))))
return newpsd | def centerdc_2_twosided(data):
"""Convert a center-dc PSD to a twosided PSD"""
N = len(data)
newpsd = np.concatenate((data[N//2:], (cshift(data[0:N//2], -1))))
return newpsd | [
"Convert",
"a",
"center",
"-",
"dc",
"PSD",
"to",
"a",
"twosided",
"PSD"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L107-L111 | [
"def",
"centerdc_2_twosided",
"(",
"data",
")",
":",
"N",
"=",
"len",
"(",
"data",
")",
"newpsd",
"=",
"np",
".",
"concatenate",
"(",
"(",
"data",
"[",
"N",
"//",
"2",
":",
"]",
",",
"(",
"cshift",
"(",
"data",
"[",
"0",
":",
"N",
"//",
"2",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _twosided_zerolag | Build a symmetric vector out of stricly positive lag vector and zero-lag
.. doctest::
>>> data = [3,2,1]
>>> zerolag = 4
>>> twosided_zerolag(data, zerolag)
array([1, 2, 3, 4, 3, 2, 1])
.. seealso:: Same behaviour as :func:`twosided_zerolag` | src/spectrum/tools.py | def _twosided_zerolag(data, zerolag):
"""Build a symmetric vector out of stricly positive lag vector and zero-lag
.. doctest::
>>> data = [3,2,1]
>>> zerolag = 4
>>> twosided_zerolag(data, zerolag)
array([1, 2, 3, 4, 3, 2, 1])
.. seealso:: Same behaviour as :func:`twosided... | def _twosided_zerolag(data, zerolag):
"""Build a symmetric vector out of stricly positive lag vector and zero-lag
.. doctest::
>>> data = [3,2,1]
>>> zerolag = 4
>>> twosided_zerolag(data, zerolag)
array([1, 2, 3, 4, 3, 2, 1])
.. seealso:: Same behaviour as :func:`twosided... | [
"Build",
"a",
"symmetric",
"vector",
"out",
"of",
"stricly",
"positive",
"lag",
"vector",
"and",
"zero",
"-",
"lag"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L129-L142 | [
"def",
"_twosided_zerolag",
"(",
"data",
",",
"zerolag",
")",
":",
"res",
"=",
"twosided",
"(",
"np",
".",
"insert",
"(",
"data",
",",
"0",
",",
"zerolag",
")",
")",
"return",
"res"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | cshift | Circular shift to the right (within an array) by a given offset
:param array data: input data (list or numpy.array)
:param int offset: shift the array with the offset
.. doctest::
>>> from spectrum import cshift
>>> cshift([0, 1, 2, 3, -2, -1], 2)
array([-2, -1, 0, 1, 2, 3]) | src/spectrum/tools.py | def cshift(data, offset):
"""Circular shift to the right (within an array) by a given offset
:param array data: input data (list or numpy.array)
:param int offset: shift the array with the offset
.. doctest::
>>> from spectrum import cshift
>>> cshift([0, 1, 2, 3, -2, -1], 2)
... | def cshift(data, offset):
"""Circular shift to the right (within an array) by a given offset
:param array data: input data (list or numpy.array)
:param int offset: shift the array with the offset
.. doctest::
>>> from spectrum import cshift
>>> cshift([0, 1, 2, 3, -2, -1], 2)
... | [
"Circular",
"shift",
"to",
"the",
"right",
"(",
"within",
"an",
"array",
")",
"by",
"a",
"given",
"offset"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/tools.py#L145-L164 | [
"def",
"cshift",
"(",
"data",
",",
"offset",
")",
":",
"# the deque method is suppose to be optimal when using rotate to shift the",
"# data that playing with the data to build a new list.",
"if",
"isinstance",
"(",
"offset",
",",
"float",
")",
":",
"offset",
"=",
"int",
"(... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | data_cosine | r"""Return a noisy cosine at a given frequency.
:param N: the final data size
:param A: the strength of the noise
:param float sampling: sampling frequency of the input :attr:`data`.
:param float freq: the frequency :math:`f_0` of the cosine.
.. math:: x[t] = cos(2\pi t * f_0)... | src/spectrum/datasets.py | def data_cosine(N=1024, A=0.1, sampling=1024., freq=200):
r"""Return a noisy cosine at a given frequency.
:param N: the final data size
:param A: the strength of the noise
:param float sampling: sampling frequency of the input :attr:`data`.
:param float freq: the frequency :mat... | def data_cosine(N=1024, A=0.1, sampling=1024., freq=200):
r"""Return a noisy cosine at a given frequency.
:param N: the final data size
:param A: the strength of the noise
:param float sampling: sampling frequency of the input :attr:`data`.
:param float freq: the frequency :mat... | [
"r",
"Return",
"a",
"noisy",
"cosine",
"at",
"a",
"given",
"frequency",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/datasets.py#L101-L121 | [
"def",
"data_cosine",
"(",
"N",
"=",
"1024",
",",
"A",
"=",
"0.1",
",",
"sampling",
"=",
"1024.",
",",
"freq",
"=",
"200",
")",
":",
"t",
"=",
"arange",
"(",
"0",
",",
"float",
"(",
"N",
")",
"/",
"sampling",
",",
"1.",
"/",
"sampling",
")",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | data_two_freqs | A simple test example with two close frequencies | src/spectrum/datasets.py | def data_two_freqs(N=200):
"""A simple test example with two close frequencies
"""
nn = arange(N)
xx = cos(0.257*pi*nn) + sin(0.2*pi*nn) + 0.01*randn(nn.size)
return xx | def data_two_freqs(N=200):
"""A simple test example with two close frequencies
"""
nn = arange(N)
xx = cos(0.257*pi*nn) + sin(0.2*pi*nn) + 0.01*randn(nn.size)
return xx | [
"A",
"simple",
"test",
"example",
"with",
"two",
"close",
"frequencies"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/datasets.py#L124-L130 | [
"def",
"data_two_freqs",
"(",
"N",
"=",
"200",
")",
":",
"nn",
"=",
"arange",
"(",
"N",
")",
"xx",
"=",
"cos",
"(",
"0.257",
"*",
"pi",
"*",
"nn",
")",
"+",
"sin",
"(",
"0.2",
"*",
"pi",
"*",
"nn",
")",
"+",
"0.01",
"*",
"randn",
"(",
"nn",... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | spectrum_data | Simple utilities to retrieve data sets from | src/spectrum/datasets.py | def spectrum_data(filename):
"""Simple utilities to retrieve data sets from """
import os
import pkg_resources
info = pkg_resources.get_distribution('spectrum')
location = info.location
# first try develop mode
share = os.sep.join([location, "spectrum", 'data'])
filename2 = os.sep.join(... | def spectrum_data(filename):
"""Simple utilities to retrieve data sets from """
import os
import pkg_resources
info = pkg_resources.get_distribution('spectrum')
location = info.location
# first try develop mode
share = os.sep.join([location, "spectrum", 'data'])
filename2 = os.sep.join(... | [
"Simple",
"utilities",
"to",
"retrieve",
"data",
"sets",
"from"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/datasets.py#L133-L146 | [
"def",
"spectrum_data",
"(",
"filename",
")",
":",
"import",
"os",
"import",
"pkg_resources",
"info",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"'spectrum'",
")",
"location",
"=",
"info",
".",
"location",
"# first try develop mode",
"share",
"=",
"os",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | TimeSeries.plot | Plot the data set, using the sampling information to set the x-axis
correctly. | src/spectrum/datasets.py | def plot(self, **kargs):
"""Plot the data set, using the sampling information to set the x-axis
correctly."""
from pylab import plot, linspace, xlabel, ylabel, grid
time = linspace(1*self.dt, self.N*self.dt, self.N)
plot(time, self.data, **kargs)
xlabel('Time')
yl... | def plot(self, **kargs):
"""Plot the data set, using the sampling information to set the x-axis
correctly."""
from pylab import plot, linspace, xlabel, ylabel, grid
time = linspace(1*self.dt, self.N*self.dt, self.N)
plot(time, self.data, **kargs)
xlabel('Time')
yl... | [
"Plot",
"the",
"data",
"set",
"using",
"the",
"sampling",
"information",
"to",
"set",
"the",
"x",
"-",
"axis",
"correctly",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/datasets.py#L177-L185 | [
"def",
"plot",
"(",
"self",
",",
"*",
"*",
"kargs",
")",
":",
"from",
"pylab",
"import",
"plot",
",",
"linspace",
",",
"xlabel",
",",
"ylabel",
",",
"grid",
"time",
"=",
"linspace",
"(",
"1",
"*",
"self",
".",
"dt",
",",
"self",
".",
"N",
"*",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | readwav | Read a WAV file and returns the data and sample rate
::
from spectrum.io import readwav
readwav() | src/spectrum/io.py | def readwav(filename):
"""Read a WAV file and returns the data and sample rate
::
from spectrum.io import readwav
readwav()
"""
from scipy.io.wavfile import read as readwav
samplerate, signal = readwav(filename)
return signal, samplerate | def readwav(filename):
"""Read a WAV file and returns the data and sample rate
::
from spectrum.io import readwav
readwav()
"""
from scipy.io.wavfile import read as readwav
samplerate, signal = readwav(filename)
return signal, samplerate | [
"Read",
"a",
"WAV",
"file",
"and",
"returns",
"the",
"data",
"and",
"sample",
"rate"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/io.py#L5-L16 | [
"def",
"readwav",
"(",
"filename",
")",
":",
"from",
"scipy",
".",
"io",
".",
"wavfile",
"import",
"read",
"as",
"readwav",
"samplerate",
",",
"signal",
"=",
"readwav",
"(",
"filename",
")",
"return",
"signal",
",",
"samplerate"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | pmtm | Multitapering spectral estimation
:param array x: the data
:param float NW: The time half bandwidth parameter (typical values are
2.5,3,3.5,4). Must be provided otherwise the tapering windows and
eigen values (outputs of dpss) must be provided
:param int k: uses the first k Slepian sequence... | src/spectrum/mtm.py | def pmtm(x, NW=None, k=None, NFFT=None, e=None, v=None, method='adapt', show=False):
"""Multitapering spectral estimation
:param array x: the data
:param float NW: The time half bandwidth parameter (typical values are
2.5,3,3.5,4). Must be provided otherwise the tapering windows and
eigen v... | def pmtm(x, NW=None, k=None, NFFT=None, e=None, v=None, method='adapt', show=False):
"""Multitapering spectral estimation
:param array x: the data
:param float NW: The time half bandwidth parameter (typical values are
2.5,3,3.5,4). Must be provided otherwise the tapering windows and
eigen v... | [
"Multitapering",
"spectral",
"estimation"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L104-L232 | [
"def",
"pmtm",
"(",
"x",
",",
"NW",
"=",
"None",
",",
"k",
"=",
"None",
",",
"NFFT",
"=",
"None",
",",
"e",
"=",
"None",
",",
"v",
"=",
"None",
",",
"method",
"=",
"'adapt'",
",",
"show",
"=",
"False",
")",
":",
"assert",
"method",
"in",
"[",... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | dpss | r"""Discrete prolate spheroidal (Slepian) sequences
Calculation of the Discrete Prolate Spheroidal Sequences also known as the
slepian sequences, and the corresponding eigenvalues.
:param int N: desired window length
:param float NW: The time half bandwidth parameter (typical values are
2.5,3,... | src/spectrum/mtm.py | def dpss(N, NW=None, k=None):
r"""Discrete prolate spheroidal (Slepian) sequences
Calculation of the Discrete Prolate Spheroidal Sequences also known as the
slepian sequences, and the corresponding eigenvalues.
:param int N: desired window length
:param float NW: The time half bandwidth parameter ... | def dpss(N, NW=None, k=None):
r"""Discrete prolate spheroidal (Slepian) sequences
Calculation of the Discrete Prolate Spheroidal Sequences also known as the
slepian sequences, and the corresponding eigenvalues.
:param int N: desired window length
:param float NW: The time half bandwidth parameter ... | [
"r",
"Discrete",
"prolate",
"spheroidal",
"(",
"Slepian",
")",
"sequences"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L235-L356 | [
"def",
"dpss",
"(",
"N",
",",
"NW",
"=",
"None",
",",
"k",
"=",
"None",
")",
":",
"assert",
"NW",
"<",
"N",
"/",
"2",
",",
"\"NW ({}) must be stricly less than N/2 ({}/2)\"",
".",
"format",
"(",
"NW",
",",
"N",
")",
"if",
"k",
"is",
"None",
":",
"k... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _other_dpss_method | Returns the Discrete Prolate Spheroidal Sequences of orders [0,Kmax-1]
for a given frequency-spacing multiple NW and sequence length N.
See dpss function that is the official version. This version is indepedant
of the C code and relies on Scipy function. However, it is slower by a factor 3
Tridiagonal... | src/spectrum/mtm.py | def _other_dpss_method(N, NW, Kmax):
"""Returns the Discrete Prolate Spheroidal Sequences of orders [0,Kmax-1]
for a given frequency-spacing multiple NW and sequence length N.
See dpss function that is the official version. This version is indepedant
of the C code and relies on Scipy function. However,... | def _other_dpss_method(N, NW, Kmax):
"""Returns the Discrete Prolate Spheroidal Sequences of orders [0,Kmax-1]
for a given frequency-spacing multiple NW and sequence length N.
See dpss function that is the official version. This version is indepedant
of the C code and relies on Scipy function. However,... | [
"Returns",
"the",
"Discrete",
"Prolate",
"Spheroidal",
"Sequences",
"of",
"orders",
"[",
"0",
"Kmax",
"-",
"1",
"]",
"for",
"a",
"given",
"frequency",
"-",
"spacing",
"multiple",
"NW",
"and",
"sequence",
"length",
"N",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L359-L418 | [
"def",
"_other_dpss_method",
"(",
"N",
",",
"NW",
",",
"Kmax",
")",
":",
"# here we want to set up an optimization problem to find a sequence",
"# whose energy is maximally concentrated within band [-W,W].",
"# Thus, the measure lambda(T,W) is the ratio between the energy within",
"# that ... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _autocov | Returns the autocovariance of signal s at all lags.
Adheres to the definition
sxx[k] = E{S[n]S[n+k]} = cov{S[n],S[n+k]}
where E{} is the expectation operator, and S is a zero mean process | src/spectrum/mtm.py | def _autocov(s, **kwargs):
"""Returns the autocovariance of signal s at all lags.
Adheres to the definition
sxx[k] = E{S[n]S[n+k]} = cov{S[n],S[n+k]}
where E{} is the expectation operator, and S is a zero mean process
"""
# only remove the mean once, if needed
debias = kwargs.pop('debias', ... | def _autocov(s, **kwargs):
"""Returns the autocovariance of signal s at all lags.
Adheres to the definition
sxx[k] = E{S[n]S[n+k]} = cov{S[n],S[n+k]}
where E{} is the expectation operator, and S is a zero mean process
"""
# only remove the mean once, if needed
debias = kwargs.pop('debias', ... | [
"Returns",
"the",
"autocovariance",
"of",
"signal",
"s",
"at",
"all",
"lags",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L421-L434 | [
"def",
"_autocov",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
":",
"# only remove the mean once, if needed",
"debias",
"=",
"kwargs",
".",
"pop",
"(",
"'debias'",
",",
"True",
")",
"axis",
"=",
"kwargs",
".",
"get",
"(",
"'axis'",
",",
"-",
"1",
")",
"if"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _crosscov | Returns the crosscovariance sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
Parameters
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, or to clip the length of s_xy
to be the length of x and y. If ... | src/spectrum/mtm.py | def _crosscov(x, y, axis=-1, all_lags=False, debias=True):
"""Returns the crosscovariance sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
Parameters
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, ... | def _crosscov(x, y, axis=-1, all_lags=False, debias=True):
"""Returns the crosscovariance sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
Parameters
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, ... | [
"Returns",
"the",
"crosscovariance",
"sequence",
"between",
"two",
"ndarrays",
".",
"This",
"is",
"performed",
"by",
"calling",
"fftconvolve",
"on",
"x",
"y",
"[",
"::",
"-",
"1",
"]"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L437-L476 | [
"def",
"_crosscov",
"(",
"x",
",",
"y",
",",
"axis",
"=",
"-",
"1",
",",
"all_lags",
"=",
"False",
",",
"debias",
"=",
"True",
")",
":",
"if",
"x",
".",
"shape",
"[",
"axis",
"]",
"!=",
"y",
".",
"shape",
"[",
"axis",
"]",
":",
"raise",
"Valu... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _crosscorr | Returns the crosscorrelation sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
Parameters
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, or to clip the length of r_xy
to be the length of x and y. If ... | src/spectrum/mtm.py | def _crosscorr(x, y, **kwargs):
"""
Returns the crosscorrelation sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
Parameters
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, or to clip the length ... | def _crosscorr(x, y, **kwargs):
"""
Returns the crosscorrelation sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
Parameters
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, or to clip the length ... | [
"Returns",
"the",
"crosscorrelation",
"sequence",
"between",
"two",
"ndarrays",
".",
"This",
"is",
"performed",
"by",
"calling",
"fftconvolve",
"on",
"x",
"y",
"[",
"::",
"-",
"1",
"]"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L479-L507 | [
"def",
"_crosscorr",
"(",
"x",
",",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"sxy",
"=",
"_crosscov",
"(",
"x",
",",
"y",
",",
"*",
"*",
"kwargs",
")",
"# estimate sigma_x, sigma_y to normalize",
"sx",
"=",
"np",
".",
"std",
"(",
"x",
")",
"sy",
"="... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _remove_bias | Subtracts an estimate of the mean from signal x at axis | src/spectrum/mtm.py | def _remove_bias(x, axis):
"Subtracts an estimate of the mean from signal x at axis"
padded_slice = [slice(d) for d in x.shape]
padded_slice[axis] = np.newaxis
mn = np.mean(x, axis=axis)
return x - mn[tuple(padded_slice)] | def _remove_bias(x, axis):
"Subtracts an estimate of the mean from signal x at axis"
padded_slice = [slice(d) for d in x.shape]
padded_slice[axis] = np.newaxis
mn = np.mean(x, axis=axis)
return x - mn[tuple(padded_slice)] | [
"Subtracts",
"an",
"estimate",
"of",
"the",
"mean",
"from",
"signal",
"x",
"at",
"axis"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L510-L515 | [
"def",
"_remove_bias",
"(",
"x",
",",
"axis",
")",
":",
"padded_slice",
"=",
"[",
"slice",
"(",
"d",
")",
"for",
"d",
"in",
"x",
".",
"shape",
"]",
"padded_slice",
"[",
"axis",
"]",
"=",
"np",
".",
"newaxis",
"mn",
"=",
"np",
".",
"mean",
"(",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | get_docstring_and_rest | Separate `filename` content between docstring and the rest
Strongly inspired from ast.get_docstring.
Returns
-------
docstring: str
docstring of `filename`
rest: str
`filename` content without the docstring | doc/sphinxext/sphinx_gallery/gen_rst.py | def get_docstring_and_rest(filename):
"""Separate `filename` content between docstring and the rest
Strongly inspired from ast.get_docstring.
Returns
-------
docstring: str
docstring of `filename`
rest: str
`filename` content without the docstring
"""
with open(filename... | def get_docstring_and_rest(filename):
"""Separate `filename` content between docstring and the rest
Strongly inspired from ast.get_docstring.
Returns
-------
docstring: str
docstring of `filename`
rest: str
`filename` content without the docstring
"""
with open(filename... | [
"Separate",
"filename",
"content",
"between",
"docstring",
"and",
"the",
"rest"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L134-L164 | [
"def",
"get_docstring_and_rest",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"read",
"(",
")",
"node",
"=",
"ast",
".",
"parse",
"(",
"content",
")",
"if",
"not",
"isinstance",
"(",
"node... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | split_code_and_text_blocks | Return list with source file separated into code and text blocks.
Returns
-------
blocks : list of (label, content)
List where each element is a tuple with the label ('text' or 'code'),
and content string of block. | doc/sphinxext/sphinx_gallery/gen_rst.py | def split_code_and_text_blocks(source_file):
"""Return list with source file separated into code and text blocks.
Returns
-------
blocks : list of (label, content)
List where each element is a tuple with the label ('text' or 'code'),
and content string of block.
"""
docstring, r... | def split_code_and_text_blocks(source_file):
"""Return list with source file separated into code and text blocks.
Returns
-------
blocks : list of (label, content)
List where each element is a tuple with the label ('text' or 'code'),
and content string of block.
"""
docstring, r... | [
"Return",
"list",
"with",
"source",
"file",
"separated",
"into",
"code",
"and",
"text",
"blocks",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L167-L201 | [
"def",
"split_code_and_text_blocks",
"(",
"source_file",
")",
":",
"docstring",
",",
"rest_of_content",
"=",
"get_docstring_and_rest",
"(",
"source_file",
")",
"blocks",
"=",
"[",
"(",
"'text'",
",",
"docstring",
")",
"]",
"pattern",
"=",
"re",
".",
"compile",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | codestr2rst | Return reStructuredText code block from code string | doc/sphinxext/sphinx_gallery/gen_rst.py | def codestr2rst(codestr, lang='python'):
"""Return reStructuredText code block from code string"""
code_directive = "\n.. code-block:: {0}\n\n".format(lang)
indented_block = indent(codestr, ' ' * 4)
return code_directive + indented_block | def codestr2rst(codestr, lang='python'):
"""Return reStructuredText code block from code string"""
code_directive = "\n.. code-block:: {0}\n\n".format(lang)
indented_block = indent(codestr, ' ' * 4)
return code_directive + indented_block | [
"Return",
"reStructuredText",
"code",
"block",
"from",
"code",
"string"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L204-L208 | [
"def",
"codestr2rst",
"(",
"codestr",
",",
"lang",
"=",
"'python'",
")",
":",
"code_directive",
"=",
"\"\\n.. code-block:: {0}\\n\\n\"",
".",
"format",
"(",
"lang",
")",
"indented_block",
"=",
"indent",
"(",
"codestr",
",",
"' '",
"*",
"4",
")",
"return",
"c... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | extract_intro | Extract the first paragraph of module-level docstring. max:95 char | doc/sphinxext/sphinx_gallery/gen_rst.py | def extract_intro(filename):
""" Extract the first paragraph of module-level docstring. max:95 char"""
docstring, _ = get_docstring_and_rest(filename)
# lstrip is just in case docstring has a '\n\n' at the beginning
paragraphs = docstring.lstrip().split('\n\n')
if len(paragraphs) > 1:
firs... | def extract_intro(filename):
""" Extract the first paragraph of module-level docstring. max:95 char"""
docstring, _ = get_docstring_and_rest(filename)
# lstrip is just in case docstring has a '\n\n' at the beginning
paragraphs = docstring.lstrip().split('\n\n')
if len(paragraphs) > 1:
firs... | [
"Extract",
"the",
"first",
"paragraph",
"of",
"module",
"-",
"level",
"docstring",
".",
"max",
":",
"95",
"char"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L219-L236 | [
"def",
"extract_intro",
"(",
"filename",
")",
":",
"docstring",
",",
"_",
"=",
"get_docstring_and_rest",
"(",
"filename",
")",
"# lstrip is just in case docstring has a '\\n\\n' at the beginning",
"paragraphs",
"=",
"docstring",
".",
"lstrip",
"(",
")",
".",
"split",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | get_md5sum | Returns md5sum of file | doc/sphinxext/sphinx_gallery/gen_rst.py | def get_md5sum(src_file):
"""Returns md5sum of file"""
with open(src_file, 'r') as src_data:
src_content = src_data.read()
# data needs to be encoded in python3 before hashing
if sys.version_info[0] == 3:
src_content = src_content.encode('utf-8')
src_md5 = hashlib.... | def get_md5sum(src_file):
"""Returns md5sum of file"""
with open(src_file, 'r') as src_data:
src_content = src_data.read()
# data needs to be encoded in python3 before hashing
if sys.version_info[0] == 3:
src_content = src_content.encode('utf-8')
src_md5 = hashlib.... | [
"Returns",
"md5sum",
"of",
"file"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L239-L250 | [
"def",
"get_md5sum",
"(",
"src_file",
")",
":",
"with",
"open",
"(",
"src_file",
",",
"'r'",
")",
"as",
"src_data",
":",
"src_content",
"=",
"src_data",
".",
"read",
"(",
")",
"# data needs to be encoded in python3 before hashing",
"if",
"sys",
".",
"version_inf... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | check_md5sum_change | Returns True if src_file has a different md5sum | doc/sphinxext/sphinx_gallery/gen_rst.py | def check_md5sum_change(src_file):
"""Returns True if src_file has a different md5sum"""
src_md5 = get_md5sum(src_file)
src_md5_file = src_file + '.md5'
src_file_changed = True
if os.path.exists(src_md5_file):
with open(src_md5_file, 'r') as file_checksum:
ref_md5 = file_checks... | def check_md5sum_change(src_file):
"""Returns True if src_file has a different md5sum"""
src_md5 = get_md5sum(src_file)
src_md5_file = src_file + '.md5'
src_file_changed = True
if os.path.exists(src_md5_file):
with open(src_md5_file, 'r') as file_checksum:
ref_md5 = file_checks... | [
"Returns",
"True",
"if",
"src_file",
"has",
"a",
"different",
"md5sum"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L253-L270 | [
"def",
"check_md5sum_change",
"(",
"src_file",
")",
":",
"src_md5",
"=",
"get_md5sum",
"(",
"src_file",
")",
"src_md5_file",
"=",
"src_file",
"+",
"'.md5'",
"src_file_changed",
"=",
"True",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"src_md5_file",
")",
":... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _plots_are_current | Test existence of image file and no change in md5sum of
example | doc/sphinxext/sphinx_gallery/gen_rst.py | def _plots_are_current(src_file, image_file):
"""Test existence of image file and no change in md5sum of
example"""
first_image_file = image_file.format(1)
has_image = os.path.exists(first_image_file)
src_file_changed = check_md5sum_change(src_file)
return has_image and not src_file_changed | def _plots_are_current(src_file, image_file):
"""Test existence of image file and no change in md5sum of
example"""
first_image_file = image_file.format(1)
has_image = os.path.exists(first_image_file)
src_file_changed = check_md5sum_change(src_file)
return has_image and not src_file_changed | [
"Test",
"existence",
"of",
"image",
"file",
"and",
"no",
"change",
"in",
"md5sum",
"of",
"example"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L273-L281 | [
"def",
"_plots_are_current",
"(",
"src_file",
",",
"image_file",
")",
":",
"first_image_file",
"=",
"image_file",
".",
"format",
"(",
"1",
")",
"has_image",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"first_image_file",
")",
"src_file_changed",
"=",
"check_md... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | save_figures | Save all open matplotlib figures of the example code-block
Parameters
----------
image_path : str
Path where plots are saved (format string which accepts figure number)
fig_count : int
Previous figure number count. Figure number add from this number
Returns
-------
list of ... | doc/sphinxext/sphinx_gallery/gen_rst.py | def save_figures(image_path, fig_count, gallery_conf):
"""Save all open matplotlib figures of the example code-block
Parameters
----------
image_path : str
Path where plots are saved (format string which accepts figure number)
fig_count : int
Previous figure number count. Figure num... | def save_figures(image_path, fig_count, gallery_conf):
"""Save all open matplotlib figures of the example code-block
Parameters
----------
image_path : str
Path where plots are saved (format string which accepts figure number)
fig_count : int
Previous figure number count. Figure num... | [
"Save",
"all",
"open",
"matplotlib",
"figures",
"of",
"the",
"example",
"code",
"-",
"block"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L284-L332 | [
"def",
"save_figures",
"(",
"image_path",
",",
"fig_count",
",",
"gallery_conf",
")",
":",
"figure_list",
"=",
"[",
"]",
"fig_managers",
"=",
"matplotlib",
".",
"_pylab_helpers",
".",
"Gcf",
".",
"get_all_fig_managers",
"(",
")",
"for",
"fig_mngr",
"in",
"fig_... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | scale_image | Scales an image with the same aspect ratio centered in an
image with a given max_width and max_height
if in_fname == out_fname the image can only be scaled down | doc/sphinxext/sphinx_gallery/gen_rst.py | def scale_image(in_fname, out_fname, max_width, max_height):
"""Scales an image with the same aspect ratio centered in an
image with a given max_width and max_height
if in_fname == out_fname the image can only be scaled down
"""
# local import to avoid testing dependency on PIL:
try:
... | def scale_image(in_fname, out_fname, max_width, max_height):
"""Scales an image with the same aspect ratio centered in an
image with a given max_width and max_height
if in_fname == out_fname the image can only be scaled down
"""
# local import to avoid testing dependency on PIL:
try:
... | [
"Scales",
"an",
"image",
"with",
"the",
"same",
"aspect",
"ratio",
"centered",
"in",
"an",
"image",
"with",
"a",
"given",
"max_width",
"and",
"max_height",
"if",
"in_fname",
"==",
"out_fname",
"the",
"image",
"can",
"only",
"be",
"scaled",
"down"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L335-L377 | [
"def",
"scale_image",
"(",
"in_fname",
",",
"out_fname",
",",
"max_width",
",",
"max_height",
")",
":",
"# local import to avoid testing dependency on PIL:",
"try",
":",
"from",
"PIL",
"import",
"Image",
"except",
"ImportError",
":",
"import",
"Image",
"img",
"=",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | save_thumbnail | Save the thumbnail image | doc/sphinxext/sphinx_gallery/gen_rst.py | def save_thumbnail(image_path, base_image_name, gallery_conf):
"""Save the thumbnail image"""
first_image_file = image_path.format(1)
thumb_dir = os.path.join(os.path.dirname(first_image_file), 'thumb')
if not os.path.exists(thumb_dir):
os.makedirs(thumb_dir)
thumb_file = os.path.join(thumb... | def save_thumbnail(image_path, base_image_name, gallery_conf):
"""Save the thumbnail image"""
first_image_file = image_path.format(1)
thumb_dir = os.path.join(os.path.dirname(first_image_file), 'thumb')
if not os.path.exists(thumb_dir):
os.makedirs(thumb_dir)
thumb_file = os.path.join(thumb... | [
"Save",
"the",
"thumbnail",
"image"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L380-L397 | [
"def",
"save_thumbnail",
"(",
"image_path",
",",
"base_image_name",
",",
"gallery_conf",
")",
":",
"first_image_file",
"=",
"image_path",
".",
"format",
"(",
"1",
")",
"thumb_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | generate_dir_rst | Generate the gallery reStructuredText for an example directory | doc/sphinxext/sphinx_gallery/gen_rst.py | def generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs):
"""Generate the gallery reStructuredText for an example directory"""
if not os.path.exists(os.path.join(src_dir, 'README.txt')):
print(80 * '_')
print('Example directory %s does not have a README.txt file' %
sr... | def generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs):
"""Generate the gallery reStructuredText for an example directory"""
if not os.path.exists(os.path.join(src_dir, 'README.txt')):
print(80 * '_')
print('Example directory %s does not have a README.txt file' %
sr... | [
"Generate",
"the",
"gallery",
"reStructuredText",
"for",
"an",
"example",
"directory"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L400-L441 | [
"def",
"generate_dir_rst",
"(",
"src_dir",
",",
"target_dir",
",",
"gallery_conf",
",",
"seen_backrefs",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"src_dir",
",",
"'README.txt'",
")",
")",
":",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | execute_script | Executes the code block of the example file | doc/sphinxext/sphinx_gallery/gen_rst.py | def execute_script(code_block, example_globals, image_path, fig_count,
src_file, gallery_conf):
"""Executes the code block of the example file"""
time_elapsed = 0
stdout = ''
# We need to execute the code
print('plotting code blocks in %s' % src_file)
plt.close('all')
cw... | def execute_script(code_block, example_globals, image_path, fig_count,
src_file, gallery_conf):
"""Executes the code block of the example file"""
time_elapsed = 0
stdout = ''
# We need to execute the code
print('plotting code blocks in %s' % src_file)
plt.close('all')
cw... | [
"Executes",
"the",
"code",
"block",
"of",
"the",
"example",
"file"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L444-L517 | [
"def",
"execute_script",
"(",
"code_block",
",",
"example_globals",
",",
"image_path",
",",
"fig_count",
",",
"src_file",
",",
"gallery_conf",
")",
":",
"time_elapsed",
"=",
"0",
"stdout",
"=",
"''",
"# We need to execute the code",
"print",
"(",
"'plotting code blo... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | generate_file_rst | Generate the rst file for a given example.
Returns the amout of code (in characters) of the corresponding
files. | doc/sphinxext/sphinx_gallery/gen_rst.py | def generate_file_rst(fname, target_dir, src_dir, gallery_conf):
""" Generate the rst file for a given example.
Returns the amout of code (in characters) of the corresponding
files.
"""
src_file = os.path.join(src_dir, fname)
example_file = os.path.join(target_dir, fname)
shutil.co... | def generate_file_rst(fname, target_dir, src_dir, gallery_conf):
""" Generate the rst file for a given example.
Returns the amout of code (in characters) of the corresponding
files.
"""
src_file = os.path.join(src_dir, fname)
example_file = os.path.join(target_dir, fname)
shutil.co... | [
"Generate",
"the",
"rst",
"file",
"for",
"a",
"given",
"example",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L520-L607 | [
"def",
"generate_file_rst",
"(",
"fname",
",",
"target_dir",
",",
"src_dir",
",",
"gallery_conf",
")",
":",
"src_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"src_dir",
",",
"fname",
")",
"example_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"t... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _arburg2 | This version is 10 times faster than arburg, but the output rho is not correct.
returns [1 a0,a1, an-1] | src/spectrum/burg.py | def _arburg2(X, order):
"""This version is 10 times faster than arburg, but the output rho is not correct.
returns [1 a0,a1, an-1]
"""
x = np.array(X)
N = len(x)
if order <= 0.:
raise ValueError("order must be > 0")
# Initialisation
# ------ rho, den
rho = sum(abs(x)**2.... | def _arburg2(X, order):
"""This version is 10 times faster than arburg, but the output rho is not correct.
returns [1 a0,a1, an-1]
"""
x = np.array(X)
N = len(x)
if order <= 0.:
raise ValueError("order must be > 0")
# Initialisation
# ------ rho, den
rho = sum(abs(x)**2.... | [
"This",
"version",
"is",
"10",
"times",
"faster",
"than",
"arburg",
"but",
"the",
"output",
"rho",
"is",
"not",
"correct",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/burg.py#L22-L79 | [
"def",
"_arburg2",
"(",
"X",
",",
"order",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"X",
")",
"N",
"=",
"len",
"(",
"x",
")",
"if",
"order",
"<=",
"0.",
":",
"raise",
"ValueError",
"(",
"\"order must be > 0\"",
")",
"# Initialisation",
"# ------ ... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | arburg | r"""Estimate the complex autoregressive parameters by the Burg algorithm.
.. math:: x(n) = \sqrt{(v}) e(n) + \sum_{k=1}^{P+1} a(k) x(n-k)
:param x: Array of complex data samples (length N)
:param order: Order of autoregressive process (0<order<N)
:param criteria: select a criteria to automatically se... | src/spectrum/burg.py | def arburg(X, order, criteria=None):
r"""Estimate the complex autoregressive parameters by the Burg algorithm.
.. math:: x(n) = \sqrt{(v}) e(n) + \sum_{k=1}^{P+1} a(k) x(n-k)
:param x: Array of complex data samples (length N)
:param order: Order of autoregressive process (0<order<N)
:param criter... | def arburg(X, order, criteria=None):
r"""Estimate the complex autoregressive parameters by the Burg algorithm.
.. math:: x(n) = \sqrt{(v}) e(n) + \sum_{k=1}^{P+1} a(k) x(n-k)
:param x: Array of complex data samples (length N)
:param order: Order of autoregressive process (0<order<N)
:param criter... | [
"r",
"Estimate",
"the",
"complex",
"autoregressive",
"parameters",
"by",
"the",
"Burg",
"algorithm",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/burg.py#L161-L284 | [
"def",
"arburg",
"(",
"X",
",",
"order",
",",
"criteria",
"=",
"None",
")",
":",
"if",
"order",
"<=",
"0.",
":",
"raise",
"ValueError",
"(",
"\"order must be > 0\"",
")",
"if",
"order",
">",
"len",
"(",
"X",
")",
":",
"raise",
"ValueError",
"(",
"\"o... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _numpy_cholesky | Solve Ax=B using numpy cholesky solver
A = LU
in the case where A is square and Hermitian, A = L.L* where L* is
transpoed and conjugate matrix
Ly = b
where
Ux=y
so x = U^{-1} y
where U = L*
and y = L^{-1} B | src/spectrum/cholesky.py | def _numpy_cholesky(A, B):
"""Solve Ax=B using numpy cholesky solver
A = LU
in the case where A is square and Hermitian, A = L.L* where L* is
transpoed and conjugate matrix
Ly = b
where
Ux=y
so x = U^{-1} y
where U = L*
and y = L^{-1} B
"""
L = numpy.linalg.cholesky... | def _numpy_cholesky(A, B):
"""Solve Ax=B using numpy cholesky solver
A = LU
in the case where A is square and Hermitian, A = L.L* where L* is
transpoed and conjugate matrix
Ly = b
where
Ux=y
so x = U^{-1} y
where U = L*
and y = L^{-1} B
"""
L = numpy.linalg.cholesky... | [
"Solve",
"Ax",
"=",
"B",
"using",
"numpy",
"cholesky",
"solver"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/cholesky.py#L16-L40 | [
"def",
"_numpy_cholesky",
"(",
"A",
",",
"B",
")",
":",
"L",
"=",
"numpy",
".",
"linalg",
".",
"cholesky",
"(",
"A",
")",
"# A=L*numpy.transpose(L).conjugate()",
"# Ly = b",
"y",
"=",
"numpy",
".",
"linalg",
".",
"solve",
"(",
"L",
",",
"B",
")",
"# Ux... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _numpy_solver | This function solve Ax=B directly without taking care of the input
matrix properties. | src/spectrum/cholesky.py | def _numpy_solver(A, B):
"""This function solve Ax=B directly without taking care of the input
matrix properties.
"""
x = numpy.linalg.solve(A, B)
return x | def _numpy_solver(A, B):
"""This function solve Ax=B directly without taking care of the input
matrix properties.
"""
x = numpy.linalg.solve(A, B)
return x | [
"This",
"function",
"solve",
"Ax",
"=",
"B",
"directly",
"without",
"taking",
"care",
"of",
"the",
"input",
"matrix",
"properties",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/cholesky.py#L42-L47 | [
"def",
"_numpy_solver",
"(",
"A",
",",
"B",
")",
":",
"x",
"=",
"numpy",
".",
"linalg",
".",
"solve",
"(",
"A",
",",
"B",
")",
"return",
"x"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | CHOLESKY | Solve linear system `AX=B` using CHOLESKY method.
:param A: an input Hermitian matrix
:param B: an array
:param str method: a choice of method in [numpy, scipy, numpy_solver]
* `numpy_solver` relies entirely on numpy.solver (no cholesky decomposition)
* `numpy` relies on the numpy.linalg.c... | src/spectrum/cholesky.py | def CHOLESKY(A, B, method='scipy'):
"""Solve linear system `AX=B` using CHOLESKY method.
:param A: an input Hermitian matrix
:param B: an array
:param str method: a choice of method in [numpy, scipy, numpy_solver]
* `numpy_solver` relies entirely on numpy.solver (no cholesky decomposition)
... | def CHOLESKY(A, B, method='scipy'):
"""Solve linear system `AX=B` using CHOLESKY method.
:param A: an input Hermitian matrix
:param B: an array
:param str method: a choice of method in [numpy, scipy, numpy_solver]
* `numpy_solver` relies entirely on numpy.solver (no cholesky decomposition)
... | [
"Solve",
"linear",
"system",
"AX",
"=",
"B",
"using",
"CHOLESKY",
"method",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/cholesky.py#L49-L105 | [
"def",
"CHOLESKY",
"(",
"A",
",",
"B",
",",
"method",
"=",
"'scipy'",
")",
":",
"if",
"method",
"==",
"'numpy_solver'",
":",
"X",
"=",
"_numpy_solver",
"(",
"A",
",",
"B",
")",
"return",
"X",
"elif",
"method",
"==",
"'numpy'",
":",
"X",
",",
"_L",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | music | Eigen value pseudo spectrum estimate. See :func:`eigenfre` | src/spectrum/eigenfre.py | def music(X, IP, NSIG=None, NFFT=default_NFFT, threshold=None, criteria='aic',
verbose=False):
"""Eigen value pseudo spectrum estimate. See :func:`eigenfre`"""
return eigen(X, IP, NSIG=NSIG, method='music', NFFT=NFFT,
threshold=threshold, criteria=criteria, verbose=verbose) | def music(X, IP, NSIG=None, NFFT=default_NFFT, threshold=None, criteria='aic',
verbose=False):
"""Eigen value pseudo spectrum estimate. See :func:`eigenfre`"""
return eigen(X, IP, NSIG=NSIG, method='music', NFFT=NFFT,
threshold=threshold, criteria=criteria, verbose=verbose) | [
"Eigen",
"value",
"pseudo",
"spectrum",
"estimate",
".",
"See",
":",
"func",
":",
"eigenfre"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/eigenfre.py#L146-L150 | [
"def",
"music",
"(",
"X",
",",
"IP",
",",
"NSIG",
"=",
"None",
",",
"NFFT",
"=",
"default_NFFT",
",",
"threshold",
"=",
"None",
",",
"criteria",
"=",
"'aic'",
",",
"verbose",
"=",
"False",
")",
":",
"return",
"eigen",
"(",
"X",
",",
"IP",
",",
"N... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | eigen | r"""Pseudo spectrum using eigenvector method (EV or Music)
This function computes either the Music or EigenValue (EV) noise
subspace frequency estimator.
First, an autocorrelation matrix of order `P` is computed from
the data. Second, this matrix is separated into vector subspaces,
one a signal su... | src/spectrum/eigenfre.py | def eigen(X, P, NSIG=None, method='music', threshold=None, NFFT=default_NFFT,
criteria='aic', verbose=False):
r"""Pseudo spectrum using eigenvector method (EV or Music)
This function computes either the Music or EigenValue (EV) noise
subspace frequency estimator.
First, an autocorrelation ma... | def eigen(X, P, NSIG=None, method='music', threshold=None, NFFT=default_NFFT,
criteria='aic', verbose=False):
r"""Pseudo spectrum using eigenvector method (EV or Music)
This function computes either the Music or EigenValue (EV) noise
subspace frequency estimator.
First, an autocorrelation ma... | [
"r",
"Pseudo",
"spectrum",
"using",
"eigenvector",
"method",
"(",
"EV",
"or",
"Music",
")"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/eigenfre.py#L160-L306 | [
"def",
"eigen",
"(",
"X",
",",
"P",
",",
"NSIG",
"=",
"None",
",",
"method",
"=",
"'music'",
",",
"threshold",
"=",
"None",
",",
"NFFT",
"=",
"default_NFFT",
",",
"criteria",
"=",
"'aic'",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"method",
"no... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _get_signal_space | todo | src/spectrum/eigenfre.py | def _get_signal_space(S, NP, verbose=False, threshold=None, NSIG=None,
criteria='aic'):
"""todo
"""
from .criteria import aic_eigen, mdl_eigen
# This section selects automatically the noise and signal subspaces.
# NSIG being the number of eigenvalues corresponding to signals.
... | def _get_signal_space(S, NP, verbose=False, threshold=None, NSIG=None,
criteria='aic'):
"""todo
"""
from .criteria import aic_eigen, mdl_eigen
# This section selects automatically the noise and signal subspaces.
# NSIG being the number of eigenvalues corresponding to signals.
... | [
"todo"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/eigenfre.py#L309-L340 | [
"def",
"_get_signal_space",
"(",
"S",
",",
"NP",
",",
"verbose",
"=",
"False",
",",
"threshold",
"=",
"None",
",",
"NSIG",
"=",
"None",
",",
"criteria",
"=",
"'aic'",
")",
":",
"from",
".",
"criteria",
"import",
"aic_eigen",
",",
"mdl_eigen",
"# This sec... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | speriodogram | Simple periodogram, but matrices accepted.
:param x: an array or matrix of data samples.
:param NFFT: length of the data before FFT is computed (zero padding)
:param bool detrend: detrend the data before co,puteing the FFT
:param float sampling: sampling frequency of the input :attr:`data`.
:param... | src/spectrum/periodogram.py | def speriodogram(x, NFFT=None, detrend=True, sampling=1.,
scale_by_freq=True, window='hamming', axis=0):
"""Simple periodogram, but matrices accepted.
:param x: an array or matrix of data samples.
:param NFFT: length of the data before FFT is computed (zero padding)
:param bool detre... | def speriodogram(x, NFFT=None, detrend=True, sampling=1.,
scale_by_freq=True, window='hamming', axis=0):
"""Simple periodogram, but matrices accepted.
:param x: an array or matrix of data samples.
:param NFFT: length of the data before FFT is computed (zero padding)
:param bool detre... | [
"Simple",
"periodogram",
"but",
"matrices",
"accepted",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/periodogram.py#L51-L144 | [
"def",
"speriodogram",
"(",
"x",
",",
"NFFT",
"=",
"None",
",",
"detrend",
"=",
"True",
",",
"sampling",
"=",
"1.",
",",
"scale_by_freq",
"=",
"True",
",",
"window",
"=",
"'hamming'",
",",
"axis",
"=",
"0",
")",
":",
"x",
"=",
"np",
".",
"array",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | WelchPeriodogram | r"""Simple periodogram wrapper of numpy.psd function.
:param A: the input data
:param int NFFT: total length of the final data sets (padded
with zero if needed; default is 4096)
:param str window:
:Technical documentation:
When we calculate the periodogram of a set of data we get an esti... | src/spectrum/periodogram.py | def WelchPeriodogram(data, NFFT=None, sampling=1., **kargs):
r"""Simple periodogram wrapper of numpy.psd function.
:param A: the input data
:param int NFFT: total length of the final data sets (padded
with zero if needed; default is 4096)
:param str window:
:Technical documentation:
... | def WelchPeriodogram(data, NFFT=None, sampling=1., **kargs):
r"""Simple periodogram wrapper of numpy.psd function.
:param A: the input data
:param int NFFT: total length of the final data sets (padded
with zero if needed; default is 4096)
:param str window:
:Technical documentation:
... | [
"r",
"Simple",
"periodogram",
"wrapper",
"of",
"numpy",
".",
"psd",
"function",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/periodogram.py#L147-L206 | [
"def",
"WelchPeriodogram",
"(",
"data",
",",
"NFFT",
"=",
"None",
",",
"sampling",
"=",
"1.",
",",
"*",
"*",
"kargs",
")",
":",
"from",
"pylab",
"import",
"psd",
"spectrum",
"=",
"Spectrum",
"(",
"data",
",",
"sampling",
"=",
"1.",
")",
"P",
"=",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | DaniellPeriodogram | r"""Return Daniell's periodogram.
To reduce fast fluctuations of the spectrum one idea proposed by daniell
is to average each value with points in its neighboorhood. It's like
a low filter.
.. math:: \hat{P}_D[f_i]= \frac{1}{2P+1} \sum_{n=i-P}^{i+P} \tilde{P}_{xx}[f_n]
where P is the number of po... | src/spectrum/periodogram.py | def DaniellPeriodogram(data, P, NFFT=None, detrend='mean', sampling=1.,
scale_by_freq=True, window='hamming'):
r"""Return Daniell's periodogram.
To reduce fast fluctuations of the spectrum one idea proposed by daniell
is to average each value with points in its neighboorhood. It's li... | def DaniellPeriodogram(data, P, NFFT=None, detrend='mean', sampling=1.,
scale_by_freq=True, window='hamming'):
r"""Return Daniell's periodogram.
To reduce fast fluctuations of the spectrum one idea proposed by daniell
is to average each value with points in its neighboorhood. It's li... | [
"r",
"Return",
"Daniell",
"s",
"periodogram",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/periodogram.py#L259-L321 | [
"def",
"DaniellPeriodogram",
"(",
"data",
",",
"P",
",",
"NFFT",
"=",
"None",
",",
"detrend",
"=",
"'mean'",
",",
"sampling",
"=",
"1.",
",",
"scale_by_freq",
"=",
"True",
",",
"window",
"=",
"'hamming'",
")",
":",
"psd",
"=",
"speriodogram",
"(",
"dat... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Range.centerdc_gen | Return the centered frequency range as a generator.
::
>>> print(list(Range(8).centerdc_gen()))
[-0.5, -0.375, -0.25, -0.125, 0.0, 0.125, 0.25, 0.375] | src/spectrum/psd.py | def centerdc_gen(self):
"""Return the centered frequency range as a generator.
::
>>> print(list(Range(8).centerdc_gen()))
[-0.5, -0.375, -0.25, -0.125, 0.0, 0.125, 0.25, 0.375]
"""
for a in range(0, self.N):
yield (a-self.N/2) * self.df | def centerdc_gen(self):
"""Return the centered frequency range as a generator.
::
>>> print(list(Range(8).centerdc_gen()))
[-0.5, -0.375, -0.25, -0.125, 0.0, 0.125, 0.25, 0.375]
"""
for a in range(0, self.N):
yield (a-self.N/2) * self.df | [
"Return",
"the",
"centered",
"frequency",
"range",
"as",
"a",
"generator",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L105-L115 | [
"def",
"centerdc_gen",
"(",
"self",
")",
":",
"for",
"a",
"in",
"range",
"(",
"0",
",",
"self",
".",
"N",
")",
":",
"yield",
"(",
"a",
"-",
"self",
".",
"N",
"/",
"2",
")",
"*",
"self",
".",
"df"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Range.onesided_gen | Return the one-sided frequency range as a generator.
If :attr:`N` is even, the length is N/2 + 1.
If :attr:`N` is odd, the length is (N+1)/2.
::
>>> print(list(Range(8).onesided()))
[0.0, 0.125, 0.25, 0.375, 0.5]
>>> print(list(Range(9).onesided()))
... | src/spectrum/psd.py | def onesided_gen(self):
"""Return the one-sided frequency range as a generator.
If :attr:`N` is even, the length is N/2 + 1.
If :attr:`N` is odd, the length is (N+1)/2.
::
>>> print(list(Range(8).onesided()))
[0.0, 0.125, 0.25, 0.375, 0.5]
>>> print... | def onesided_gen(self):
"""Return the one-sided frequency range as a generator.
If :attr:`N` is even, the length is N/2 + 1.
If :attr:`N` is odd, the length is (N+1)/2.
::
>>> print(list(Range(8).onesided()))
[0.0, 0.125, 0.25, 0.375, 0.5]
>>> print... | [
"Return",
"the",
"one",
"-",
"sided",
"frequency",
"range",
"as",
"a",
"generator",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L129-L148 | [
"def",
"onesided_gen",
"(",
"self",
")",
":",
"if",
"self",
".",
"N",
"%",
"2",
"==",
"0",
":",
"for",
"n",
"in",
"range",
"(",
"0",
",",
"self",
".",
"N",
"//",
"2",
"+",
"1",
")",
":",
"yield",
"n",
"*",
"self",
".",
"df",
"else",
":",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Spectrum.frequencies | Return the frequency vector according to :attr:`sides` | src/spectrum/psd.py | def frequencies(self, sides=None):
"""Return the frequency vector according to :attr:`sides`"""
# use the attribute sides except if a valid sides argument is provided
if sides is None:
sides = self.sides
if sides not in self._sides_choices:
raise errors.SpectrumC... | def frequencies(self, sides=None):
"""Return the frequency vector according to :attr:`sides`"""
# use the attribute sides except if a valid sides argument is provided
if sides is None:
sides = self.sides
if sides not in self._sides_choices:
raise errors.SpectrumC... | [
"Return",
"the",
"frequency",
"vector",
"according",
"to",
":",
"attr",
":",
"sides"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L540-L554 | [
"def",
"frequencies",
"(",
"self",
",",
"sides",
"=",
"None",
")",
":",
"# use the attribute sides except if a valid sides argument is provided",
"if",
"sides",
"is",
"None",
":",
"sides",
"=",
"self",
".",
"sides",
"if",
"sides",
"not",
"in",
"self",
".",
"_sid... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Spectrum.get_converted_psd | This function returns the PSD in the **sides** format
:param str sides: the PSD format in ['onesided', 'twosided', 'centerdc']
:return: the expected PSD.
.. doctest::
from spectrum import *
p = pcovar(marple_data, 15)
centerdc_psd = p.get_converted_psd('cen... | src/spectrum/psd.py | def get_converted_psd(self, sides):
"""This function returns the PSD in the **sides** format
:param str sides: the PSD format in ['onesided', 'twosided', 'centerdc']
:return: the expected PSD.
.. doctest::
from spectrum import *
p = pcovar(marple_data, 15)
... | def get_converted_psd(self, sides):
"""This function returns the PSD in the **sides** format
:param str sides: the PSD format in ['onesided', 'twosided', 'centerdc']
:return: the expected PSD.
.. doctest::
from spectrum import *
p = pcovar(marple_data, 15)
... | [
"This",
"function",
"returns",
"the",
"PSD",
"in",
"the",
"**",
"sides",
"**",
"format"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L556-L625 | [
"def",
"get_converted_psd",
"(",
"self",
",",
"sides",
")",
":",
"if",
"sides",
"==",
"self",
".",
"sides",
":",
"#nothing to be done is sides = :attr:`sides",
"return",
"self",
".",
"__psd",
"if",
"self",
".",
"datatype",
"==",
"'complex'",
":",
"assert",
"si... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Spectrum.plot | a simple plotting routine to plot the PSD versus frequency.
:param str filename: save the figure into a file
:param norm: False by default. If True, the PSD is normalised.
:param ylim: readjust the y range .
:param sides: if not provided, :attr:`sides` is used. See :attr:`sides`
... | src/spectrum/psd.py | def plot(self, filename=None, norm=False, ylim=None,
sides=None, **kargs):
"""a simple plotting routine to plot the PSD versus frequency.
:param str filename: save the figure into a file
:param norm: False by default. If True, the PSD is normalised.
:param ylim: readjust ... | def plot(self, filename=None, norm=False, ylim=None,
sides=None, **kargs):
"""a simple plotting routine to plot the PSD versus frequency.
:param str filename: save the figure into a file
:param norm: False by default. If True, the PSD is normalised.
:param ylim: readjust ... | [
"a",
"simple",
"plotting",
"routine",
"to",
"plot",
"the",
"PSD",
"versus",
"frequency",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L627-L715 | [
"def",
"plot",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"norm",
"=",
"False",
",",
"ylim",
"=",
"None",
",",
"sides",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"import",
"pylab",
"from",
"pylab",
"import",
"ylim",
"as",
"plt_ylim",
"#Fi... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Spectrum.power | r"""Return the power contained in the PSD
if scale_by_freq is False, the power is:
.. math:: P = N \sum_{k=1}^{N} P_{xx}(k)
else, it is
.. math:: P = \sum_{k=1}^{N} P_{xx}(k) \frac{df}{2\pi}
.. todo:: check these equations | src/spectrum/psd.py | def power(self):
r"""Return the power contained in the PSD
if scale_by_freq is False, the power is:
.. math:: P = N \sum_{k=1}^{N} P_{xx}(k)
else, it is
.. math:: P = \sum_{k=1}^{N} P_{xx}(k) \frac{df}{2\pi}
.. todo:: check these equations
"""
if s... | def power(self):
r"""Return the power contained in the PSD
if scale_by_freq is False, the power is:
.. math:: P = N \sum_{k=1}^{N} P_{xx}(k)
else, it is
.. math:: P = \sum_{k=1}^{N} P_{xx}(k) \frac{df}{2\pi}
.. todo:: check these equations
"""
if s... | [
"r",
"Return",
"the",
"power",
"contained",
"in",
"the",
"PSD"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L717-L735 | [
"def",
"power",
"(",
"self",
")",
":",
"if",
"self",
".",
"scale_by_freq",
"==",
"False",
":",
"return",
"sum",
"(",
"self",
".",
"psd",
")",
"*",
"len",
"(",
"self",
".",
"psd",
")",
"else",
":",
"return",
"sum",
"(",
"self",
".",
"psd",
")",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | FourierSpectrum.periodogram | An alias to :class:`~spectrum.periodogram.Periodogram`
The parameters are extracted from the attributes. Relevant attributes
ares :attr:`window`, attr:`sampling`, attr:`NFFT`, attr:`scale_by_freq`,
:attr:`detrend`.
.. plot::
:width: 80%
:include-source:
... | src/spectrum/psd.py | def periodogram(self):
"""An alias to :class:`~spectrum.periodogram.Periodogram`
The parameters are extracted from the attributes. Relevant attributes
ares :attr:`window`, attr:`sampling`, attr:`NFFT`, attr:`scale_by_freq`,
:attr:`detrend`.
.. plot::
:width: 80%
... | def periodogram(self):
"""An alias to :class:`~spectrum.periodogram.Periodogram`
The parameters are extracted from the attributes. Relevant attributes
ares :attr:`window`, attr:`sampling`, attr:`NFFT`, attr:`scale_by_freq`,
:attr:`detrend`.
.. plot::
:width: 80%
... | [
"An",
"alias",
"to",
":",
"class",
":",
"~spectrum",
".",
"periodogram",
".",
"Periodogram"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/psd.py#L986-L1007 | [
"def",
"periodogram",
"(",
"self",
")",
":",
"from",
".",
"periodogram",
"import",
"speriodogram",
"psd",
"=",
"speriodogram",
"(",
"self",
".",
"data",
",",
"window",
"=",
"self",
".",
"window",
",",
"sampling",
"=",
"self",
".",
"sampling",
",",
"NFFT"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | ipy_notebook_skeleton | Returns a dictionary with the elements of a Jupyter notebook | doc/sphinxext/sphinx_gallery/notebook.py | def ipy_notebook_skeleton():
"""Returns a dictionary with the elements of a Jupyter notebook"""
py_version = sys.version_info
notebook_skeleton = {
"cells": [],
"metadata": {
"kernelspec": {
"display_name": "Python " + str(py_version[0]),
"language... | def ipy_notebook_skeleton():
"""Returns a dictionary with the elements of a Jupyter notebook"""
py_version = sys.version_info
notebook_skeleton = {
"cells": [],
"metadata": {
"kernelspec": {
"display_name": "Python " + str(py_version[0]),
"language... | [
"Returns",
"a",
"dictionary",
"with",
"the",
"elements",
"of",
"a",
"Jupyter",
"notebook"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/notebook.py#L19-L46 | [
"def",
"ipy_notebook_skeleton",
"(",
")",
":",
"py_version",
"=",
"sys",
".",
"version_info",
"notebook_skeleton",
"=",
"{",
"\"cells\"",
":",
"[",
"]",
",",
"\"metadata\"",
":",
"{",
"\"kernelspec\"",
":",
"{",
"\"display_name\"",
":",
"\"Python \"",
"+",
"st... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | rst2md | Converts the RST text from the examples docstrigs and comments
into markdown text for the IPython notebooks | doc/sphinxext/sphinx_gallery/notebook.py | def rst2md(text):
"""Converts the RST text from the examples docstrigs and comments
into markdown text for the IPython notebooks"""
top_heading = re.compile(r'^=+$\s^([\w\s-]+)^=+$', flags=re.M)
text = re.sub(top_heading, r'# \1', text)
math_eq = re.compile(r'^\.\. math::((?:.+)?(?:\n+^ .+)*)', f... | def rst2md(text):
"""Converts the RST text from the examples docstrigs and comments
into markdown text for the IPython notebooks"""
top_heading = re.compile(r'^=+$\s^([\w\s-]+)^=+$', flags=re.M)
text = re.sub(top_heading, r'# \1', text)
math_eq = re.compile(r'^\.\. math::((?:.+)?(?:\n+^ .+)*)', f... | [
"Converts",
"the",
"RST",
"text",
"from",
"the",
"examples",
"docstrigs",
"and",
"comments",
"into",
"markdown",
"text",
"for",
"the",
"IPython",
"notebooks"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/notebook.py#L49-L63 | [
"def",
"rst2md",
"(",
"text",
")",
":",
"top_heading",
"=",
"re",
".",
"compile",
"(",
"r'^=+$\\s^([\\w\\s-]+)^=+$'",
",",
"flags",
"=",
"re",
".",
"M",
")",
"text",
"=",
"re",
".",
"sub",
"(",
"top_heading",
",",
"r'# \\1'",
",",
"text",
")",
"math_eq... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Notebook.add_markdown_cell | Add a markdown cell to the notebook
Parameters
----------
code : str
Cell content | doc/sphinxext/sphinx_gallery/notebook.py | def add_markdown_cell(self, text):
"""Add a markdown cell to the notebook
Parameters
----------
code : str
Cell content
"""
markdown_cell = {
"cell_type": "markdown",
"metadata": {},
"source": [rst2md(text)]
}
... | def add_markdown_cell(self, text):
"""Add a markdown cell to the notebook
Parameters
----------
code : str
Cell content
"""
markdown_cell = {
"cell_type": "markdown",
"metadata": {},
"source": [rst2md(text)]
}
... | [
"Add",
"a",
"markdown",
"cell",
"to",
"the",
"notebook"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/notebook.py#L105-L118 | [
"def",
"add_markdown_cell",
"(",
"self",
",",
"text",
")",
":",
"markdown_cell",
"=",
"{",
"\"cell_type\"",
":",
"\"markdown\"",
",",
"\"metadata\"",
":",
"{",
"}",
",",
"\"source\"",
":",
"[",
"rst2md",
"(",
"text",
")",
"]",
"}",
"self",
".",
"work_not... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | Notebook.save_file | Saves the notebook to a file | doc/sphinxext/sphinx_gallery/notebook.py | def save_file(self):
"""Saves the notebook to a file"""
with open(self.write_file, 'w') as out_nb:
json.dump(self.work_notebook, out_nb, indent=2) | def save_file(self):
"""Saves the notebook to a file"""
with open(self.write_file, 'w') as out_nb:
json.dump(self.work_notebook, out_nb, indent=2) | [
"Saves",
"the",
"notebook",
"to",
"a",
"file"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/notebook.py#L120-L123 | [
"def",
"save_file",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"write_file",
",",
"'w'",
")",
"as",
"out_nb",
":",
"json",
".",
"dump",
"(",
"self",
".",
"work_notebook",
",",
"out_nb",
",",
"indent",
"=",
"2",
")"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | arma2psd | r"""Computes power spectral density given ARMA values.
This function computes the power spectral density values
given the ARMA parameters of an ARMA model. It assumes that
the driving sequence is a white noise process of zero mean and
variance :math:`\rho_w`. The sampling frequency and noise variance a... | src/spectrum/arma.py | def arma2psd(A=None, B=None, rho=1., T=1., NFFT=4096, sides='default',
norm=False):
r"""Computes power spectral density given ARMA values.
This function computes the power spectral density values
given the ARMA parameters of an ARMA model. It assumes that
the driving sequence is a white noise p... | def arma2psd(A=None, B=None, rho=1., T=1., NFFT=4096, sides='default',
norm=False):
r"""Computes power spectral density given ARMA values.
This function computes the power spectral density values
given the ARMA parameters of an ARMA model. It assumes that
the driving sequence is a white noise p... | [
"r",
"Computes",
"power",
"spectral",
"density",
"given",
"ARMA",
"values",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/arma.py#L30-L127 | [
"def",
"arma2psd",
"(",
"A",
"=",
"None",
",",
"B",
"=",
"None",
",",
"rho",
"=",
"1.",
",",
"T",
"=",
"1.",
",",
"NFFT",
"=",
"4096",
",",
"sides",
"=",
"'default'",
",",
"norm",
"=",
"False",
")",
":",
"if",
"NFFT",
"is",
"None",
":",
"NFFT... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | arma_estimate | Autoregressive and moving average estimators.
This function provides an estimate of the autoregressive
parameters, the moving average parameters, and the driving
white noise variance of an ARMA(P,Q) for a complex or real data sequence.
The parameters are estimated using three steps:
* Estima... | src/spectrum/arma.py | def arma_estimate(X, P, Q, lag):
"""Autoregressive and moving average estimators.
This function provides an estimate of the autoregressive
parameters, the moving average parameters, and the driving
white noise variance of an ARMA(P,Q) for a complex or real data sequence.
The parameters are estima... | def arma_estimate(X, P, Q, lag):
"""Autoregressive and moving average estimators.
This function provides an estimate of the autoregressive
parameters, the moving average parameters, and the driving
white noise variance of an ARMA(P,Q) for a complex or real data sequence.
The parameters are estima... | [
"Autoregressive",
"and",
"moving",
"average",
"estimators",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/arma.py#L130-L221 | [
"def",
"arma_estimate",
"(",
"X",
",",
"P",
",",
"Q",
",",
"lag",
")",
":",
"R",
"=",
"CORRELATION",
"(",
"X",
",",
"maxlags",
"=",
"lag",
",",
"norm",
"=",
"'unbiased'",
")",
"R0",
"=",
"R",
"[",
"0",
"]",
"#C Estimate the AR parameters (no error we... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | ma | Moving average estimator.
This program provides an estimate of the moving average parameters
and driving noise variance for a data sequence based on a
long AR model and a least squares fit.
:param array X: The input data array
:param int Q: Desired MA model order (must be >0 and <M)
:param int... | src/spectrum/arma.py | def ma(X, Q, M):
"""Moving average estimator.
This program provides an estimate of the moving average parameters
and driving noise variance for a data sequence based on a
long AR model and a least squares fit.
:param array X: The input data array
:param int Q: Desired MA model order (must be >... | def ma(X, Q, M):
"""Moving average estimator.
This program provides an estimate of the moving average parameters
and driving noise variance for a data sequence based on a
long AR model and a least squares fit.
:param array X: The input data array
:param int Q: Desired MA model order (must be >... | [
"Moving",
"average",
"estimator",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/arma.py#L344-L388 | [
"def",
"ma",
"(",
"X",
",",
"Q",
",",
"M",
")",
":",
"if",
"Q",
"<=",
"0",
"or",
"Q",
">=",
"M",
":",
"raise",
"ValueError",
"(",
"'Q(MA) must be in ]0,lag['",
")",
"#C Fit a high-order AR to the data",
"a",
",",
"rho",
",",
"_c",
"=",
"yulewalker",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | CORRELOGRAMPSD | PSD estimate using correlogram method.
:param array X: complex or real data samples X(1) to X(N)
:param array Y: complex data samples Y(1) to Y(N). If provided, computes
the cross PSD, otherwise the PSD is returned
:param int lag: highest lag index to compute. Must be less than N
:param str wi... | src/spectrum/correlog.py | def CORRELOGRAMPSD(X, Y=None, lag=-1, window='hamming',
norm='unbiased', NFFT=4096, window_params={},
correlation_method='xcorr'):
"""PSD estimate using correlogram method.
:param array X: complex or real data samples X(1) to X(N)
:param array Y: complex data sample... | def CORRELOGRAMPSD(X, Y=None, lag=-1, window='hamming',
norm='unbiased', NFFT=4096, window_params={},
correlation_method='xcorr'):
"""PSD estimate using correlogram method.
:param array X: complex or real data samples X(1) to X(N)
:param array Y: complex data sample... | [
"PSD",
"estimate",
"using",
"correlogram",
"method",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/correlog.py#L24-L145 | [
"def",
"CORRELOGRAMPSD",
"(",
"X",
",",
"Y",
"=",
"None",
",",
"lag",
"=",
"-",
"1",
",",
"window",
"=",
"'hamming'",
",",
"norm",
"=",
"'unbiased'",
",",
"NFFT",
"=",
"4096",
",",
"window_params",
"=",
"{",
"}",
",",
"correlation_method",
"=",
"'xco... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _get_data | Helper function to get data over http or from a local file | doc/sphinxext/sphinx_gallery/docs_resolv.py | def _get_data(url):
"""Helper function to get data over http or from a local file"""
if url.startswith('http://'):
# Try Python 2, use Python 3 on exception
try:
resp = urllib.urlopen(url)
encoding = resp.headers.dict.get('content-encoding', 'plain')
except Attrib... | def _get_data(url):
"""Helper function to get data over http or from a local file"""
if url.startswith('http://'):
# Try Python 2, use Python 3 on exception
try:
resp = urllib.urlopen(url)
encoding = resp.headers.dict.get('content-encoding', 'plain')
except Attrib... | [
"Helper",
"function",
"to",
"get",
"data",
"over",
"http",
"or",
"from",
"a",
"local",
"file"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/docs_resolv.py#L29-L51 | [
"def",
"_get_data",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"'http://'",
")",
":",
"# Try Python 2, use Python 3 on exception",
"try",
":",
"resp",
"=",
"urllib",
".",
"urlopen",
"(",
"url",
")",
"encoding",
"=",
"resp",
".",
"headers",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _select_block | Select first block delimited by start_tag and end_tag | doc/sphinxext/sphinx_gallery/docs_resolv.py | def _select_block(str_in, start_tag, end_tag):
"""Select first block delimited by start_tag and end_tag"""
start_pos = str_in.find(start_tag)
if start_pos < 0:
raise ValueError('start_tag not found')
depth = 0
for pos in range(start_pos, len(str_in)):
if str_in[pos] == start_tag:
... | def _select_block(str_in, start_tag, end_tag):
"""Select first block delimited by start_tag and end_tag"""
start_pos = str_in.find(start_tag)
if start_pos < 0:
raise ValueError('start_tag not found')
depth = 0
for pos in range(start_pos, len(str_in)):
if str_in[pos] == start_tag:
... | [
"Select",
"first",
"block",
"delimited",
"by",
"start_tag",
"and",
"end_tag"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/docs_resolv.py#L73-L88 | [
"def",
"_select_block",
"(",
"str_in",
",",
"start_tag",
",",
"end_tag",
")",
":",
"start_pos",
"=",
"str_in",
".",
"find",
"(",
"start_tag",
")",
"if",
"start_pos",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'start_tag not found'",
")",
"depth",
"=",
"0"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _parse_dict_recursive | Parse a dictionary from the search index | doc/sphinxext/sphinx_gallery/docs_resolv.py | def _parse_dict_recursive(dict_str):
"""Parse a dictionary from the search index"""
dict_out = dict()
pos_last = 0
pos = dict_str.find(':')
while pos >= 0:
key = dict_str[pos_last:pos]
if dict_str[pos + 1] == '[':
# value is a list
pos_tmp = dict_str.find(']',... | def _parse_dict_recursive(dict_str):
"""Parse a dictionary from the search index"""
dict_out = dict()
pos_last = 0
pos = dict_str.find(':')
while pos >= 0:
key = dict_str[pos_last:pos]
if dict_str[pos + 1] == '[':
# value is a list
pos_tmp = dict_str.find(']',... | [
"Parse",
"a",
"dictionary",
"from",
"the",
"search",
"index"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/docs_resolv.py#L91-L128 | [
"def",
"_parse_dict_recursive",
"(",
"dict_str",
")",
":",
"dict_out",
"=",
"dict",
"(",
")",
"pos_last",
"=",
"0",
"pos",
"=",
"dict_str",
".",
"find",
"(",
"':'",
")",
"while",
"pos",
">=",
"0",
":",
"key",
"=",
"dict_str",
"[",
"pos_last",
":",
"p... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | parse_sphinx_searchindex | Parse a Sphinx search index
Parameters
----------
searchindex : str
The Sphinx search index (contents of searchindex.js)
Returns
-------
filenames : list of str
The file names parsed from the search index.
objects : dict
The objects parsed from the search index. | doc/sphinxext/sphinx_gallery/docs_resolv.py | def parse_sphinx_searchindex(searchindex):
"""Parse a Sphinx search index
Parameters
----------
searchindex : str
The Sphinx search index (contents of searchindex.js)
Returns
-------
filenames : list of str
The file names parsed from the search index.
objects : dict
... | def parse_sphinx_searchindex(searchindex):
"""Parse a Sphinx search index
Parameters
----------
searchindex : str
The Sphinx search index (contents of searchindex.js)
Returns
-------
filenames : list of str
The file names parsed from the search index.
objects : dict
... | [
"Parse",
"a",
"Sphinx",
"search",
"index"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/docs_resolv.py#L131-L168 | [
"def",
"parse_sphinx_searchindex",
"(",
"searchindex",
")",
":",
"# Make sure searchindex uses UTF-8 encoding",
"if",
"hasattr",
"(",
"searchindex",
",",
"'decode'",
")",
":",
"searchindex",
"=",
"searchindex",
".",
"decode",
"(",
"'UTF-8'",
")",
"# parse objects",
"q... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | embed_code_links | Embed hyperlinks to documentation into example code | doc/sphinxext/sphinx_gallery/docs_resolv.py | def embed_code_links(app, exception):
"""Embed hyperlinks to documentation into example code"""
if exception is not None:
return
# No need to waste time embedding hyperlinks when not running the examples
# XXX: also at the time of writing this fixes make html-noplot
# for some reason I don'... | def embed_code_links(app, exception):
"""Embed hyperlinks to documentation into example code"""
if exception is not None:
return
# No need to waste time embedding hyperlinks when not running the examples
# XXX: also at the time of writing this fixes make html-noplot
# for some reason I don'... | [
"Embed",
"hyperlinks",
"to",
"documentation",
"into",
"example",
"code"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/docs_resolv.py#L408-L436 | [
"def",
"embed_code_links",
"(",
"app",
",",
"exception",
")",
":",
"if",
"exception",
"is",
"not",
"None",
":",
"return",
"# No need to waste time embedding hyperlinks when not running the examples",
"# XXX: also at the time of writing this fixes make html-noplot",
"# for some reas... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | SphinxDocLinkResolver._get_link | Get a valid link, False if not found | doc/sphinxext/sphinx_gallery/docs_resolv.py | def _get_link(self, cobj):
"""Get a valid link, False if not found"""
fname_idx = None
full_name = cobj['module_short'] + '.' + cobj['name']
if full_name in self._searchindex['objects']:
value = self._searchindex['objects'][full_name]
if isinstance(value, dict):
... | def _get_link(self, cobj):
"""Get a valid link, False if not found"""
fname_idx = None
full_name = cobj['module_short'] + '.' + cobj['name']
if full_name in self._searchindex['objects']:
value = self._searchindex['objects'][full_name]
if isinstance(value, dict):
... | [
"Get",
"a",
"valid",
"link",
"False",
"if",
"not",
"found"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/docs_resolv.py#L219-L272 | [
"def",
"_get_link",
"(",
"self",
",",
"cobj",
")",
":",
"fname_idx",
"=",
"None",
"full_name",
"=",
"cobj",
"[",
"'module_short'",
"]",
"+",
"'.'",
"+",
"cobj",
"[",
"'name'",
"]",
"if",
"full_name",
"in",
"self",
".",
"_searchindex",
"[",
"'objects'",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | create_all_psd | #ARMA 15 order
a, b, rho = spectrum.arma_estimate(data, 15,15, 30)
psd = spectrum.arma2psd(A=a,B=b, rho=rho)
newpsd = tools.cshift(psd, len(psd)//2) # switch positive and negative freq
pylab.plot(f, 10 * pylab.log10(newpsd/max(newpsd)), label='ARMA 15,15') | examples/plot_allpsd.py | def create_all_psd():
f = pylab.linspace(0, 1, 4096)
pylab.figure(figsize=(12,8))
# MA model
p = spectrum.pma(xx, 64,128); p(); p.plot()
"""
#ARMA 15 order
a, b, rho = spectrum.arma_estimate(data, 15,15, 30)
psd = spectrum.arma2psd(A=a,B=b, rho=rho)
newpsd = tools.cshift(psd, len(... | def create_all_psd():
f = pylab.linspace(0, 1, 4096)
pylab.figure(figsize=(12,8))
# MA model
p = spectrum.pma(xx, 64,128); p(); p.plot()
"""
#ARMA 15 order
a, b, rho = spectrum.arma_estimate(data, 15,15, 30)
psd = spectrum.arma2psd(A=a,B=b, rho=rho)
newpsd = tools.cshift(psd, len(... | [
"#ARMA",
"15",
"order",
"a",
"b",
"rho",
"=",
"spectrum",
".",
"arma_estimate",
"(",
"data",
"15",
"15",
"30",
")",
"psd",
"=",
"spectrum",
".",
"arma2psd",
"(",
"A",
"=",
"a",
"B",
"=",
"b",
"rho",
"=",
"rho",
")",
"newpsd",
"=",
"tools",
".",
... | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/examples/plot_allpsd.py#L29-L78 | [
"def",
"create_all_psd",
"(",
")",
":",
"f",
"=",
"pylab",
".",
"linspace",
"(",
"0",
",",
"1",
",",
"4096",
")",
"pylab",
".",
"figure",
"(",
"figsize",
"=",
"(",
"12",
",",
"8",
")",
")",
"# MA model",
"p",
"=",
"spectrum",
".",
"pma",
"(",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | tf2zp | Convert transfer function filter parameters to zero-pole-gain form
Find the zeros, poles, and gains of this continuous-time system:
.. warning:: b and a must have the same length.
::
from spectrum import tf2zp
b = [2,3,0]
a = [1, 0.4, 1]
[z,p,k] = tf2zp(b,a) ... | src/spectrum/transfer.py | def tf2zp(b,a):
"""Convert transfer function filter parameters to zero-pole-gain form
Find the zeros, poles, and gains of this continuous-time system:
.. warning:: b and a must have the same length.
::
from spectrum import tf2zp
b = [2,3,0]
a = [1, 0.4, 1]
[z,p,k... | def tf2zp(b,a):
"""Convert transfer function filter parameters to zero-pole-gain form
Find the zeros, poles, and gains of this continuous-time system:
.. warning:: b and a must have the same length.
::
from spectrum import tf2zp
b = [2,3,0]
a = [1, 0.4, 1]
[z,p,k... | [
"Convert",
"transfer",
"function",
"filter",
"parameters",
"to",
"zero",
"-",
"pole",
"-",
"gain",
"form"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/transfer.py#L29-L75 | [
"def",
"tf2zp",
"(",
"b",
",",
"a",
")",
":",
"from",
"numpy",
"import",
"roots",
"assert",
"len",
"(",
"b",
")",
"==",
"len",
"(",
"a",
")",
",",
"\"length of the vectors a and b must be identical. fill with zeros if needed.\"",
"g",
"=",
"b",
"[",
"0",
"]"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | eqtflength | Given two list or arrays, pad with zeros the shortest array
:param b: list or array
:param a: list or array
.. doctest::
>>> from spectrum.transfer import eqtflength
>>> a = [1,2]
>>> b = [1,2,3,4]
>>> a, b, = eqtflength(a,b) | src/spectrum/transfer.py | def eqtflength(b,a):
"""Given two list or arrays, pad with zeros the shortest array
:param b: list or array
:param a: list or array
.. doctest::
>>> from spectrum.transfer import eqtflength
>>> a = [1,2]
>>> b = [1,2,3,4]
>>> a, b, = eqtflength(a,b)
"""
d = a... | def eqtflength(b,a):
"""Given two list or arrays, pad with zeros the shortest array
:param b: list or array
:param a: list or array
.. doctest::
>>> from spectrum.transfer import eqtflength
>>> a = [1,2]
>>> b = [1,2,3,4]
>>> a, b, = eqtflength(a,b)
"""
d = a... | [
"Given",
"two",
"list",
"or",
"arrays",
"pad",
"with",
"zeros",
"the",
"shortest",
"array"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/transfer.py#L83-L112 | [
"def",
"eqtflength",
"(",
"b",
",",
"a",
")",
":",
"d",
"=",
"abs",
"(",
"len",
"(",
"b",
")",
"-",
"len",
"(",
"a",
")",
")",
"if",
"d",
"!=",
"0",
":",
"if",
"len",
"(",
"a",
")",
">",
"len",
"(",
"b",
")",
":",
"try",
":",
"b",
"."... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | tf2zpk | Return zero, pole, gain (z,p,k) representation from a numerator,
denominator representation of a linear filter.
Convert zero-pole-gain filter parameters to transfer function form
:param ndarray b: numerator polynomial.
:param ndarray a: numerator and denominator polynomials.
:return:
* z... | src/spectrum/transfer.py | def tf2zpk(b, a):
"""Return zero, pole, gain (z,p,k) representation from a numerator,
denominator representation of a linear filter.
Convert zero-pole-gain filter parameters to transfer function form
:param ndarray b: numerator polynomial.
:param ndarray a: numerator and denominator polynomials.
... | def tf2zpk(b, a):
"""Return zero, pole, gain (z,p,k) representation from a numerator,
denominator representation of a linear filter.
Convert zero-pole-gain filter parameters to transfer function form
:param ndarray b: numerator polynomial.
:param ndarray a: numerator and denominator polynomials.
... | [
"Return",
"zero",
"pole",
"gain",
"(",
"z",
"p",
"k",
")",
"representation",
"from",
"a",
"numerator",
"denominator",
"representation",
"of",
"a",
"linear",
"filter",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/transfer.py#L146-L175 | [
"def",
"tf2zpk",
"(",
"b",
",",
"a",
")",
":",
"import",
"scipy",
".",
"signal",
"z",
",",
"p",
",",
"k",
"=",
"scipy",
".",
"signal",
".",
"tf2zpk",
"(",
"b",
",",
"a",
")",
"return",
"z",
",",
"p",
",",
"k"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | ss2zpk | State-space representation to zero-pole-gain representation.
:param A: ndarray State-space representation of linear system.
:param B: ndarray State-space representation of linear system.
:param C: ndarray State-space representation of linear system.
:param D: ndarray State-space representation of linea... | src/spectrum/transfer.py | def ss2zpk(a,b,c,d, input=0):
"""State-space representation to zero-pole-gain representation.
:param A: ndarray State-space representation of linear system.
:param B: ndarray State-space representation of linear system.
:param C: ndarray State-space representation of linear system.
:param D: ndarra... | def ss2zpk(a,b,c,d, input=0):
"""State-space representation to zero-pole-gain representation.
:param A: ndarray State-space representation of linear system.
:param B: ndarray State-space representation of linear system.
:param C: ndarray State-space representation of linear system.
:param D: ndarra... | [
"State",
"-",
"space",
"representation",
"to",
"zero",
"-",
"pole",
"-",
"gain",
"representation",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/transfer.py#L178-L195 | [
"def",
"ss2zpk",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"input",
"=",
"0",
")",
":",
"import",
"scipy",
".",
"signal",
"z",
",",
"p",
",",
"k",
"=",
"scipy",
".",
"signal",
".",
"ss2zpk",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | zpk2tf | r"""Return polynomial transfer function representation from zeros and poles
:param ndarray z: Zeros of the transfer function.
:param ndarray p: Poles of the transfer function.
:param float k: System gain.
:return:
b : ndarray Numerator polynomial.
a : ndarray Numerator and denominator ... | src/spectrum/transfer.py | def zpk2tf(z, p, k):
r"""Return polynomial transfer function representation from zeros and poles
:param ndarray z: Zeros of the transfer function.
:param ndarray p: Poles of the transfer function.
:param float k: System gain.
:return:
b : ndarray Numerator polynomial.
a : ndarray N... | def zpk2tf(z, p, k):
r"""Return polynomial transfer function representation from zeros and poles
:param ndarray z: Zeros of the transfer function.
:param ndarray p: Poles of the transfer function.
:param float k: System gain.
:return:
b : ndarray Numerator polynomial.
a : ndarray N... | [
"r",
"Return",
"polynomial",
"transfer",
"function",
"representation",
"from",
"zeros",
"and",
"poles"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/transfer.py#L198-L234 | [
"def",
"zpk2tf",
"(",
"z",
",",
"p",
",",
"k",
")",
":",
"import",
"scipy",
".",
"signal",
"b",
",",
"a",
"=",
"scipy",
".",
"signal",
".",
"zpk2tf",
"(",
"z",
",",
"p",
",",
"k",
")",
"return",
"b",
",",
"a"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | zpk2ss | Zero-pole-gain representation to state-space representation
:param sequence z,p: Zeros and poles.
:param float k: System gain.
:return:
* A, B, C, D : ndarray State-space matrices.
.. note:: wrapper of scipy function zpk2ss | src/spectrum/transfer.py | def zpk2ss(z, p, k):
"""Zero-pole-gain representation to state-space representation
:param sequence z,p: Zeros and poles.
:param float k: System gain.
:return:
* A, B, C, D : ndarray State-space matrices.
.. note:: wrapper of scipy function zpk2ss
"""
import scipy.signal
retur... | def zpk2ss(z, p, k):
"""Zero-pole-gain representation to state-space representation
:param sequence z,p: Zeros and poles.
:param float k: System gain.
:return:
* A, B, C, D : ndarray State-space matrices.
.. note:: wrapper of scipy function zpk2ss
"""
import scipy.signal
retur... | [
"Zero",
"-",
"pole",
"-",
"gain",
"representation",
"to",
"state",
"-",
"space",
"representation"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/transfer.py#L237-L249 | [
"def",
"zpk2ss",
"(",
"z",
",",
"p",
",",
"k",
")",
":",
"import",
"scipy",
".",
"signal",
"return",
"scipy",
".",
"signal",
".",
"zpk2ss",
"(",
"z",
",",
"p",
",",
"k",
")"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | create_window | r"""Returns the N-point window given a valid name
:param int N: window size
:param str name: window name (default is *rectangular*). Valid names
are stored in :func:`~spectrum.window.window_names`.
:param kargs: optional arguments are:
* *beta*: argument of the :func:`window_kaiser` functi... | src/spectrum/window.py | def create_window(N, name=None, **kargs):
r"""Returns the N-point window given a valid name
:param int N: window size
:param str name: window name (default is *rectangular*). Valid names
are stored in :func:`~spectrum.window.window_names`.
:param kargs: optional arguments are:
* *beta*... | def create_window(N, name=None, **kargs):
r"""Returns the N-point window given a valid name
:param int N: window size
:param str name: window name (default is *rectangular*). Valid names
are stored in :func:`~spectrum.window.window_names`.
:param kargs: optional arguments are:
* *beta*... | [
"r",
"Returns",
"the",
"N",
"-",
"point",
"window",
"given",
"a",
"valid",
"name"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L330-L461 | [
"def",
"create_window",
"(",
"N",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"'rectangle'",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"assert",
"name",
"in",
"list",
"(",
"window_nam... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | enbw | r"""Computes the equivalent noise bandwidth
.. math:: ENBW = N \frac{\sum_{n=1}^{N} w_n^2}{\left(\sum_{n=1}^{N} w_n \right)^2}
.. doctest::
>>> from spectrum import create_window, enbw
>>> w = create_window(64, 'rectangular')
>>> enbw(w)
1.0
The following table contains t... | src/spectrum/window.py | def enbw(data):
r"""Computes the equivalent noise bandwidth
.. math:: ENBW = N \frac{\sum_{n=1}^{N} w_n^2}{\left(\sum_{n=1}^{N} w_n \right)^2}
.. doctest::
>>> from spectrum import create_window, enbw
>>> w = create_window(64, 'rectangular')
>>> enbw(w)
1.0
The follow... | def enbw(data):
r"""Computes the equivalent noise bandwidth
.. math:: ENBW = N \frac{\sum_{n=1}^{N} w_n^2}{\left(\sum_{n=1}^{N} w_n \right)^2}
.. doctest::
>>> from spectrum import create_window, enbw
>>> w = create_window(64, 'rectangular')
>>> enbw(w)
1.0
The follow... | [
"r",
"Computes",
"the",
"equivalent",
"noise",
"bandwidth"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L464-L506 | [
"def",
"enbw",
"(",
"data",
")",
":",
"N",
"=",
"len",
"(",
"data",
")",
"return",
"N",
"*",
"np",
".",
"sum",
"(",
"data",
"**",
"2",
")",
"/",
"np",
".",
"sum",
"(",
"data",
")",
"**",
"2"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | _kaiser | Independant Kaiser window
For the definition of the Kaiser window, see A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".
The continuous version of width n centered about x=0 is:
.. note:: 2 times slower than scipy.kaiser | src/spectrum/window.py | def _kaiser(n, beta):
"""Independant Kaiser window
For the definition of the Kaiser window, see A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".
The continuous version of width n centered about x=0 is:
.. note:: 2 times slower than scipy.kaiser
"""
from scipy.special import... | def _kaiser(n, beta):
"""Independant Kaiser window
For the definition of the Kaiser window, see A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".
The continuous version of width n centered about x=0 is:
.. note:: 2 times slower than scipy.kaiser
"""
from scipy.special import... | [
"Independant",
"Kaiser",
"window"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L509-L523 | [
"def",
"_kaiser",
"(",
"n",
",",
"beta",
")",
":",
"from",
"scipy",
".",
"special",
"import",
"iv",
"as",
"besselI",
"m",
"=",
"n",
"-",
"1",
"k",
"=",
"arange",
"(",
"0",
",",
"m",
")",
"k",
"=",
"2.",
"*",
"beta",
"/",
"m",
"*",
"sqrt",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_visu | A Window visualisation tool
:param N: length of the window
:param name: name of the window
:param NFFT: padding used by the FFT
:param mindB: the minimum frequency power in dB
:param maxdB: the maximum frequency power in dB
:param kargs: optional arguments passed to :func:`create_window`
T... | src/spectrum/window.py | def window_visu(N=51, name='hamming', **kargs):
"""A Window visualisation tool
:param N: length of the window
:param name: name of the window
:param NFFT: padding used by the FFT
:param mindB: the minimum frequency power in dB
:param maxdB: the maximum frequency power in dB
:param kargs: op... | def window_visu(N=51, name='hamming', **kargs):
"""A Window visualisation tool
:param N: length of the window
:param name: name of the window
:param NFFT: padding used by the FFT
:param mindB: the minimum frequency power in dB
:param maxdB: the maximum frequency power in dB
:param kargs: op... | [
"A",
"Window",
"visualisation",
"tool"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L526-L555 | [
"def",
"window_visu",
"(",
"N",
"=",
"51",
",",
"name",
"=",
"'hamming'",
",",
"*",
"*",
"kargs",
")",
":",
"# get the default parameters",
"mindB",
"=",
"kargs",
".",
"pop",
"(",
"'mindB'",
",",
"-",
"100",
")",
"maxdB",
"=",
"kargs",
".",
"pop",
"(... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_kaiser | r"""Kaiser window
:param N: window length
:param beta: kaiser parameter (default is 8.6)
To obtain a Kaiser window that designs an FIR filter with
sidelobe attenuation of :math:`\alpha` dB, use the following :math:`\beta` where
:math:`\beta = \pi \alpha`.
.. math::
w_n = \frac{I_0\le... | src/spectrum/window.py | def window_kaiser(N, beta=8.6, method='numpy'):
r"""Kaiser window
:param N: window length
:param beta: kaiser parameter (default is 8.6)
To obtain a Kaiser window that designs an FIR filter with
sidelobe attenuation of :math:`\alpha` dB, use the following :math:`\beta` where
:math:`\beta = \pi... | def window_kaiser(N, beta=8.6, method='numpy'):
r"""Kaiser window
:param N: window length
:param beta: kaiser parameter (default is 8.6)
To obtain a Kaiser window that designs an FIR filter with
sidelobe attenuation of :math:`\alpha` dB, use the following :math:`\beta` where
:math:`\beta = \pi... | [
"r",
"Kaiser",
"window"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L574-L635 | [
"def",
"window_kaiser",
"(",
"N",
",",
"beta",
"=",
"8.6",
",",
"method",
"=",
"'numpy'",
")",
":",
"if",
"N",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
")",
"if",
"method",
"==",
"'numpy'",
":",
"from",
"numpy",
"import",
"kaiser",
"return",
"ka... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_blackman | r"""Blackman window
:param N: window length
.. math:: a_0 - a_1 \cos(\frac{2\pi n}{N-1}) +a_2 \cos(\frac{4\pi n }{N-1})
with
.. math::
a_0 = (1-\alpha)/2, a_1=0.5, a_2=\alpha/2 \rm{\;and\; \alpha}=0.16
When :math:`\alpha=0.16`, this is the unqualified Blackman window with
:math:`a_... | src/spectrum/window.py | def window_blackman(N, alpha=0.16):
r"""Blackman window
:param N: window length
.. math:: a_0 - a_1 \cos(\frac{2\pi n}{N-1}) +a_2 \cos(\frac{4\pi n }{N-1})
with
.. math::
a_0 = (1-\alpha)/2, a_1=0.5, a_2=\alpha/2 \rm{\;and\; \alpha}=0.16
When :math:`\alpha=0.16`, this is the unqual... | def window_blackman(N, alpha=0.16):
r"""Blackman window
:param N: window length
.. math:: a_0 - a_1 \cos(\frac{2\pi n}{N-1}) +a_2 \cos(\frac{4\pi n }{N-1})
with
.. math::
a_0 = (1-\alpha)/2, a_1=0.5, a_2=\alpha/2 \rm{\;and\; \alpha}=0.16
When :math:`\alpha=0.16`, this is the unqual... | [
"r",
"Blackman",
"window"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L638-L676 | [
"def",
"window_blackman",
"(",
"N",
",",
"alpha",
"=",
"0.16",
")",
":",
"a0",
"=",
"(",
"1.",
"-",
"alpha",
")",
"/",
"2.",
"a1",
"=",
"0.5",
"a2",
"=",
"alpha",
"/",
"2.",
"if",
"(",
"N",
"==",
"1",
")",
":",
"win",
"=",
"array",
"(",
"["... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_gaussian | r"""Gaussian window
:param N: window length
.. math:: \exp^{-0.5 \left( \sigma\frac{n}{N/2} \right)^2}
with :math:`\frac{N-1}{2}\leq n \leq \frac{N-1}{2}`.
.. note:: N-1 is used to be in agreement with octave convention. The ENBW of
1.4 is also in agreement with [Harris]_
.. plot::
... | src/spectrum/window.py | def window_gaussian(N, alpha=2.5):
r"""Gaussian window
:param N: window length
.. math:: \exp^{-0.5 \left( \sigma\frac{n}{N/2} \right)^2}
with :math:`\frac{N-1}{2}\leq n \leq \frac{N-1}{2}`.
.. note:: N-1 is used to be in agreement with octave convention. The ENBW of
1.4 is also in agre... | def window_gaussian(N, alpha=2.5):
r"""Gaussian window
:param N: window length
.. math:: \exp^{-0.5 \left( \sigma\frac{n}{N/2} \right)^2}
with :math:`\frac{N-1}{2}\leq n \leq \frac{N-1}{2}`.
.. note:: N-1 is used to be in agreement with octave convention. The ENBW of
1.4 is also in agre... | [
"r",
"Gaussian",
"window"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L755-L781 | [
"def",
"window_gaussian",
"(",
"N",
",",
"alpha",
"=",
"2.5",
")",
":",
"t",
"=",
"linspace",
"(",
"-",
"(",
"N",
"-",
"1",
")",
"/",
"2.",
",",
"(",
"N",
"-",
"1",
")",
"/",
"2.",
",",
"N",
")",
"#t = linspace(-(N)/2., (N)/2., N)",
"w",
"=",
"... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_chebwin | Cheb window
:param N: window length
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'chebwin', attenuation=50)
.. seealso:: scipy.signal.chebwin, :func:`create_window`, :class:`Window` | src/spectrum/window.py | def window_chebwin(N, attenuation=50):
"""Cheb window
:param N: window length
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'chebwin', attenuation=50)
.. seealso:: scipy.signal.chebwin, :func:`create_window`, :class:`Window`
... | def window_chebwin(N, attenuation=50):
"""Cheb window
:param N: window length
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'chebwin', attenuation=50)
.. seealso:: scipy.signal.chebwin, :func:`create_window`, :class:`Window`
... | [
"Cheb",
"window"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L784-L799 | [
"def",
"window_chebwin",
"(",
"N",
",",
"attenuation",
"=",
"50",
")",
":",
"import",
"scipy",
".",
"signal",
"return",
"scipy",
".",
"signal",
".",
"chebwin",
"(",
"N",
",",
"attenuation",
")"
] | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_cosine | r"""Cosine tapering window also known as sine window.
:param N: window length
.. math:: w(n) = \cos\left(\frac{\pi n}{N-1} - \frac{\pi}{2}\right) = \sin \left(\frac{\pi n}{N-1}\right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, ... | src/spectrum/window.py | def window_cosine(N):
r"""Cosine tapering window also known as sine window.
:param N: window length
.. math:: w(n) = \cos\left(\frac{\pi n}{N-1} - \frac{\pi}{2}\right) = \sin \left(\frac{\pi n}{N-1}\right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_vis... | def window_cosine(N):
r"""Cosine tapering window also known as sine window.
:param N: window length
.. math:: w(n) = \cos\left(\frac{\pi n}{N-1} - \frac{\pi}{2}\right) = \sin \left(\frac{\pi n}{N-1}\right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_vis... | [
"r",
"Cosine",
"tapering",
"window",
"also",
"known",
"as",
"sine",
"window",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L802-L822 | [
"def",
"window_cosine",
"(",
"N",
")",
":",
"if",
"N",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
")",
"n",
"=",
"arange",
"(",
"0",
",",
"N",
")",
"win",
"=",
"sin",
"(",
"pi",
"*",
"n",
"/",
"(",
"N",
"-",
"1.",
")",
")",
"return",
"wi... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_lanczos | r"""Lanczos window also known as sinc window.
:param N: window length
.. math:: w(n) = sinc \left( \frac{2n}{N-1} - 1 \right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'lanczos')
.. seealso:: :func:`create_window`, :clas... | src/spectrum/window.py | def window_lanczos(N):
r"""Lanczos window also known as sinc window.
:param N: window length
.. math:: w(n) = sinc \left( \frac{2n}{N-1} - 1 \right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'lanczos')
.. seealso:: :... | def window_lanczos(N):
r"""Lanczos window also known as sinc window.
:param N: window length
.. math:: w(n) = sinc \left( \frac{2n}{N-1} - 1 \right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'lanczos')
.. seealso:: :... | [
"r",
"Lanczos",
"window",
"also",
"known",
"as",
"sinc",
"window",
"."
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L824-L845 | [
"def",
"window_lanczos",
"(",
"N",
")",
":",
"if",
"N",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
")",
"n",
"=",
"linspace",
"(",
"-",
"N",
"/",
"2.",
",",
"N",
"/",
"2.",
",",
"N",
")",
"win",
"=",
"sinc",
"(",
"2",
"*",
"n",
"/",
"(",... | bad6c32e3f10e185098748f67bb421b378b06afe |
valid | window_bartlett_hann | r"""Bartlett-Hann window
:param N: window length
.. math:: w(n) = a_0 + a_1 \left| \frac{n}{N-1} -\frac{1}{2}\right| - a_2 \cos \left( \frac{2\pi n}{N-1} \right)
with :math:`a_0 = 0.62`, :math:`a_1 = 0.48` and :math:`a_2=0.38`
.. plot::
:width: 80%
:include-source:
from spec... | src/spectrum/window.py | def window_bartlett_hann(N):
r"""Bartlett-Hann window
:param N: window length
.. math:: w(n) = a_0 + a_1 \left| \frac{n}{N-1} -\frac{1}{2}\right| - a_2 \cos \left( \frac{2\pi n}{N-1} \right)
with :math:`a_0 = 0.62`, :math:`a_1 = 0.48` and :math:`a_2=0.38`
.. plot::
:width: 80%
:i... | def window_bartlett_hann(N):
r"""Bartlett-Hann window
:param N: window length
.. math:: w(n) = a_0 + a_1 \left| \frac{n}{N-1} -\frac{1}{2}\right| - a_2 \cos \left( \frac{2\pi n}{N-1} \right)
with :math:`a_0 = 0.62`, :math:`a_1 = 0.48` and :math:`a_2=0.38`
.. plot::
:width: 80%
:i... | [
"r",
"Bartlett",
"-",
"Hann",
"window"
] | cokelaer/spectrum | python | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L848-L875 | [
"def",
"window_bartlett_hann",
"(",
"N",
")",
":",
"if",
"N",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
")",
"n",
"=",
"arange",
"(",
"0",
",",
"N",
")",
"a0",
"=",
"0.62",
"a1",
"=",
"0.48",
"a2",
"=",
"0.38",
"win",
"=",
"a0",
"-",
"a1",
... | bad6c32e3f10e185098748f67bb421b378b06afe |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.