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


Python spectrum.Spectrum类代码示例

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


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

示例1: setUp

 def setUp(self):
     s = Spectrum(np.array([1.0, 2, 4, 7, 12, 7, 4, 2, 1]))
     m = s.create_model()
     self.model = m
     self.A = 38.022476979172588
     self.sigma = 1.4764966133859543
     self.centre = 4.0000000002462945
开发者ID:lu-chi,项目名称:hyperspy,代码行数:7,代码来源:test_chi_squared.py

示例2: setUp

 def setUp(self):
     s = Spectrum(range(100))
     m = s.create_model()
     m.append(Gaussian())
     m.components.Gaussian.A.value = 13
     m.components.Gaussian.name = 'something'
     self.m = m
开发者ID:temcode,项目名称:hyperspy,代码行数:7,代码来源:test_model_storing.py

示例3: __init__

 def __init__(self, *args, **kwards):
     Spectrum.__init__(self, *args, **kwards)
     if self.metadata.Signal.signal_type == 'EDS':
         print('The microscope type is not set. Use '
               'set_signal_type(\'EDS_TEM\')  '
               'or set_signal_type(\'EDS_SEM\')')
     self.metadata.Signal.binned = True
开发者ID:temcode,项目名称:hyperspy,代码行数:7,代码来源:eds.py

示例4: __init__

 def __init__(self, *args, **kwards):
     Spectrum.__init__(self, *args, **kwards)
     if self.metadata.Signal.signal_type == 'EDS':
         warnings.warn('The microscope type is not set. Use '
                       'set_signal_type(\'EDS_TEM\')  '
                       'or set_signal_type(\'EDS_SEM\')')
     self.metadata.Signal.binned = True
     self._xray_markers = {}
开发者ID:AakashV,项目名称:hyperspy,代码行数:8,代码来源:eds.py

示例5: __init__

 def __init__(self, *args, **kwards):
     Spectrum.__init__(self, *args, **kwards)
     # Attributes defaults
     self.subshells = set()
     self.elements = set()
     self.edges = list()
     if hasattr(self.mapped_parameters, 'Sample') and \
     hasattr(self.mapped_parameters.Sample, 'elements'):
         print('Elemental composition read from file')
         self.add_elements(self.mapped_parameters.Sample.elements)
开发者ID:Emilieringe,项目名称:hyperspy,代码行数:10,代码来源:eels.py

示例6: __init__

 def __init__(self, *args, **kwards):
     Spectrum.__init__(self, *args, **kwards)
     # Attributes defaults
     self.subshells = set()
     self.elements = set()
     self.edges = list()
     if hasattr(self.metadata, 'Sample') and \
             hasattr(self.metadata.Sample, 'elements'):
         print('Elemental composition read from file')
         self.add_elements(self.metadata.Sample.elements)
     self.metadata.Signal.binned = True
开发者ID:gdonval,项目名称:hyperspy,代码行数:11,代码来源:eels.py

示例7: setUp

    def setUp(self):
        s = Spectrum(np.array([1.0, 2, 4, 7, 12, 7, 4, 2, 1]))
        m = s.create_model()
        m.low_loss = (s + 3.0).deepcopy()
        self.model = m
        self.s = s

        m.append(Gaussian())
        m.append(Gaussian())
        m.append(ScalableFixedPattern(s * 0.3))
        m[0].A.twin = m[1].A
        m.fit()
开发者ID:AakashV,项目名称:hyperspy,代码行数:12,代码来源:test_model_as_dictionary.py

示例8: 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 = s.create_model()
     self.model = m
     self.g = g
     self.axis = axis
     self.rtol = 0.00
开发者ID:jerevon,项目名称:hyperspy,代码行数:12,代码来源:test_fit_component.py

示例9: setUp

 def setUp(self):
     g1 = Gaussian()
     g2 = Gaussian()
     g3 = Gaussian()
     s = Spectrum(np.arange(1000).reshape(10, 10, 10))
     m = s.create_model()
     m.append(g1)
     m.append(g2)
     m.append(g3)
     self.g1 = g1
     self.g2 = g2
     self.g3 = g3
     self.model = m
