Data and Datastack¶
This module provides the data_obj and datastack_obj classes for handling experimental data.
Data¶
The data_obj class is a container for experimental data. Create a data object with:
>>> d = esc.data(name="Data name", coordinates, experiment, errors=None, mask=None, copy=False)
All input arrays must be numpy.ndarray type. Arrays will be converted and copied if needed.
Arrays are copied if copy=True, otherwise wrappers are used when possible. If errors=None, errors are calculated as sqrt(experiment) (Poisson distribution). The mask parameter is a boolean array to hide specific data points.
The num_variables property returns the number of coordinates per intensity value. For 2D data with function F(x,y), coordinates should be [x0,y0, x1,y1, x2,y2,…].
2D arrays in the form:
coordinates=[
[x0, y0],
[x1, y1],
[x2, y2]
]
are supported but will be flattened and copied.
Datastack¶
The datastack_obj class is a container for multiple data objects. Used in modelstack to handle data for multiple models.
Create a datastack with:
>>> s = datastack("Name")
- escape.core.data.data(name: str, coordinates: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], intensities: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], errors: Optional[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = None, mask: Optional[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = None, copy: bool = False) data_obj ¶
Create a data_obj container for experimental data.
- Args:
name: Name of data object coordinates: Array of coordinate values (e.g. scattering/wave-vector components) intensities: Array of intensity values errors: Optional error values (defaults to sqrt(intensities)) mask: Optional boolean mask to exclude data points copy: If True, copy all arrays. If False, use wrappers when possible
- Returns:
data_obj instance
- Raises:
ValueError: If coordinates shape length > 2 TypeError: If input arrays are not compatible types
- escape.core.data.datastack(name: str, data: Optional[Union[data_obj, List[data_obj]]] = None) datastack_obj ¶
Create a datastack_obj container for multiple data objects.
- Args:
name: Datastack name data: Optional data_obj or list of data_obj instances
- Returns:
datastack_obj instance
- Raises:
TypeError: If data is not data_obj or list of data_obj
- class escape.core.data.data_obj¶
Container class for experimental data.
- coordinates¶
Get coordinates array with masked points removed.
- errors¶
Get errors array with masked points removed.
- ini_coordinates¶
Get initial coordinates array (ignoring mask).
- ini_errors¶
Get initial errors array (ignoring mask).
- ini_intensities¶
Get initial intensities array (ignoring mask).
- intensities¶
Get intensities array with masked points removed.
- mask¶
Get mask array.
- name¶
Get data object name.
- num_variables¶
Get number of coordinates per intensity point.
- parameters¶
Get list of parameters.
- set_mask(mask: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], copy: bool = False) None ¶
Set mask array to hide certain data points.
- Args:
mask: Boolean array with same length as intensities copy: If True, always copy source data. If False, avoid copying when possible
- class escape.core.data.datastack_obj¶
Container class for multiple data objects.
- data_length¶
Get total number of data points.
- name¶
Get datastack name.
- parameters¶
Get list of parameters.
- set(idx: int, obj: data_obj) None ¶
Replace data object at index.
- Args:
idx: Data index obj: New data_obj
- show(data_configs: Optional[Any] = None, config: Optional[Any] = None, **kwargs) Any ¶
Show data stack in a widget.
- Args:
- data_configs: Either a single DataConfig applied to all data items,
or a list of DataConfig for each data item
config: Optional layout config for the stack widget **kwargs: Additional keyword arguments passed to DataStackLayout
- Returns:
DataStackLayout widget displaying the data stack