flixopt.utils
This module contains several utility functions used throughout the flixopt framework.
Functions
convert_dataarray
convert_dataarray(data: DataArray, mode: Literal['py', 'numpy', 'xarray', 'structure']) -> Union[List, np.ndarray, xr.DataArray, str]
Convert a DataArray to a different format.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | DataArray | The DataArray to convert. | required | 
| mode | Literal['py', 'numpy', 'xarray', 'structure'] | The mode to convert to. - 'py': Convert to python native types (for json) - 'numpy': Convert to numpy array - 'xarray': Convert to xarray.DataArray - 'structure': Convert to strings (for structure, storing variable names) | required | 
Returns:
| Type | Description | 
|---|---|
| Union[List, ndarray, DataArray, str] | The converted data. | 
Raises:
| Type | Description | 
|---|---|
| ValueError | If the mode is unknown. |