js-quantities
js-quantities copied to clipboard
Definition for pH
I created a PR #98 that adds a unit for pH. It's not a standard SI unit, but it's very commonly used instead of using the hydrogen ion concentration so I wanted to add it for the sake of completeness.
Is it possible to convert from pH to H+ concentration (moles/ml) using this library? I wouldn't mind writing a PR for doing this conversion if I could get a pointer on where to add the code.
The unit is very common, I would appreciate it if @gentooboontoo accepted this PR.
I going to do a folk, to add a new unit (water hardness). It is a great library and it must to grow with new units.
Unfortunately, I currently have 2 objections to this proposal :
- First, a
pHunit would conflict with the unit picoHenry of the electrical inductance (3 pH)) - Second,
pHis not a physical quantity but a scale. It actually has no units.
To overcome the first problem, another unit symbol (different than pH) would have to be chosen.
For the second problem, the pH measurement would have to be defined as a concentration but it will not be accurate.
Have you some suggestions?
I agree with your first point and don't see an obvious resolution. About your second point, I'd disagree that it doesn't have units because it's definitely not a unitless number like a simple ratio. pH can be used to estimate the H+ concentration, but it's not just a simple log-10 transformation. After reading up on this, it's not clear to me there's even a standard definition of pH.
I'm thinking that pH isn't appropriate to include in js-quantities after all. But that doesn't solve my issue - we ask that our partners specify a "unit" whenever they send us numerical data. Since js-quantities also allows for each, count etc as a valid unit, validating the unit they sent us was easy. I suppose we can just treat pH as an edge case and validate that unit outside of js-quantitites.
Thanks for your feedback @carlo-quinonez. I am not opposed to include pH as a concentration measure (it will just have to be documented somewhere in the library). Perhaps we could wrap the unit inside square brackets to distinguish it from picoHenry or something like that ([pH])...