xarray-contrib / cf-xarray

an accessor for xarray objects that interprets CF attributes
https://cf-xarray.readthedocs.io/
Apache License 2.0
157 stars 39 forks source link

add align? #449

Open dcherian opened 1 year ago

dcherian commented 1 year ago

xarray.align only supports an opt-out exclude kwarg, but for these purposes it seems like we'd want an opt-in include kwarg, so that we only aligned along specific user-specified dimensions (so cfxr.align(..., include="vertical")) Or perhaps cfxr.align_along_dims(..., dims="vertical")

xref https://github.com/Unidata/MetPy/issues/1599#issuecomment-1579492224

I imagine a xarray Dataset going in that contains the variables needing to be unified, which will have multiple vertical coordinates (e.g., 'isobaric', 'isobaric3', 'isobaric5', etc.) and out comes a xarray Dataset with all of the same variables subset to the common levels that are available for all of the variables with a single common vertical coordinate name across all of the variables (e.g., 'isobaric_unified').

dcherian commented 1 year ago

Given that renaming to a common dimension name is probably sensible, I lean towards align_along_dims to make it clear that this new function isn't too closely related to xr.align