Пример #1
0
    def __init__(self, spectrum, auto_background=True, auto_add_edges=True, ll=None, GOS=None, dictionary=None):
        Model.__init__(self, spectrum)
        self._suspend_auto_fine_structure_width = False
        self.convolved = False
        self.low_loss = ll
        self.GOS = GOS
        self.edges = list()
        if dictionary is not None:
            auto_background = False
            auto_add_edges = False
            self._load_dictionary(dictionary)

        if auto_background is True:
            interactive_ns = get_interactive_ns()
            background = PowerLaw()
            background.name = "background"
            warnings.warn(
                'Adding "background" to the user namespace. ' "This feature will be removed in HyperSpy 0.9.",
                VisibleDeprecationWarning,
            )
            interactive_ns["background"] = background
            self.append(background)

        if self.spectrum.subshells and auto_add_edges is True:
            self._add_edges_from_subshells_names()
Пример #2
0
    def _add_edges_from_subshells_names(self,
                                        e_shells=None,
                                        copy2interactive_ns=True):
        """Create the Edge instances and configure them appropiately
        Parameters
        ----------
        e_shells : list of strings
        copy2interactive_ns : bool
            If True, variables with the format Element_Shell will be
            created in IPython's interactive shell
        """
        interactive_ns = get_interactive_ns()
        if e_shells is None:
            e_shells = list(self.spectrum.subshells)
        e_shells.sort()
        master_edge = EELSCLEdge(e_shells.pop(), self.GOS)
        # If self.GOS was None, the GOS is set by eels_cl_edge so
        # we reassing the value of self.GOS
        self.GOS = master_edge.GOS._name
        self.append(master_edge)
        interactive_ns[self[-1].name] = self[-1]
        element = master_edge.element
        interactive_ns[element] = []
        interactive_ns[element].append(self[-1])
        while len(e_shells) > 0:
            next_element = e_shells[-1].split('_')[0]
            if next_element != element:
                # New master edge
                self._add_edges_from_subshells_names(e_shells=e_shells)
            elif self.GOS == 'hydrogenic':
                # The hydrogenic GOS includes all the L subshells in one
                # so we get rid of the others
                e_shells.pop()
            else:
                # Add the other subshells of the same element
                # and couple their intensity and onset_energy to that of the
                # master edge
                edge = EELSCLEdge(e_shells.pop(), GOS=self.GOS)

                edge.intensity.twin = master_edge.intensity
                delta = _give_me_delta(master_edge.GOS.onset_energy,
                                       edge.GOS.onset_energy)
                idelta = _give_me_idelta(master_edge.GOS.onset_energy,
                                         edge.GOS.onset_energy)
                edge.onset_energy.twin_function = delta
                edge.onset_energy.twin_inverse_function = idelta
                edge.onset_energy.twin = master_edge.onset_energy
                edge.free_onset_energy = False
                self.append(edge)
                if copy2interactive_ns is True:
                    interactive_ns[edge.name] = edge
                    interactive_ns[element].append(edge)
Пример #3
0
 def _add_edges_from_subshells_names(self, e_shells=None, 
                                     copy2interactive_ns=True):
     """Create the Edge instances and configure them appropiately
     Parameters
     ----------
     e_shells : list of strings
     copy2interactive_ns : bool
         If True, variables with the format Element_Shell will be 
         created in IPython's interactive shell
     """
     interactive_ns = get_interactive_ns()
     if e_shells is None:
         e_shells = list(self.spectrum.subshells)
     e_shells.sort()
     master_edge = EELSCLEdge(e_shells.pop(), self.GOS)
     # If self.GOS was None, the GOS is set by eels_cl_edge so
     # we reassing the value of self.GOS
     self.GOS = master_edge.GOS._name
     self.append(master_edge)
     interactive_ns[self[-1].name] = self[-1]
     element = master_edge.element
     interactive_ns[element] = []
     interactive_ns[element].append(self[-1])
     while len(e_shells) > 0:
         next_element = e_shells[-1].split('_')[0]
         if next_element != element:
             # New master edge
             self._add_edges_from_subshells_names(e_shells=e_shells)
         elif self.GOS == 'hydrogenic':
             # The hydrogenic GOS includes all the L subshells in one
             # so we get rid of the others
             e_shells.pop()
         else:
             # Add the other subshells of the same element
             # and couple their intensity and onset_energy to that of the 
             # master edge
             edge = EELSCLEdge(e_shells.pop(), GOS=self.GOS)
             
             edge.intensity.twin = master_edge.intensity
             delta =  _give_me_delta(master_edge.GOS.onset_energy,
                                    edge.GOS.onset_energy)
             idelta = _give_me_idelta(master_edge.GOS.onset_energy,
                                    edge.GOS.onset_energy)
             edge.onset_energy.twin_function = delta
             edge.onset_energy.twin_inverse_function = idelta
             edge.onset_energy.twin = master_edge.onset_energy
             edge.free_onset_energy = False
             self.append(edge)
             if copy2interactive_ns is True:
                 interactive_ns[edge.name] = edge
                 interactive_ns[element].append(edge)
Пример #4
0
    def __init__(self, spectrum, auto_background=True, auto_add_edges=True, ll=None, GOS=None, *args, **kwargs):
        Model.__init__(self, spectrum, *args, **kwargs)
        self._suspend_auto_fine_structure_width = False
        self.convolved = False
        self.low_loss = ll
        self.GOS = GOS
        self.edges = list()
        if auto_background is True:
            interactive_ns = get_interactive_ns()
            background = PowerLaw()
            background.name = "background"
            interactive_ns["background"] = background
            self.append(background)

        if self.spectrum.subshells and auto_add_edges is True:
            self._add_edges_from_subshells_names()
Пример #5
0
 def __init__(self, spectrum, auto_background=True,
              auto_add_edges=True, ll=None, 
              GOS=None, *args, **kwargs):
     Model.__init__(self, spectrum, *args, **kwargs)
     self.convolved = False
     self.low_loss = ll
     self.GOS = GOS
     if auto_background is True:
         interactive_ns = get_interactive_ns()
         background = PowerLaw()
         background.name = 'background'
         interactive_ns['background'] = background
         self.append(background)
         
     if self.spectrum.subshells and auto_add_edges is True:
         self._add_edges_from_subshells_names()
Пример #6
0
    def __init__(self,
                 spectrum,
                 auto_background=True,
                 auto_add_edges=True,
                 ll=None,
                 GOS=None,
                 *args,
                 **kwargs):
        Model.__init__(self, spectrum, *args, **kwargs)
        self.convolved = False
        self.low_loss = ll
        self.GOS = GOS
        if auto_background is True:
            interactive_ns = get_interactive_ns()
            background = PowerLaw()
            background.name = 'background'
            interactive_ns['background'] = background
            self.append(background)

        if self.spectrum.subshells and auto_add_edges is True:
            self._add_edges_from_subshells_names()