Component#
- class hyperspy.component.Component(parameter_name_list, linear_parameter_list=None, *args, **kwargs)#
Bases:
HasTraits
The component of a model.
- Attributes:
- activebool
- name
str
free_parameters
list
The list of free parameters of the component.
parameters
list
The list of parameters of the component.
- Parameters:
- property active_is_multidimensional#
In multidimensional signals it is possible to store the value of the
active
attribute at each navigation index.
- as_dictionary(fullcopy=True)#
Returns component as a dictionary. For more information on method and conventions, see
export_to_dictionary()
.- Parameters:
- Returns:
- dic
dict
A dictionary, containing at least the following fields:
parameters: a list of dictionaries of the parameters, one per component.
_whitelist: a dictionary with keys used as references saved attributes, for more information, see
export_to_dictionary()
.any field from _whitelist.keys().
- dic
- export(folder=None, format='hspy', save_std=False, only_free=True)#
Plot the value of the parameters of the model
- Parameters:
- folder
str
orNone
The path to the folder where the file will be saved. If None the current folder is used by default.
- format
str
The extension of the file format, default “hspy”.
- save_stdbool
If True, also the standard deviation will be saved.
- only_freebool
If True, only the value of the parameters that are free will be exported.
- folder
Notes
The name of the files will be determined by each the Component and each Parameter name attributes. Therefore, it is possible to customise the file names modify the name attributes.
- fetch_values_from_array(p, p_std=None, onlyfree=False)#
Fetch the parameter values from an array p and optionally standard deviation from p_std. Places them component.parameter.value and …std, according to their position in the component.
- property free_parameters#
The list of free parameters of the component.
- gui(display=True, toolkit=None, **kwargs)#
Display or return interactive GUI element if available.
- Parameters:
- displaybool
If True, display the user interface widgets. If False, return the widgets container in a dictionary, usually for customisation or testing.
- toolkit
str
, iterable ofstr
orNone
If None (default), all available widgets are displayed or returned. If string, only the widgets of the selected toolkit are displayed if available. If an interable of toolkit strings, the widgets of all listed toolkits are displayed or returned.
- init_parameters(parameter_name_list, linear_parameter_list=None)#
Initialise the parameters of the component.
- property parameters#
The list of parameters of the component.
- plot(only_free=True)#
Plot the value of the parameters of the model
- Parameters:
- only_freebool
- If True, only the value of the parameters that are free will
be plotted
- print_current_values(only_free=False)#
Prints the current values of the component’s parameters.
- Parameters:
- only_freebool
If True, only free parameters will be printed.
- set_parameters_free(parameter_name_list=None, only_linear=False, only_nonlinear=False)#
Sets parameters in a component to free.
- Parameters:
- parameter_name_list
None
orlist
ofstr
, optional If None, will set all the parameters to free. If list of strings, will set all the parameters with the same name as the strings in parameter_name_list to free.
- only_linearbool
If True, only sets a parameter free if it is linear
- only_nonlinearbool
If True, only sets a parameter free if it is nonlinear
- parameter_name_list
See also
Examples
>>> v1 = hs.model.components1D.Voigt() >>> v1.set_parameters_free() >>> v1.set_parameters_free(parameter_name_list=['area','centre']) >>> v1.set_parameters_free(only_linear=True)
- set_parameters_not_free(parameter_name_list=None, only_linear=False, only_nonlinear=False)#
Sets parameters in a component to not free.
- Parameters:
- parameter_name_list
None
orlist
ofstr
, optional If None, will set all the parameters to not free. If list of strings, will set all the parameters with the same name as the strings in parameter_name_list to not free.
- only_linearbool
If True, only sets a parameter not free if it is linear
- only_nonlinearbool
If True, only sets a parameter not free if it is nonlinear
- parameter_name_list
See also
Examples
>>> v1 = hs.model.components1D.Voigt() >>> v1.set_parameters_not_free() >>> v1.set_parameters_not_free(parameter_name_list=['area','centre']) >>> v1.set_parameters_not_free(only_linear=True)