-
Notifications
You must be signed in to change notification settings - Fork 64
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
xclim.convert_units_to
issues with accuracy
#2121
Comments
xclim.convert_units
issues with accuracyxclim.convert_units_to
issues with accuracy
Is it possible that the outputs now reflect the units of the input array by default? i.e. This appears to be the case. For out1, this is fixed by: out1 = xclim.core.units.convert_units_to(out1, "degF days") Update: This is very odd behaviour. This should be reporting in "K days" by default. |
Indicator definitions seem to clearly indicate output units of K days but seems to not get applied correctly? e.g. xclim/xclim/indicators/atmos/_temperature.py Line 814 in e4aca67
|
I don't think we explicitly test Fahrenheit conversions very often (or even at all?) |
Oups, I realize that what you guys were saying, I'll leave the plot there out1.plot(label="K and degC", linestyle="-", ax=ax)
f = convert_units_to("degC day", "degF day")
(out2/f).plot(label="degF and degC / conv-factor", marker="s", markersize=10, linestyle="none", ax=ax)
(out3/f).plot(label="degF and K / conv-factor", marker="o", linestyle="none", ax=ax)
ax.legend()
ax.set_title("Different input units"); I have a different gridpoint, so the plot is a bit different, but the idea is the same. By taking the conversion factor between degC d and degF d |
My issue here is that the initial calculations report that all three curves report having units If you try going the other way around ( When converting out2 and out3 to |
Yes, I understand. The problem is already present in the index function print(xclim.indices.growing_degree_days(tas=ds_pt.tas, thresh="5 degC", freq="MS").units)
print(xclim.indices.growing_degree_days(tas=ds_pt.tas_F, thresh="5 degC", freq="MS").units)
>>> 'K d'
>>> 'K d' both give 'K d', but the magnitudes of the values are clearly 'K d' and 'degF d' |
print(cumulative_difference(ds_pt.tas, "5 degC", ">", "MS").units) # 'd K' expected
print(cumulative_difference(ds_pt.tas_F, "5 degC", ">", "MS").units) # 'd degF' expected?
>>> d K
>>> d K
else:
out.attrs.update(pint2cfattrs(orig_u * freq_u, is_difference)) |
This was fixed in #2122 |
Setup Information
Description
On PAVICS I'm seeing a difference in the expected unit outputs when comparing Celsius, Kelvin and Fahrenheit
Steps To Reproduce
Additional context
No response
Contribution
Code of Conduct
The text was updated successfully, but these errors were encountered: