Parameter#
- class Parameter(name, label=None, unit=None, data_type=None, collection_type=None, element_indices=None, _parent_name=None, _parent_label=None)#
Bases:
object
A basic data structure that represents a single variable.
The variable can be a high-level or low-level control knob of an instrument such as the amplitude of a pulse or a control voltage; a physical quantity such as resonance frequency; or an abstract concept like the number of averages in a measurement.
Setting
combines Parameter with a numerical, boolean, or string value to represent a quantity.Module:
exa.common.data.parameter
Attributes
Data format that this parameter accepts and validates.
Data type or a tuple of datatypes that this parameter accepts and validates.
For parameters representing a single value in a collection-valued parent parameter, this field gives the indices of that value.
name
Returns the parent label.
Returns the parent name.
SI unit of the quantity, if applicable.
Parameter name used as identifier
Methods
Attach Parameter information to a numerical array.
Build an xarray Dataset, where the only DataArray is given by results and coordinates are given by variables.
Return a copy of the parameter, where attributes defined in attributes are replaced.
Utility for creating an element-wise parameter for a single value in a collection valued parameter.
Create a Setting object with given value.
Validate that given value matches the
data_type
andcollection_type
.- Parameters:
- label: str = None#
name
- Type:
Parameter label used as pretty identifier for display purposes. Default
- data_type: DataType | Tuple[DataType, ...] = None#
Data type or a tuple of datatypes that this parameter accepts and validates. One of
DataType
. Default: NUMBER.
- collection_type: CollectionType = None#
Data format that this parameter accepts and validates. One of
CollectionType
. Default: SCALAR.
- element_indices: int | list[int] | None = None#
For parameters representing a single value in a collection-valued parent parameter, this field gives the indices of that value. If populated, the
self.name
andself.label
will be updated in post init to include the indices (becoming"<parent name>__<index0>__<index1>__...__<indexN>"
and"<parent label> <indices>"
, respectively). The parent name can then be retrieved withself.parent_name
and the parent label withself.parent_label
.
- property parent_name: str | None#
Returns the parent name.
This None except in element-wise parameters where gives the name of the parent parameter.
- property parent_label: str | None#
Returns the parent label.
This None except in element-wise parameters where gives the label of the parent parameter.
- set(value)#
Create a Setting object with given value.
- static build_data_set(variables, data, attributes=None, extra_variables=None)#
Build an xarray Dataset, where the only DataArray is given by results and coordinates are given by variables. The data is reshaped to correspond to the sizes of the variables. For example,
variables = [(par_x, [1,2,3]), (par_y: [-1, -2])]
will shape the data to 3-by-2 array. If there are not enough variables to reshape the data, remaining dimensions can be given by extra_variables. For example,variables = [(par_x: [1,2,3])], extra_variables=[('y', 2)]
yields the same 3-by-2 data.'y'
will then be a “dimension without coordinate” in xarray terms.- Args:
variables: Coordinates of the set. data: Data Parameter and associated data as a possible nested list. attributes: metadata to attach to the whole Dataset. extra_variables: Valueless dimensions and their sizes.
- validate(value)#
Validate that given value matches the
data_type
andcollection_type
.
- copy(**attributes)#
Return a copy of the parameter, where attributes defined in attributes are replaced.
- build_data_array(data, dimensions=None, coords=None, metadata=None)#
Attach Parameter information to a numerical array.
Given an array of numerical values, returns a corresponding
xr.DataArray
instance that gets its name, units, and dimension names (unless explicitly given) from theParameter
instance.
- create_element_parameter_for(indices)#
Utility for creating an element-wise parameter for a single value in a collection valued parameter.
- Parameters:
indices (int | list[int]) – The indices in the collection for which to create the element-wise parameter.
- Returns:
The element-wise parameter.
- Raises:
InvalidParameterValueError – If
self
is not collection-valued.- Return type: