xarray_dataclasses.dataarray module#
Submodule for DataArray creation.
- class AsDataArray[source]#
Bases:
object
Mix-in class that provides shorthand methods.
- classmethod empty(shape: Sequence[int] | int | Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataArray [source]#
- classmethod empty(shape: Sequence[int] | int | Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) DataArray
Create a DataArray object without initializing data.
- Parameters:
shape – Shape or sizes of the new DataArray object.
order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.
kwargs – Args of the DataArray class except for data.
- Returns:
DataArray object without initializing data.
- classmethod full(shape: Sequence[int] | int | Dict[str, int], fill_value: Any, order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataArray [source]#
- classmethod full(shape: Sequence[int] | int | Dict[str, int], fill_value: Any, order: Literal['C', 'F'] = 'C', **kwargs: Any) DataArray
Create a DataArray object filled with given value.
- Parameters:
shape – Shape or sizes of the new DataArray object.
fill_value – Value for the new DataArray object.
order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.
kwargs – Args of the DataArray class except for data.
- Returns:
DataArray object filled with given value.
- new(*args: Any, **kwargs: Any) Any [source]#
Create a DataArray object from dataclass parameters.
- Parameters:
args (Any) –
kwargs (Any) –
- Return type:
Any
- classmethod ones(shape: Sequence[int] | int | Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataArray [source]#
- classmethod ones(shape: Sequence[int] | int | Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) DataArray
Create a DataArray object filled with ones.
- Parameters:
shape – Shape or sizes of the new DataArray object.
order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.
kwargs – Args of the DataArray class except for data.
- Returns:
DataArray object filled with ones.
- classmethod shaped(func: Callable[[Sequence[int] | int], ndarray[Any, Any]], shape: Sequence[int] | int | Dict[str, int], **kwargs: Any) TDataArray [source]#
- classmethod shaped(func: Callable[[Sequence[int] | int], ndarray[Any, Any]], shape: Sequence[int] | int | Dict[str, int], **kwargs: Any) DataArray
Create a DataArray object from a shaped function.
- Parameters:
func – Function to create an array with given shape.
shape – Shape or sizes of the new DataArray object.
kwargs – Args of the DataArray class except for data.
- Returns:
DataArray object created from the shaped function.
- classmethod zeros(shape: Sequence[int] | int | Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataArray [source]#
- classmethod zeros(shape: Sequence[int] | int | Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) DataArray
Create a DataArray object filled with zeros.
- Parameters:
shape – Shape or sizes of the new DataArray object.
order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.
kwargs – Args of the DataArray class except for data.
- Returns:
DataArray object filled with zeros.
- asdataarray(dataclass: OptionedClass[PInit, TDataArray], reference: DataArray | Dataset | None = None, dataoptions: None = None) TDataArray [source]#
- asdataarray(dataclass: DataClass[PInit], reference: DataArray | Dataset | None = None, dataoptions: None = None) DataArray
- asdataarray(dataclass: Any, reference: DataArray | Dataset | None = None, dataoptions: DataOptions[TDataArray] = DataOptions(xr.DataArray)) TDataArray
Create a DataArray object from a dataclass object.
- Parameters:
dataclass – Dataclass object that defines typed DataArray.
reference – DataArray or Dataset object as a reference of shape.
dataoptions – Options for DataArray creation.
- Returns:
DataArray object created from the dataclass object.