本文整理汇总了Python中hyperspy.components.Gaussian.function方法的典型用法代码示例。如果您正苦于以下问题:Python Gaussian.function方法的具体用法?Python Gaussian.function怎么用?Python Gaussian.function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperspy.components.Gaussian
的用法示例。
在下文中一共展示了Gaussian.function方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def setUp(self):
gaussian = Gaussian()
gaussian.A.value = 20
gaussian.sigma.value = 10
gaussian.centre.value = 50
self.spectrum = Signal(gaussian.function(np.arange(0, 100, 0.01)))
self.spectrum.axes_manager[0].scale = 0.01
示例2: setUp
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def setUp(self):
s = EDSTEMSpectrum(np.ones([2, 2, 1024]))
energy_axis = s.axes_manager.signal_axes[0]
energy_axis.scale = 1e-2
energy_axis.units = 'keV'
energy_axis.name = "Energy"
s.set_microscope_parameters(beam_energy=200,
live_time=3.1, tilt_stage=0.0,
azimuth_angle=None, elevation_angle=35,
energy_resolution_MnKa=130)
s.metadata.Acquisition_instrument.TEM.Detector.EDS.real_time = 2.5
s.metadata.Acquisition_instrument.TEM.beam_current = 0.05
elements = ['Al', 'Zn']
xray_lines = ['Al_Ka', 'Zn_Ka']
intensities = [300, 500]
for i, xray_line in enumerate(xray_lines):
gauss = Gaussian()
line_energy, FWHM = s._get_line_energy(xray_line, FWHM_MnKa='auto')
gauss.centre.value = line_energy
gauss.A.value = intensities[i]
gauss.sigma.value = FWHM
s.data[:] += gauss.function(energy_axis.axis)
s.set_elements(elements)
s.add_lines(xray_lines)
s.axes_manager[0].scale = 0.5
s.axes_manager[1].scale = 0.5
self.spectrum = s
示例3: setUp
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def setUp(self):
# Create an empty spectrum
s = EELSSpectrumSimulation(np.zeros((3,2,1024)))
energy_axis = s.axes_manager.signal_axes[0]
energy_axis.scale = 0.02
energy_axis.offset = -5
gauss = Gaussian()
gauss.centre.value = 0
gauss.A.value = 5000
gauss.sigma.value = 0.5
gauss2 = Gaussian()
gauss2.sigma.value = 0.5
# Inflexion point 1.5
gauss2.A.value = 5000
gauss2.centre.value = 5
s.data[:] = (gauss.function(energy_axis.axis) +
gauss2.function(energy_axis.axis))
# s.add_poissonian_noise()
self.signal = s
示例4: test_fit_component
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def test_fit_component(self):
m = self.model
axis = self.axis
g1 = Gaussian()
m.append(g1)
m.fit_component(g1, signal_range=(4000, 6000))
assert_true(
np.allclose(
self.g.function(axis),
g1.function(axis),
rtol=self.rtol))
示例5: setUp
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def setUp(self):
g = Gaussian()
g.A.value = 10000.0
g.centre.value = 5000.0
g.sigma.value = 500.0
axis = np.arange(10000)
s = Spectrum(g.function(axis))
m = create_model(s)
self.model = m
self.g = g
self.axis = axis
self.rtol = 0.00
示例6: setUp
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def setUp(self):
# Create an empty spectrum
s = EDSSEMSpectrum(np.zeros((2, 2, 3, 100)))
energy_axis = s.axes_manager.signal_axes[0]
energy_axis.scale = 0.04
energy_axis.units = 'keV'
energy_axis.name = "Energy"
g = Gaussian()
g.sigma.value = 0.05
g.centre.value = 1.487
s.data[:] = g.function(energy_axis.axis)
s.metadata.Acquisition_instrument.SEM.Detector.EDS.live_time = 3.1
s.metadata.Acquisition_instrument.SEM.beam_energy = 15.0
self.signal = s
示例7: setUp
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def setUp(self):
np.random.seed(1)
axes = np.array([[100 * np.random.random() + np.arange(0., 600, 1)
for i in range(3)] for j in range(4)])
g = Gaussian()
g.A.value = 30000.
g.centre.value = 300.
g.sigma.value = 150.
data = g.function(axes)
s = SpectrumSimulation(data)
s.axes_manager[-1].offset = -150.
s.axes_manager[-1].scale = 0.5
s.add_gaussian_noise(2.0)
m = s.create_model()
g = Gaussian()
g.A.ext_force_positive = True
g.A.ext_bounded = True
m.append(g)
g.active_is_multidimensional = True
for index in m.axes_manager:
m.fit()
self.model = m
示例8: fourier_ratio_deconvolution
# 需要导入模块: from hyperspy.components import Gaussian [as 别名]
# 或者: from hyperspy.components.Gaussian import function [as 别名]
def fourier_ratio_deconvolution(self, ll,
fwhm=None,
threshold=None,
extrapolate_lowloss=True,
extrapolate_coreloss=True):
"""Performs Fourier-ratio deconvolution.
The core-loss should have the background removed. To reduce
the noise amplication the result is convolved with a
Gaussian function.
Parameters
----------
ll: EELSSpectrum
The corresponding low-loss (ll) EELSSpectrum.
fwhm : float or None
Full-width half-maximum of the Gaussian function by which
the result of the deconvolution is convolved. It can be
used to select the final SNR and spectral resolution. If
None, the FWHM of the zero-loss peak of the low-loss is
estimated and used.
threshold : {None, float}
Truncation energy to estimate the intensity of the
elastic scattering. If None the threshold is taken as the
first minimum after the ZLP centre.
extrapolate_lowloss, extrapolate_coreloss : bool
If True the signals are extrapolated using a power law,
Notes
-----
For details see: Egerton, R. Electron Energy-Loss
Spectroscopy in the Electron Microscope. Springer-Verlag, 2011.
"""
self._check_signal_dimension_equals_one()
orig_cl_size = self.axes_manager.signal_axes[0].size
if threshold is None:
threshold = ll.estimate_elastic_scattering_threshold()
if extrapolate_coreloss is True:
cl = self.power_law_extrapolation(
window_size=20,
extrapolation_size=100)
else:
cl = self.deepcopy()
if extrapolate_lowloss is True:
ll = ll.power_law_extrapolation(
window_size=100,
extrapolation_size=100)
else:
ll = ll.deepcopy()
ll.hanning_taper()
cl.hanning_taper()
ll_size = ll.axes_manager.signal_axes[0].size
cl_size = self.axes_manager.signal_axes[0].size
# Conservative new size to solve the wrap-around problem
size = ll_size + cl_size - 1
# Increase to the closest multiple of two to enhance the FFT
# performance
size = int(2 ** np.ceil(np.log2(size)))
axis = ll.axes_manager.signal_axes[0]
if fwhm is None:
fwhm = float(ll.get_current_signal().estimate_peak_width()())
print("FWHM = %1.2f" % fwhm)
I0 = ll.estimate_elastic_scattering_intensity(threshold=threshold)
I0 = I0.data
if ll.axes_manager.navigation_size > 0:
I0_shape = list(I0.shape)
I0_shape.insert(axis.index_in_array, 1)
I0 = I0.reshape(I0_shape)
from hyperspy.components import Gaussian
g = Gaussian()
g.sigma.value = fwhm / 2.3548
g.A.value = 1
g.centre.value = 0
zl = g.function(
np.linspace(axis.offset,
axis.offset + axis.scale * (size - 1),
size))
z = np.fft.rfft(zl)
jk = np.fft.rfft(cl.data, n=size, axis=axis.index_in_array)
jl = np.fft.rfft(ll.data, n=size, axis=axis.index_in_array)
zshape = [1, ] * len(cl.data.shape)
zshape[axis.index_in_array] = jk.shape[axis.index_in_array]
cl.data = np.fft.irfft(z.reshape(zshape) * jk / jl,
axis=axis.index_in_array)
cl.data *= I0
cl.crop(-1, None, int(orig_cl_size))
cl.metadata.General.title = (self.metadata.General.title +
' after Fourier-ratio deconvolution')
if cl.tmp_parameters.has_item('filename'):
cl.tmp_parameters.filename = (
#.........这里部分代码省略.........