xrdantic.DataTree#
- pydantic model xrdantic.DataTree#
Base class for DataTree definitions.
A DataTree represents a hierarchical collection of Datasets and other DataTrees, similar to xarray.DataTree. It can contain Dataset fields, other DataTree fields, coordinate fields, and attribute fields.
Examples
>>> class SimulationTree(DataTree): ... coarse_grid: WeatherDataset ... fine_grid: WeatherDataset ... metadata: MetadataDataset ... simulation_name: Attr[str] = "default"
>>> sim_tree = SimulationTree(coarse_grid=coarse_dataset, fine_grid=fine_dataset, metadata=meta_dataset) >>> xr_tree = sim_tree.to_xarray()
- Raises:
ValidationError – If the model doesn’t have at least one Dataset or DataTree field:
- classmethod new(**dataset_and_datatree_instances)#
Create a new DataTree instance with the given Dataset and DataTree instances.
- Return type: