xarray_dataclasses.dataarray module#
Submodule for DataArray creation.
- class AsDataArray[source]#
Bases:
object
Mix-in class that provides shorthand methods.
- classmethod empty(shape: Shape | Sizes, order: Order = 'C', **kwargs: Any) TDataArray [source]#
- classmethod empty(shape: Shape | Sizes, order: Order = 'C', **kwargs: Any) xr.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: Shape | Sizes, fill_value: Any, order: Order = 'C', **kwargs: Any) TDataArray [source]#
- classmethod full(shape: Shape | Sizes, fill_value: Any, order: Order = 'C', **kwargs: Any) xr.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: Shape | Sizes, order: Order = 'C', **kwargs: Any) TDataArray [source]#
- classmethod ones(shape: Shape | Sizes, order: Order = 'C', **kwargs: Any) xr.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[[Shape], AnyArray], shape: Shape | Sizes, **kwargs: Any) TDataArray [source]#
- classmethod shaped(func: Callable[[Shape], AnyArray], shape: Shape | Sizes, **kwargs: Any) xr.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: Shape | Sizes, order: Order = 'C', **kwargs: Any) TDataArray [source]#
- classmethod zeros(shape: Shape | Sizes, order: Order = 'C', **kwargs: Any) xr.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: AnyXarray | None = None, dataoptions: None = None) TDataArray [source]#
- asdataarray(dataclass: DataClass[PInit], reference: AnyXarray | None = None, dataoptions: None = None) xr.DataArray
- asdataarray(dataclass: Any, reference: AnyXarray | 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.