开发者ID:AakashV,项目名称:hyperspy,代码行数:13,代码来源:test_set_parameter_value.py

示例10: blind_source_separation

    def blind_source_separation(self,
                                number_of_components=None,
                                algorithm='sklearn_fastica',
                                diff_order=1,
                                diff_axes=None,
                                factors=None,
                                comp_list=None,
                                mask=None,
                                on_loadings=False,
                                pretreatment=None,
                                **kwargs):
        """Blind source separation (BSS) on the result on the
        decomposition.

        Available algorithms: FastICA, JADE, CuBICA, and TDSEP

        Parameters
        ----------
        number_of_components : int
            number of principal components to pass to the BSS algorithm
        algorithm : {FastICA, JADE, CuBICA, TDSEP}
        diff_order : int
            Sometimes it is convenient to perform the BSS on the derivative of
            the signal. If diff_order is 0, the signal is not differentiated.
        diff_axes : None or list of ints or strings
            If None, when `diff_order` is greater than 1 and `signal_dimension`
            (`navigation_dimension`) when `on_loadings` is False (True) is
            greater than 1, the differences are calculated across all
            signal (navigation) axes. Otherwise the axes can be specified in
            a list.
        factors : Signal or numpy array.
            Factors to decompose. If None, the BSS is performed on the
            factors of a previous decomposition. If a Signal instance the
            navigation dimension must be 1 and the size greater than 1. If a
            numpy array (deprecated) the factors are stored in a 2d array
            stacked over the last axis.
        comp_list : boolen numpy array
            choose the components to use by the boolean list. It permits
             to choose non contiguous components.
        mask : bool numpy array or Signal instance.
            If not None, the signal locations marked as True are masked. The
            mask shape must be equal to the signal shape
            (navigation shape) when `on_loadings` is False (True).
        on_loadings : bool
            If True, perform the BSS on the loadings of a previous
            decomposition. If False, performs it on the factors.
        pretreatment: dict

        **kwargs : extra key word arguments
            Any keyword arguments are passed to the BSS algorithm.

        """
        from hyperspy.signal import Signal
        from hyperspy._signals.spectrum import Spectrum

        lr = self.learning_results

        if factors is None:
            if not hasattr(lr, 'factors') or lr.factors is None:
                raise AttributeError(
                    'A decomposition must be performed before blind '
                    'source seperation or factors must be provided.')

            else:
                if on_loadings:
                    factors = self.get_decomposition_loadings()
                else:
                    factors = self.get_decomposition_factors()

        # Check factors
        if not isinstance(factors, Signal):
            if isinstance(factors, np.ndarray):
                warnings.warn(
                    "factors as numpy arrays will raise an error in "
                    "HyperSpy 0.9 and newer. From them on only passing "
                    "factors as HyperSpy Signal instances will be "
                    "supported.",
                    DeprecationWarning)
                # We proceed supposing that the factors are spectra stacked
                # over the last dimension to reproduce the deprecated
                # behaviour.
                # TODO: Don't forget to change `factors` docstring when
                # removing this.
                factors = Spectrum(factors.T)
            else:
                # Change next error message when removing the
                # DeprecationWarning
                raise ValueError(
                    "`factors` must be either a Signal instance or a "
                    "numpy array but an object of type %s was provided." %
                    type(factors))

        # Check factor dimensions
        if factors.axes_manager.navigation_dimension != 1:
            raise ValueError("`factors` must have navigation dimension"
                             "equal one, but the navigation dimension "
                             "of the given factors is %i." %
                             factors.axes_manager.navigation_dimension
                             )
        elif factors.axes_manager.navigation_size < 2:
#.........这里部分代码省略.........
开发者ID:lu-chi,项目名称:hyperspy,代码行数:101,代码来源:mva.py

