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

Unit handling code is slow #43

Open
mcgibbon opened this issue Aug 21, 2018 · 2 comments
Open

Unit handling code is slow #43

mcgibbon opened this issue Aug 21, 2018 · 2 comments

Comments

@mcgibbon
Copy link
Owner

@JoyMonteiro brought up that currently when run in SCM mode, unit conversion checking takes up a significant amount of CliMT's runtime. We may want to add a faster backend for unit handling.

See climt/issues/75 for original discussion of this issue.

cfunits is a good candidate as a backend, but it appears to only work on Python 2. When I run cfunits-1.5.1 on Python 3, I get:

ValueError: Bad python version: cf requires 2.6 <= python < 3.0. Got 3.5.2

The more official package appears to be cf-units, hosted by the Met office, but that is also incompatible with Python 3 according to their docs and my attempt to download it through conda. We could try to fix it to work with Python 3 and submit a PR to them.

Or we could look for another option.

@JoyMonteiro
Copy link
Collaborator

cf-units now works on Python 3.6/3.7. Can we restart discussion/work around this issue?

@JoyMonteiro
Copy link
Collaborator

I was playing around with the code, and if I change this line:

elif unit_registry(value.attrs['units']) != unit_registry(units):

With an equivalent statement using cf-units, the code is twice as fast. cf-units supports all
aliases setup in this file. It does not understand 'dimensionless', and that needs to be handled. Otherwise, this should be easy to optimize -- use cfunits if it exists.

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