-
Notifications
You must be signed in to change notification settings - Fork 123
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
Automated unit handling in operations #536
Comments
I started playing around with this feature and found a reasonably smart way to handle this using the iam-units package (which is based on pint), see danielhuppmann@6509394 Follow-up question: how should the binary-ops function work if automated unit handling doesn't work? This happens if the units are not defined in the iam-units registry.
@znicholls @khaeru @gidden @Rlamboll, any thoughts? |
My default here would be to raise an error about the unknown unit or let pint simply raise a dimensionality error or similar... After that, option 2 sounds good with one tweak. If |
I'm asking myself similar questions at khaeru/genno#32. The patterns are slightly different, but some reusable ideas:
As I mention in the linked issue, one possibility is a package-level global or option (or 2) that controls the "strictness" (behaviour from the numbered lists above). |
The approach looks really nice :) Some thoughts about it:
As a solution we could add a keyword A question to dimensionless units: these might be wanted and converted into percentage later. Is that possible with the iam-units? |
closed via #541 |
This issue shall describe the problem already noted in the PR #535
The
_op_data
-function doesn't handle units automatically. I guess, the corresponding functionsadd
,subtract
,multiply
,divide
andapply
only work if the timeseries have the same units, but I didn't test yet what it does if timeseries have different units.When doing
df.multiply('Emission Factor|Gases', 'Final Energy|Gases', 'Emissions|Gases')
I'd expect to haveEmissions|Gases
the unitsMt CO2
.To make
_op_data
handle units automaticallypint
might be useful. Pint can do calculations with units, even with numpy-arrays. My first thoughts for it:I think it's important to handle units when calculating on the variables-axis, e.g. emissions = emission factor * energy. However on other axis like regions or scenarios I'm not sure how much it makes sense and how difficult the implementation would be to handle different units at once.
The text was updated successfully, but these errors were encountered: