Closed
Description
Dear all,
I could not find a differentiation between absolute and relative pressures in the list of units proposed by pint. Is this feature already implemented? If not, I think it would make sense to have it, as it is very common to differentiate between these two pressures. One could have units looking like bar_relative
and bar_absolute
for instance.
Thank you in advance and best regards,
Metadata
Metadata
Assignees
Labels
No labels
Activity
alexpovel commentedon Mar 31, 2020
Wouldn't you then have to ask, relative to what?
1 bar
,1 atm
come to mind.With temperatures, it is more clear.
degC
is relative to273.15 K
.UniqASL commentedon Apr 1, 2020
Thanks for the reply. In English it seems that what I meant is actually called gauge pressure and yes indeed it is relative to atmospheric pressure. And it also seems that in English (in the industry notably) the unit
barg
orpsig
, etc. is used to define this gauge pressure and to differentiate frombara
orpsia
(absolute pressure).dcambie commentedon Nov 2, 2021
I was also interested in a way to define barg relative to ambient pressure, but
ureg.define("barg = 1 * bar; offset: -1")
did not work as expected. Ideally 4 barg = 5 bar. No idea why I get 3e-08, it seems also unrelated to pascaldalito commentedon Nov 6, 2021
@dcambie - There you found a nice bug :-).
The factor 1e-8 results two conversions: 1e-5 (from bar to Pa) and 1e-3 (from kg to g). The latter is because pint uses g but not kg internally as default unit for mass. The main problem is that the units of the first quantity are lost in the code path. Then a number (5.0) is converted to Pa. When using pint such a conversion would normally fail because the dimensionality is checked. However, for the internal calculation path pint explicitly deactivated the dimensionality check... (relevant code is all in registry.py).
I'll send a PR with a fix in a few minutes. Note that you should define the unit with a positive offset (my test code):
Fix offset-calculation for user-defined offset-units (hgrecco#1066)
dalito commentedon Nov 6, 2021
In my opinion gauge pressure should be defined by the user. Adding it to the default unit definition file is problematic because of the unclear reference point as @alexpovel wrote above.
Fix use of offset units for higher dimensional units (e.g. gauge pres…
Mo-Gul commentedon Jan 10, 2023
I totally agree. But in reality it is even worse. Because a constant offset is (of course) just an approximation/simplification. At least this is the case when the reference point is the atmospheric pressure, which is changing with time as we all know from the weather forecast 😄
So my question is, how would one implement that "dynamic offset", i.e. I have a table with the ambient (absolute) pressure and the gauge pressure from some sensor?