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

Use cf_xarray.accessor._get_with_standard_name in gsw_xarray #465

Closed
rcaneill opened this issue Aug 17, 2023 · 2 comments
Closed

Use cf_xarray.accessor._get_with_standard_name in gsw_xarray #465

rcaneill opened this issue Aug 17, 2023 · 2 comments

Comments

@rcaneill
Copy link
Contributor

Hello,

In gsw_xarray we are relying on cf_xarray for finding variables based on standard names. I remarked that using function cf_xarray.accessor._get_with_standard_name was about 1000 times faster than using the usual ds.cf["standard_name_of_variable"].
I guess that the difference comes from the fact that the ds.cf method also checks for e.g. units, axes, etc.
It would be better for us to only use the cf_xarray.accessor._get_with_standard_name function.

My question is the following: would it be possible to open this function as a public and not internal one? This would more or less be a guaranty for us that we don't base our code on something internal to cf_xarray. The other option would be that we copy the function to gsw_xarray, does the license authorize us to do it? (I guess so but I'm not sure)

Thanks!

@dcherian
Copy link
Contributor

dcherian commented Aug 17, 2023

use ds.cf.standard_names . That way you can grab the dict once and do lookups on it.

1000 times faster than using

Yes this is unfortunate. I made a bad choice on the order of inner loops. Its fixable but I don't know when I'll get to it.

@rcaneill
Copy link
Contributor Author

Perfect! That works fine :)
Thanks

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

2 participants