xarray_dataclasses.dataset module#

Submodule for Dataset creation.

class AsDataset[source]#

Bases: object

Mix-in class that provides shorthand methods.

classmethod empty(sizes: Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataset[source]#
classmethod empty(sizes: Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) Dataset

Create a Dataset object without initializing data vars.

Parameters:
  • sizes – Sizes of the new Dataset object.

  • order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.

  • kwargs – Args of the Dataset class except for data vars.

Returns:

Dataset object without initializing data vars.

classmethod full(sizes: Dict[str, int], fill_value: Any, order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataset[source]#
classmethod full(sizes: Dict[str, int], fill_value: Any, order: Literal['C', 'F'] = 'C', **kwargs: Any) Dataset

Create a Dataset object whose data vars are filled with given value.

Parameters:
  • sizes – Sizes of the new Dataset object.

  • fill_value – Value for data vars of the new Dataset object.

  • order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.

  • kwargs – Args of the Dataset class except for data vars.

Returns:

Dataset object whose data vars are filled with given value.

new(*args: Any, **kwargs: Any) Any[source]#

Create a Dataset object from dataclass parameters.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

classmethod ones(sizes: Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataset[source]#
classmethod ones(sizes: Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) Dataset

Create a Dataset object whose data vars are filled with ones.

Parameters:
  • sizes – Sizes of the new Dataset object.

  • order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.

  • kwargs – Args of the Dataset class except for data vars.

Returns:

Dataset object whose data vars are filled with ones.

classmethod shaped(func: Callable[[Sequence[int] | int], ndarray[Any, Any]], sizes: Dict[str, int], **kwargs: Any) TDataset[source]#
classmethod shaped(func: Callable[[Sequence[int] | int], ndarray[Any, Any]], sizes: Dict[str, int], **kwargs: Any) Dataset

Create a Dataset object from a shaped function.

Parameters:
  • func – Function to create an array with given shape.

  • sizes – Sizes of the new Dataset object.

  • kwargs – Args of the Dataset class except for data vars.

Returns:

Dataset object created from the shaped function.

classmethod zeros(sizes: Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) TDataset[source]#
classmethod zeros(sizes: Dict[str, int], order: Literal['C', 'F'] = 'C', **kwargs: Any) Dataset

Create a Dataset object whose data vars are filled with zeros.

Parameters:
  • sizes – Sizes of the new Dataset object.

  • order – Whether to store data in row-major (C-style) or column-major (Fortran-style) order in memory.

  • kwargs – Args of the Dataset class except for data vars.

Returns:

Dataset object whose data vars are filled with zeros.

asdataset(dataclass: OptionedClass[PInit, TDataset], reference: DataArray | Dataset | None = None, dataoptions: None = None) TDataset[source]#
asdataset(dataclass: DataClass[PInit], reference: DataArray | Dataset | None = None, dataoptions: None = None) Dataset
asdataset(dataclass: Any, reference: DataArray | Dataset | None = None, dataoptions: DataOptions[TDataset] = DataOptions(xr.Dataset)) TDataset

Create a Dataset object from a dataclass object.

Parameters:
  • dataclass – Dataclass object that defines typed Dataset.

  • reference – DataArray or Dataset object as a reference of shape.

  • dataoptions – Options for Dataset creation.

Returns:

Dataset object created from the dataclass object.