carpentries-lab / python-aos-lesson

Python for Atmosphere and Ocean Scientists
https://carpentries-lab.github.io/python-aos-lesson/
Other
87 stars 49 forks source link

xarray.compute() should return an xarray instance #48

Closed pletzer closed 2 years ago

pletzer commented 2 years ago

Hi @DamienIrving,

Towards the end of the large data episode, https://carpentries-lab.github.io/python-aos-lesson/10-large-data/index.html, pr_max.compute() is invoked to compute the max precipitation values across all times.

This pr_max.compute() call should:

1) return an xarray (ie pr_max_done = pr_max.compute(), otherwise the result of the computation is lost. Note that the compute method does not modify the dataset, but returns a new dataset with the computation completed.

--or--

2) call the load() method.

From the xarray doc: https://xarray.pydata.org/en/stable/generated/xarray.DataArray.compute.html Manually trigger loading of this array’s data from disk or a remote source into memory and return a new array. The original is left unaltered.

See also: https://xarray.pydata.org/en/stable/generated/xarray.Dataset.load.html#:~:text=Unlike%20compute%2C%20the%20original%20dataset,many%20file%20objects%20on%20disk.