Return the data in this node as a new xarray.Dataset object. Parameters ---------- inherit : bool or {"all_coords", "indexes"}, default True Controls which coordinates are inherited from parent nodes. - True or "indexes": inherit only indexe
(
self, inherit: bool | Literal["all_coords", "indexes"] = True
)
| 696 | ds = dataset |
| 697 | |
| 698 | def to_dataset( |
| 699 | self, inherit: bool | Literal["all_coords", "indexes"] = True |
| 700 | ) -> Dataset: |
| 701 | """ |
| 702 | Return the data in this node as a new xarray.Dataset object. |
| 703 | |
| 704 | Parameters |
| 705 | ---------- |
| 706 | inherit : bool or {"all_coords", "indexes"}, default True |
| 707 | Controls which coordinates are inherited from parent nodes. |
| 708 | |
| 709 | - True or "indexes": inherit only indexed coordinates (default). |
| 710 | - "all_coords": inherit all coordinates, including non-index coordinates. |
| 711 | - False: only include coordinates defined at this node. |
| 712 | |
| 713 | See Also |
| 714 | -------- |
| 715 | DataTree.dataset |
| 716 | """ |
| 717 | coord_vars, indexes = self._resolve_inherit(inherit) |
| 718 | variables = dict(self._data_variables) |
| 719 | variables |= coord_vars |
| 720 | dims = ( |
| 721 | dict(self._node_dims) |
| 722 | if inherit is False |
| 723 | else calculate_dimensions(variables) |
| 724 | ) |
| 725 | return Dataset._construct_direct( |
| 726 | variables, |
| 727 | set(coord_vars), |
| 728 | dims, |
| 729 | None if self._attrs is None else dict(self._attrs), |
| 730 | indexes, |
| 731 | None if self._encoding is None else dict(self._encoding), |
| 732 | None, |
| 733 | ) |
| 734 | |
| 735 | @property |
| 736 | def has_data(self) -> bool: |