当前位置: 首页>>代码示例>>Python>>正文


Python components.Gaussian类代码示例

本文整理汇总了Python中hyperspy.components.Gaussian的典型用法代码示例。如果您正苦于以下问题:Python Gaussian类的具体用法?Python Gaussian怎么用?Python Gaussian使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Gaussian类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 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
开发者ID:siriagus,项目名称:hyperspy,代码行数:7,代码来源:test_integrate_in_range.py

示例2: setUp

    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
开发者ID:siriagus,项目名称:hyperspy,代码行数:28,代码来源:test_eds_tem.py

示例3: test_access_component_by_index

 def test_access_component_by_index(self):
     m = self.model
     g1 = Gaussian()
     g2 = Gaussian()
     g2.name = "test"
     m.extend((g1, g2))
     nose.tools.assert_is(m[1], g2)
开发者ID:LewysJones,项目名称:hyperspy,代码行数:7,代码来源:test_model.py

示例4: test_get_component_wrong

 def test_get_component_wrong(self):
     m = self.model
     g1 = Gaussian()
     g2 = Gaussian()
     g2.name = "test"
     m.extend((g1, g2))
     m._get_component(1.2)
开发者ID:LewysJones,项目名称:hyperspy,代码行数:7,代码来源:test_model.py

示例5: test_get_component_by_component

 def test_get_component_by_component(self):
     m = self.model
     g1 = Gaussian()
     g2 = Gaussian()
     g2.name = "test"
     m.extend((g1, g2))
     nose.tools.assert_is(m._get_component(g2), g2)
开发者ID:LewysJones,项目名称:hyperspy,代码行数:7,代码来源:test_model.py

示例6: test_dof_with_fit

 def test_dof_with_fit(self):
     m = self.model
     g = Gaussian()
     g1 = Gaussian()
     m.extend((g, g1))
     g1.set_parameters_not_free('A')
     m.fit()
     assert_true(np.equal(m.dof(), 5))
开发者ID:TimeSpaceFractal,项目名称:hyperspy,代码行数:8,代码来源:test_chi_squared.py

示例7: test_chisq_with_inactive_components

 def test_chisq_with_inactive_components(self):
     m = self.model
     ga = Gaussian()
     gin = Gaussian()
     m.append(ga)
     m.append(gin)
     gin.active = False
     m.fit()
     assert_true(np.allclose(m.chisq(), 7.78966223))
开发者ID:TimeSpaceFractal,项目名称:hyperspy,代码行数:9,代码来源:test_chi_squared.py

示例8: test_dof_with_p0

 def test_dof_with_p0(self):
     m = self.model
     g = Gaussian()
     g1 = Gaussian()
     m.extend((g, g1))
     g1.set_parameters_not_free('A')
     m._set_p0()
     m._set_current_degrees_of_freedom()
     assert_true(np.equal(m.dof(), 5))
开发者ID:TimeSpaceFractal,项目名称:hyperspy,代码行数:9,代码来源:test_chi_squared.py

示例9: test_dof_with_inactive_components

 def test_dof_with_inactive_components(self):
     m = self.model
     ga = Gaussian()
     gin = Gaussian()
     m.append(ga)
     m.append(gin)
     gin.active = False
     m.fit()
     assert_true(np.equal(m.dof(), 3))
开发者ID:TimeSpaceFractal,项目名称:hyperspy,代码行数:9,代码来源:test_chi_squared.py

示例10: test_fit_component

    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))
开发者ID:gdonval,项目名称:hyperspy,代码行数:12,代码来源:test_fit_component.py

示例11: setUp

 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
开发者ID:gdonval,项目名称:hyperspy,代码行数:12,代码来源:test_fit_component.py

示例12: setUp

 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
开发者ID:gdonval,项目名称:hyperspy,代码行数:14,代码来源:test_eds_sem.py

示例13: setUp

    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
开发者ID:mfm24,项目名称:hyperspy,代码行数:20,代码来源:test_eels.py

示例14: setUp

 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
开发者ID:siriagus,项目名称:hyperspy,代码行数:22,代码来源:test_fancy_indexing.py

示例15: fourier_ratio_deconvolution

    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 = (
#.........这里部分代码省略.........
开发者ID:gdonval,项目名称:hyperspy,代码行数:101,代码来源:eels.py


注:本文中的hyperspy.components.Gaussian类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。