---
# System prepended metadata

title: Xarray Office Hours Notepad

---

# Xarray Office Hours Notepad

## Important Links

- [Code of Conduct](https://github.com/pydata/xarray/blob/main/CODE_OF_CONDUCT.md)
- [Private anonymous feedback form](https://forms.gle/KDMGyu6hEPRwDva68)
- [Public discussion and comments](https://github.com/pydata/xarray/discussions/7217)

If possible, we encourage you to open a [new Github Discussion](https://github.com/pydata/xarray/discussions/new) for your question. This is entirely optional, but will allow other users to benefit from answers to your questions.



## 2022 Nov 15

- 🎉 Innaugural Xarray virtual office hours 
- [Event-specific announcement](https://github.com/pydata/xarray/discussions/7217)

### Notes

#### Regridding

Pangeo Discourse: https://discourse.pangeo.io/t/conservative-region-aggregation-with-xarray-geopandas-and-sparse/2715/16

Creating an environment file after you've added a few packages to an existing environment:
conda env export -n ENVNAME --from-history

What do we do with the "increased chunksize warning"?

Better dask memory management for data reading/writing in parallel
https://github.com/dask/distributed/discussions/7128

Get dask logs from the dask dashboard → Info

```python
ds = xr.Dataset({"a": ("z", np.linspace(0, 1, 100))})

coord1 = np.arange(10)
coord2 = np.arange(10)
index = pd.MultiIndex.from_product((coord1, coord2), names=["coord1", "coord2"])

ds.assign_coords(z=index).unstack("z")
```

Gist which contains problem description, notes, and solution: 
https://gist.github.com/andrewdnolan/3214d59375e667aaf573d3e0e2264570

### era5 wind stress curl

- https://xgcm.readthedocs.io/en/latest/xgcm-examples/02_mitgcm.html
- https://xgcm.readthedocs.io/en/latest/grids.html
- https://gist.github.com/zxdawn/49c73e4d1ef9043580644e57eaa16d83

TODO - open an issue for an XGCM example for ERA5

#### apply_ufunc regression with statsmodels

- appl_ufunc tutorial: https://tutorial.xarray.dev/advanced/apply_ufunc/apply_ufunc.html

#### CESM gridding

What xarray tools are available to average non-uniform parts of grid?
How can we find data by values of labeled indices?

- xarray issues: https://github.com/pydata/xarray/issues
    we are opening a new issue to move user warning of weighting non-aligned datasets into weighting function (i.e. ds.weighted(ds2) runs fine, but then ds.mean() errors because ds and ds2 don't have the same indices)


- xarray.DataSet.sel has no examples in the docs!
- tutorial on indexing in xarray: https://tutorial.xarray.dev/workshops/online-tutorial-series/02_indexing.html?highlight=sel
- masking with where:
  - https://docs.xarray.dev/en/stable/user-guide/indexing.html#masking-with-where
  - https://github.com/pydata/xarray/issues/2028 (for transitioning to set_xindex)
- weighted means:
  -  https://tutorial.xarray.dev/fundamentals/03.4_weighted.html
  -  https://docs.xarray.dev/en/stable/user-guide/computation.html#weighted-array-reductions
- selecting multiple data arrays:
   - https://docs.xarray.dev/en/stable/user-guide/data-structures.html#transforming-datasets
- pop-tools: https://pop-tools.readthedocs.io/en/latest/examples/index.html

#### Open_Zarr()

https://discourse.pangeo.io/t/attributeerror-entrypoint-object-has-no-attribute-key-stops-computation-after-a-process-has-been-running/2796 

things we're discussing:
1. testing code with dask 
    2. numpy (no dask)
    3. LocalCluster
    4. GatewayCluster

using context managers for testing code with different dask configurations
(https://stackoverflow.com/questions/53394935/what-is-the-right-way-to-close-a-dask-localcluster)

1. How to share datasets for troubleshooting
  https://docs.2i2c.org/en/latest/data/cloud.html#scratch-bucket 