Replies: 3 comments 4 replies
-
Hm, the warning gets confused because unit and entity are different. Multiple levels of answers:
In [1]: import openscm_units
In [2]: u = openscm_units.unit_registry
In [3]: 1 * u.g * u.NOx
Out[3]: 1 <Unit('NOx * gram')>
In [4]: (1 * u.g * u.NOx).to(u.g * u.NO2)
DimensionalityError: Cannot convert from 'NOx * gram' ([NOx] * [mass]) to 'NO2 * gram' ([mass] * [nitrogen]) openscm-units provides the In [6]: with u.context("NOx_conversions"):
...: a = (1 * u.g * u.NOx).to(u.g * u.NO2)
In [7]: a
Out[7]: 1.0 <Unit('NO2 * gram')> but you have to do it explicitly So, by extension, we also handle this the same in primap2 at the moment: NOx is its own thing, if you insist, you can convert it, but then you should still align the unit and the entity. |
Beta Was this translation helpful? Give feedback.
-
Thinking about it more, i wonder whether it's more a general question how far one wants to keep data in their 'original' format.
Maybe it's good to have both :-) |
Beta Was this translation helpful? Give feedback.
-
So far, we have erred on the side of homogenization in PRIMAP. So, we value homogeneity of the datasets in our database over keeping the original format. But that is of course a policy choice for each database and application, not something which can be decided once and for all. |
Beta Was this translation helpful? Give feedback.
-
With the following snippet i get a warning for the NOx unit "'NOx' has a unit of NO2 * kt / year, which is not compatible with an emission rate":
The
df
looks likeI don't get the warning if I set the entity to
NO2
.Is this some definition missing from
openscm-units
? Or shouldn't this be possible as NOx is ambiguous (NO as well NO2)?CEDS uses NOx with
kt NO2
as unit.The checking code is here: https://github.com/pik-primap/primap2/blob/main/primap2/_data_format.py#L355
Beta Was this translation helpful? Give feedback.
All reactions