Skip to content
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

How to handle ppm and ppmv #384

Closed
tomchor opened this issue Jun 5, 2016 · 3 comments
Closed

How to handle ppm and ppmv #384

tomchor opened this issue Jun 5, 2016 · 3 comments

Comments

@tomchor
Copy link

tomchor commented Jun 5, 2016

I am trying to figure out a way to handle ppm (g/g) and ppmv (mole/mole) in pint but can't. Since I can't find ppm inside constants_en.txt and default_en.txt I'm guessing it's because there is no native support for that. Is there a suggested way to deal with that?

What I've tried:

In [3]: ureg.define('ppm = 1e-6*g/g')

In [4]: a=1*ureg['ppm']

In [5]: a
Out[5]: <Quantity(1, 'ppm')>

In [7]: a.to('g/g')
Out[7]: <Quantity(1.0, 'dimensionless')>

I expected the last output to be <Quantity(1.0e-6, 'dimensionless')>. I'm trying to figure out a way to define ppm such that

a * gram = 1e-6 grams

and similarly with ppmv.

Cheers

@tomchor
Copy link
Author

tomchor commented Jun 5, 2016

Update: kind of made it work by defining as

ureg.define('ppm = mg/kg')

but I'm not sure if that's correct

@noahl
Copy link
Contributor

noahl commented Jun 10, 2016

I would take the attitude that the units in 'g/g' (and 'mole/mole') are
abbreviations. Try defining two new dimensions: 'g mixture' and 'g solute'.
Then define ppm as 'g solute / g mixture'. Multiplying a ppm value by 'g
mixture' should produce a correct value with units 'g solute', and
similarly with ppmv.

I hope that helps.

On Sun, Jun 5, 2016 at 2:22 PM, tomchor [email protected] wrote:

Update: kind of made it work by defining as

ureg.define('ppm = mg/kg')

but I'm not sure if that's correct


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#384 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AABB8rR4dFiapfc5_8_p3j633cNkvf0qks5qIz4tgaJpZM4Iua5O
.

@hgrecco
Copy link
Owner

hgrecco commented Dec 20, 2019

Exactly as @noahl said. Closing now, feel free too open another if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants