本文整理汇总了Python中PyMca5.PyMcaMath.fitting.SpecfitFuns.slit方法的典型用法代码示例。如果您正苦于以下问题:Python SpecfitFuns.slit方法的具体用法?Python SpecfitFuns.slit怎么用?Python SpecfitFuns.slit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyMca5.PyMcaMath.fitting.SpecfitFuns
的用法示例。
在下文中一共展示了SpecfitFuns.slit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculateShiftsFFT
# 需要导入模块: from PyMca5.PyMcaMath.fitting import SpecfitFuns [as 别名]
# 或者: from PyMca5.PyMcaMath.fitting.SpecfitFuns import slit [as 别名]
def calculateShiftsFFT(self, stack, reference, offsets=None, widths=None, crop=False):
if DEBUG:
print("Offsets = ", offsets)
print("Widths = ", widths)
data = stack.data
if offsets is None:
offsets = [0.0, 0.0]
if widths is None:
widths = [reference.shape[0], reference.shape[1]]
fft2Function = numpy.fft.fft2
if 1:
DTYPE = numpy.float32
else:
DTYPE = numpy.float64
image2 = numpy.zeros((widths[0], widths[1]), dtype=DTYPE)
shape = image2.shape
USE_APODIZATION_WINDOW = False
apo = [10, 10]
if USE_APODIZATION_WINDOW:
# use apodization window
window = numpy.outer(SpecfitFuns.slit([0.5, shape[0] * 0.5, shape[0] - 4 * apo[0], apo[0]],
numpy.arange(float(shape[0]))),
SpecfitFuns.slit([0.5, shape[1] * 0.5, shape[1] - 4 * apo[1], apo[1]],
numpy.arange(float(shape[1])))).astype(DTYPE)
else:
window = numpy.zeros((shape[0], shape[1]), dtype=DTYPE)
window[apo[0]:shape[0] - apo[0], apo[1]:shape[1] - apo[1]] = 1
image2[:,:] = window * reference[offsets[0]:offsets[0]+widths[0],
offsets[1]:offsets[1]+widths[1]]
image2fft2 = fft2Function(image2)
mcaIndex = stack.info.get('McaIndex')
shifts = numpy.zeros((data.shape[mcaIndex], 2), numpy.float)
image1 = numpy.zeros(image2.shape, dtype=DTYPE)
total = float(data.shape[mcaIndex])
if mcaIndex == 0:
for i in range(data.shape[mcaIndex]):
image1[:,:] = window * data[i][offsets[0]:offsets[0]+widths[0],
offsets[1]:offsets[1]+widths[1]]
image1fft2 = fft2Function(image1)
shifts[i] = ImageRegistration.measure_offset_from_ffts(image2fft2,
image1fft2)
if DEBUG:
print("Index = %d shift = %.4f, %.4f" % (i, shifts[i][0], shifts[i][1]))
self._progress = (100 * i) / total
elif mcaIndex in [2, -1]:
for i in range(data.shape[mcaIndex]):
image1[:,:] = window * data[:,:,i][offsets[0]:offsets[0]+widths[0],
offsets[1]:offsets[1]+widths[1]]
image1fft2 = fft2Function(image1)
shifts[i] = ImageRegistration.measure_offset_from_ffts(image2fft2,
image1fft2)
if DEBUG:
print("Index = %d shift = %.4f, %.4f" % (i, shifts[i][0], shifts[i][1]))
self._progress = (100 * i) / total
else:
raise IndexError("Only stacks of images or spectra supported. 1D index should be 0 or 2")
return shifts
示例2: slit
# 需要导入模块: from PyMca5.PyMcaMath.fitting import SpecfitFuns [as 别名]
# 或者: from PyMca5.PyMcaMath.fitting.SpecfitFuns import slit [as 别名]
def slit(self,pars,x):
"""
A fit function.
"""
return 0.5*SpecfitFuns.slit(pars,x)
示例3: slit
# 需要导入模块: from PyMca5.PyMcaMath.fitting import SpecfitFuns [as 别名]
# 或者: from PyMca5.PyMcaMath.fitting.SpecfitFuns import slit [as 别名]
def slit(self,pars,x):
"""
Function to calulate slit width and knife edge cut
"""
return 0.5*SpecfitFuns.slit(pars,x)