question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automated unit handling in operations

See original GitHub issue

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 functions add, subtract, multiply, divide and apply 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 have Emissions|Gases the units Mt CO2.

To make _op_data handle units automatically pint might be useful. Pint can do calculations with units, even with numpy-arrays. My first thoughts for it:

import iam_units
# load iam-Units
registry = iam_units.registry
# calculate something with pint - this should be adapted to pyam timeseries and the units stored there
a = registry.Quantity(5, 'TW')
b = registry.Quantity(3, 'Mt')
c = a / b
# store the unit as string 'TW / Mt' - this needs to be passed to the pyam timeseries
unit = '{:~}'.format(c.units)

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
znichollscommented, May 25, 2021

how should the binary-ops function work if automated unit handling doesn’t work?

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 ignore_units is True, I would put ‘unknown’ as the unit (empty string in pyam is treated as nan often so might be dangerous…).

0reactions
danielhuppmanncommented, Jun 10, 2021

closed via #541

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing An Automated Material Handling System
Here are four steps businesses should take when deciding to add automated material handling systems.
Read more >
What is an Automated Material Handling System? AMHS ...
In today's demanding and busy society, the way we handle materials, orders, and packaging must be efficient and incredibly optimized.
Read more >
Everything To Know About Semi-Automated Material Handling ...
A semi-automated material handling system is a good alternative to full automation. It allows you to remain competitive at a fair price.
Read more >
Automated Material Handling Systems (AMHS)
Automated material handling systems ensure efficient transport of material from one place to another in the manufacturing area – within the same department ......
Read more >
Top Advantages and Disadvantages of Automated Material ...
Advantages of Implementing Automated Material Handling Systems · Save money. Automated systems speed up productivity. · Improve efficiency.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found