示例11: blind_source_separation

    def blind_source_separation(self,
                                number_of_components=None,
                                algorithm='sklearn_fastica',
                                diff_order=1,
                                factors=None,
                                comp_list=None,
                                mask=None, 
                                on_loadings=False,
                                pretreatment=None,
                                **kwargs):
        """Blind source separation (BSS) on the result on the 
        decomposition.

        Available algorithms: FastICA, JADE, CuBICA, and TDSEP

        Parameters
        ----------
        number_of_components : int
            number of principal components to pass to the BSS algorithm
        algorithm : {FastICA, JADE, CuBICA, TDSEP}
        diff_order : int
            Sometimes it is convenient to perform the BSS on the derivative 
            of the signal. If diff_order is 0, the signal is not differentiated.
        factors : numpy.array
            Factors to decompose. If None, the BSS is performed on the result
            of a previous decomposition.
        comp_list : boolen numpy array
            choose the components to use by the boolean list. It permits
             to choose non contiguous components.
        mask : numpy boolean array with the same dimension as the signal
            If not None, the signal locations marked as True (masked) will 
            not be passed to the BSS algorithm.
        on_loadings : bool
            If True, perform the BSS on the loadings of a previous 
            decomposition. If False, performs it on the factors.
        pretreatment: dict
        
        **kwargs : extra key word arguments
            Any keyword arguments are passed to the BSS algorithm.
        
        """
        target=self.learning_results                
        if not hasattr(target, 'factors') or target.factors==None:
            raise AttributeError(
                'A decomposition must be performed before blind '
                'source seperation or factors must be provided.')
        else:
            if factors is None:
                if on_loadings:
                    factors = target.loadings
                else:
                    factors = target.factors
            bool_index = np.zeros((factors.shape[0]), dtype = 'bool')
            if number_of_components is not None:
                bool_index[:number_of_components] = True
            else:
                if target.output_dimension is not None:
                    number_of_components = target.output_dimension
                    bool_index[:number_of_components] = True

            if comp_list is not None:
                for ifactors in comp_list:
                    bool_index[ifactors] = True
                number_of_components = len(comp_list)
            factors = factors[:,bool_index]
                    
            if pretreatment is not None:
                from hyperspy._signals.spectrum import Spectrum
                sfactors = Spectrum(factors.T)
                if pretreatment['algorithm'] == 'savitzky_golay':
                    sfactors.smooth_savitzky_golay(
                        number_of_points=pretreatment[
                                'number_of_points'],
                        polynomial_order=pretreatment[
                                'polynomial_order'],
                        differential_order = diff_order)
                if pretreatment['algorithm'] == 'tv':
                    sfactors.smooth_tv(
                        smoothing_parameter= pretreatment[
                            'smoothing_parameter'],
                        differential_order = diff_order)
                factors = sfactors.data.T
                if pretreatment['algorithm'] == 'butter':
                    b, a = sp.signal.butter(pretreatment['order'],
                        pretreatment['cutoff'], pretreatment['type'])
                    for i in range(factors.shape[1]):
                        factors[:,i] = sp.signal.filtfilt(b,a,
                            factors[:,i])
            elif diff_order > 0:
                factors = np.diff(factors, diff_order, axis=0)
                    
            if mask is not None:
                factors = factors[~mask]

            # first center and scale the data
            factors,invsqcovmat = centering_and_whitening(factors)
            if algorithm == 'orthomax':
                _, unmixing_matrix = orthomax(factors, **kwargs)
                unmixing_matrix = unmixing_matrix.T
            
#.........这里部分代码省略.........
开发者ID:mfm24,项目名称:hyperspy,代码行数:101,代码来源:mva.py

示例12: __init__

 def __init__(self, *args, **kwards):
     Spectrum.__init__(self, *args, **kwards)
     if self.mapped_parameters.signal_type == 'EDS':
         print('The microscope type is not set. Use '
         'set_signal_type(\'EDS_TEM\') or set_signal_type(\'EDS_SEM\')')
开发者ID:Emilieringe,项目名称:hyperspy,代码行数:5,代码来源:eds.py

示例13: __init__

 def __init__(self, *args, **kwards):
     Spectrum.__init__(self, *args, **kwards)
     self.metadata.Signal.binned = False
开发者ID:LewysJones,项目名称:hyperspy,代码行数:3,代码来源:dielectric_function.py


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