This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Description
In xarray it's possible to automatically close a dataset after opening by opening it using a context manager. From the documentation:
Datasets have a Dataset.close() method to close the associated netCDF file. However, it’s often cleaner to use a with statement:
# this automatically closes the dataset after use
In [5]: with xr.open_dataset("saved_on_disk.nc") as ds:
...: print(ds.keys())
...:
We currently don't have a DataTree.close() method, or any context manager behaviour for open_datatree. To add them presumably we would need to iterate over all file handles (i.e. groups) and close them one by one.
Related to #90 @jhamman @thewtex