cf-xarray icon indicating copy to clipboard operation
cf-xarray copied to clipboard

use `"positive"` attribute in `differentiate` and `integrate`

Open dcherian opened this issue 3 years ago • 1 comments

The 'positive': 'up' or 'positive': 'down' attribute should be taken into account when calculating derivatives.

I think we could add .cf.differentiate(..., fix_sign=True) (default False) as an opt-in to this approach. In practice, I think we just fix the sign of the coordinate variable before passing it on to xarray.

Thoughts on adding this?

I think we could come up with a better kwarg name.

I think it should raise an error if fix_sign is True and "positive" not in attrs

dcherian avatar Mar 18 '21 15:03 dcherian

Sounds good to me.

Just one thought about adding kwargs to xarray functions. Maybe it's easier if we always use the same kwarg, either a bool (like use_cf) or a dict (like cf_kwargs)? It might make more clear what is added by cf_xarray and easier to switch on/off all cf_xarray extra features.

malmans2 avatar Mar 18 '21 16:03 malmans2