Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with "time" dim differently #47

Open
BSchilperoort opened this issue Sep 12, 2024 · 3 comments
Open

Dealing with "time" dim differently #47

BSchilperoort opened this issue Sep 12, 2024 · 3 comments

Comments

@BSchilperoort
Copy link
Contributor

Currently when you regrid data, you only need to specify the target dataset:

ds_regridded = ds_source.regrid.linear(ds_target)

And the dims common to ds_source and ds_target are regridded, except if a dimension is named "time". That one is dropped out. This is of course a bit arbitrary.

Other ways to deal with this would be:

  1. Only regrid dimensions specified by user with an arg/kwarg (a bit cumbersome).
  2. Force users to modify the ds_target object so it only includes the dimensions that they actually want to regrid (like 1. but without the input argument)
  3. Regrid all common dimensions, except for ones specified by users through a kwarg.
  4. Like 3., but automatically drop any dimensions with a non-int/float coordinate values (while warning the user).

To me option 4 sounds like a good compromise between the current behavior and being less arbitrary. It would also make it easier to deprecate the automagical ignoring of dimensions as users are already being warned.


This issue arose from a comment by @dcherian in #46 (comment)_

@dcherian
Copy link

Doesn't xarray-regrid expect 'latitude' and 'longitude' here? You could use cf-xarray https://cf-xarray.readthedocs.io/en/latest/quickstart.html#indexing though it'd be pretty easy to just implement lat/long matching using this attribute table: https://github.com/xarray-contrib/cf-xarray/blob/7072f70292efcc73030653209b44a367510766e0/cf_xarray/criteria.py#L43

@BSchilperoort
Copy link
Contributor Author

Doesn't xarray-regrid expect 'latitude' and 'longitude' here?

Latitude and longitude are not required. It works on any rectilinear grid.

The latitude coordinate values are used in the conservative routine to correct the weights, if they're present. For the other methods this is not needed.

@slevang
Copy link
Collaborator

slevang commented Sep 13, 2024

Yeah I think 3/4 should be flexible enough to handle all cases without imposing an extra burden on typical usage patterns. xarray already uses both exclude and exclude_dims in a number of places, either of those would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants