本文整理汇总了Python中numpy.polynomial.polynomial.polyint方法的典型用法代码示例。如果您正苦于以下问题:Python polynomial.polyint方法的具体用法?Python polynomial.polyint怎么用?Python polynomial.polyint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.polynomial.polynomial
的用法示例。
在下文中一共展示了polynomial.polyint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_polyder
# 需要导入模块: from numpy.polynomial import polynomial [as 别名]
# 或者: from numpy.polynomial.polynomial import polyint [as 别名]
def test_polyder(self):
# check exceptions
assert_raises(ValueError, poly.polyder, [0], .5)
assert_raises(ValueError, poly.polyder, [0], -1)
# check that zeroth derivative does nothing
for i in range(5):
tgt = [0]*i + [1]
res = poly.polyder(tgt, m=0)
assert_equal(trim(res), trim(tgt))
# check that derivation is the inverse of integration
for i in range(5):
for j in range(2, 5):
tgt = [0]*i + [1]
res = poly.polyder(poly.polyint(tgt, m=j), m=j)
assert_almost_equal(trim(res), trim(tgt))
# check derivation with scaling
for i in range(5):
for j in range(2, 5):
tgt = [0]*i + [1]
res = poly.polyder(poly.polyint(tgt, m=j, scl=2), m=j, scl=.5)
assert_almost_equal(trim(res), trim(tgt))
示例2: test_polyder
# 需要导入模块: from numpy.polynomial import polynomial [as 别名]
# 或者: from numpy.polynomial.polynomial import polyint [as 别名]
def test_polyder(self):
# check exceptions
assert_raises(ValueError, poly.polyder, [0], .5)
assert_raises(ValueError, poly.polyder, [0], -1)
# check that zeroth deriviative does nothing
for i in range(5):
tgt = [0]*i + [1]
res = poly.polyder(tgt, m=0)
assert_equal(trim(res), trim(tgt))
# check that derivation is the inverse of integration
for i in range(5):
for j in range(2, 5):
tgt = [0]*i + [1]
res = poly.polyder(poly.polyint(tgt, m=j), m=j)
assert_almost_equal(trim(res), trim(tgt))
# check derivation with scaling
for i in range(5):
for j in range(2, 5):
tgt = [0]*i + [1]
res = poly.polyder(poly.polyint(tgt, m=j, scl=2), m=j, scl=.5)
assert_almost_equal(trim(res), trim(tgt))
示例3: test_polyder
# 需要导入模块: from numpy.polynomial import polynomial [as 别名]
# 或者: from numpy.polynomial.polynomial import polyint [as 别名]
def test_polyder(self) :
# check exceptions
assert_raises(ValueError, poly.polyder, [0], .5)
assert_raises(ValueError, poly.polyder, [0], -1)
# check that zeroth deriviative does nothing
for i in range(5) :
tgt = [0]*i + [1]
res = poly.polyder(tgt, m=0)
assert_equal(trim(res), trim(tgt))
# check that derivation is the inverse of integration
for i in range(5) :
for j in range(2, 5) :
tgt = [0]*i + [1]
res = poly.polyder(poly.polyint(tgt, m=j), m=j)
assert_almost_equal(trim(res), trim(tgt))
# check derivation with scaling
for i in range(5) :
for j in range(2, 5) :
tgt = [0]*i + [1]
res = poly.polyder(poly.polyint(tgt, m=j, scl=2), m=j, scl=.5)
assert_almost_equal(trim(res), trim(tgt))
示例4: test_polyint_axis
# 需要导入模块: from numpy.polynomial import polynomial [as 别名]
# 或者: from numpy.polynomial.polynomial import polyint [as 别名]
def test_polyint_axis(self):
# check that axis keyword works
c2d = np.random.random((3, 4))
tgt = np.vstack([poly.polyint(c) for c in c2d.T]).T
res = poly.polyint(c2d, axis=0)
assert_almost_equal(res, tgt)
tgt = np.vstack([poly.polyint(c) for c in c2d])
res = poly.polyint(c2d, axis=1)
assert_almost_equal(res, tgt)
tgt = np.vstack([poly.polyint(c, k=3) for c in c2d])
res = poly.polyint(c2d, k=3, axis=1)
assert_almost_equal(res, tgt)
示例5: deskewmem
# 需要导入模块: from numpy.polynomial import polynomial [as 别名]
# 或者: from numpy.polynomial.polynomial import polyint [as 别名]
def deskewmem(input_data, DeltaKCOAPoly, dim0_coords_m, dim1_coords_m, dim, fft_sgn=-1):
"""
Performs deskew (centering of the spectrum on zero frequency) on a complex dataset.
Parameters
----------
input_data : numpy.ndarray
Complex FFT Data
DeltaKCOAPoly : numpy.ndarray
Polynomial that describes center of frequency support of data.
dim0_coords_m : numpy.ndarray
dim1_coords_m : numpy.ndarray
dim : int
fft_sgn : int|float
Returns
-------
Tuple[numpy.ndarray, numpy.ndarray]
* `output_data` - Deskewed data
* `new_DeltaKCOAPoly` - Frequency support shift in the non-deskew dimension caused by the deskew.
"""
# Integrate DeltaKCOA polynomial (in meters) to form new polynomial DeltaKCOAPoly_int
DeltaKCOAPoly_int = polynomial.polyint(DeltaKCOAPoly, axis=dim)
# New DeltaKCOAPoly in other dimension will be negative of the derivative of
# DeltaKCOAPoly_int in other dimension (assuming it was zero before).
new_DeltaKCOAPoly = - polynomial.polyder(DeltaKCOAPoly_int, axis=dim-1)
# Apply phase adjustment from polynomial
dim1_coords_m_2d, dim0_coords_m_2d = np.meshgrid(dim1_coords_m, dim0_coords_m)
output_data = np.multiply(input_data, np.exp(1j * fft_sgn * 2 * np.pi *
polynomial.polyval2d(
dim0_coords_m_2d,
dim1_coords_m_2d,
DeltaKCOAPoly_int)))
return output_data, new_DeltaKCOAPoly
示例6: deskewmem
# 需要导入模块: from numpy.polynomial import polynomial [as 别名]
# 或者: from numpy.polynomial.polynomial import polyint [as 别名]
def deskewmem(input_data, DeltaKCOAPoly, dim0_coords_m, dim1_coords_m, dim, fft_sgn=-1):
"""Performs deskew (centering of the spectrum on zero frequency) on a complex dataset.
INPUTS:
input_data: Complex FFT Data
DeltaKCOAPoly: Polynomial that describes center of frequency support of data.
dim0_coords_m: Coordinate of each "row" in dimension 0
dim1_coords_m: Coordinate of each "column" in dimension 1
dim: Dimension over which to perform deskew
fft_sgn: FFT sign required to transform data to spatial frequency domain
OUTPUTS:
output_data: Deskewed data
new_DeltaKCOAPoly: Frequency support shift in the non-deskew dimension
caused by the deskew.
"""
# Integrate DeltaKCOA polynomial (in meters) to form new polynomial DeltaKCOAPoly_int
DeltaKCOAPoly_int = polynomial.polyint(DeltaKCOAPoly, axis=dim)
# New DeltaKCOAPoly in other dimension will be negative of the derivative of
# DeltaKCOAPoly_int in other dimension (assuming it was zero before).
new_DeltaKCOAPoly = - polynomial.polyder(DeltaKCOAPoly_int, axis=dim-1)
# Apply phase adjustment from polynomial
[dim1_coords_m_2d, dim0_coords_m_2d] = np.meshgrid(dim1_coords_m, dim0_coords_m)
output_data = np.multiply(input_data, np.exp(1j * fft_sgn * 2 * np.pi *
polynomial.polyval2d(
dim0_coords_m_2d,
dim1_coords_m_2d,
DeltaKCOAPoly_int)))
return output_data, new_DeltaKCOAPoly