Parameter#
- class hyperspy.component.Parameter#
Bases:
HasTraits
The parameter of a component.
- Attributes:
- bmin
float
The lower bound of the parameter.
- bmax
float
The upper bound of the parameter.
ext_force_positive
boolIf True, the parameter value is set to be the absolute value of the input value i.e.
ext_bounded
boolSimilar to
ext_force_positive
, but in this case the bounds are defined by bmin and bmax.- freebool
- map
numpy.ndarray
twin
None
orParameter
If it is not None, the value of the current parameter is a function of the given Parameter.
twin_function_expr
str
Expression of the function that enables setting a functional relationship between the parameter and its twin.
twin_inverse_function_expr
str
Expression of the function that enables setting the value of the twin parameter.
- value
float
orarray
The value of the parameter for the current location. The value for other locations is stored in map.
- bmin
- value#
- free#
- map#
- as_dictionary(fullcopy=True)#
Returns parameter as a dictionary, saving all attributes from self._whitelist.keys() For more information see py:meth:~hyperspy.misc.export_dictionary.export_to_dictionary
- Parameters:
- Returns:
dict
A dictionary, containing at least the following fields:
_id_name: _id_name of the original parameter, used to create the dictionary. Has to match with the
self._id_name
_twins: a list of ids of the twins of the parameter
_whitelist: a dictionary, which keys are used as keywords to match with the parameter attributes. For more information see
export_to_dictionary()
any field from _whitelist.keys()
- as_signal(field='values')#
Get a parameter map as a signal object.
Please note that this method only works when the navigation dimension is greater than 0.
- Parameters:
- field{‘values’, ‘std’, ‘is_set’}
Field to return as signal.
- assign_current_value_to_all(mask=None)#
Assign the current value attribute to all the indices, setting parameter.map for all parameters in the component.
Takes the current parameter.value and sets it for all indices in parameter.map[‘values’].
- Parameters:
- mask: {None, boolean numpy array}
Set only the indices that are not masked i.e. where mask is False.
See also
- default_traits_view()#
Returns the name of the default traits view for the object’s class.
- export(folder=None, name=None, format='hspy', save_std=False)#
Save the data to a file. All the arguments are optional.
- Parameters:
- folder
str
orNone
The path to the folder where the file will be saved. If None the current folder is used by default.
- name
str
orNone
The name of the file. If None the Components name followed by the Parameter name attributes will be used by default. If a file with the same name exists the name will be modified by appending a number to the file path.
- save_stdbool
If True, also the standard deviation will be saved
- format: str
The extension of any file format supported by HyperSpy, default
hspy
.
- folder
- property ext_bounded#
Similar to
ext_force_positive
, but in this case the bounds are defined by bmin and bmax. It is a better idea to use an optimizer that supports bounding though.
- property ext_force_positive#
If True, the parameter value is set to be the absolute value of the input value i.e. if we set Parameter.value = -3, the value stored is 3 instead. This is useful to bound a value to be positive in an optimization without actually using an optimizer that supports bounding.
- fetch()#
Fetch the stored value and std attributes from the parameter.map[‘values’] and …[‘std’] if parameter.map[‘is_set’] is True for that index. Updates parameter.value and parameter.std. If not stored, then .value and .std will remain from their previous values, i.e. from a fit in a previous pixel.
- 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.
- plot(**kwargs)#
Plot parameter signal.
- Parameters:
- **kwargs
Any extra keyword arguments are passed to the signal plot.
Examples
>>> parameter.plot()
Set the minimum and maximum displayed values
>>> parameter.plot(vmin=0, vmax=1)
- store_current_value_in_array()#
Store the value and std attributes.
See also
- property twin#
If it is not None, the value of the current parameter is a function of the given Parameter. The function is by default the identity function, but it can be defined by
twin_function_expr
- property twin_function_expr#
Expression of the function that enables setting a functional relationship between the parameter and its twin. If
twin
is notNone
, the parameter value is calculated as the output of calling the twin function with the value of the twin parameter. The string is parsed using sympy, so permitted values are any valid sympy expressions of one variable. If the function is invertible the twin inverse function is set automatically.
- property twin_inverse_function_expr#
Expression of the function that enables setting the value of the twin parameter. If
twin
is notNone
, its value is set to the output of calling the twin inverse function with the value provided. The string is parsed using sympy, so permitted values are any valid sympy expressions of one variable.