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

upgrade to use units package #10

Open
sebkopf opened this issue Oct 11, 2019 · 3 comments
Open

upgrade to use units package #10

sebkopf opened this issue Oct 11, 2019 · 3 comments

Comments

@sebkopf
Copy link
Collaborator

sebkopf commented Oct 11, 2019

consider reimplementing on top of the nice units package https://r-quantities.github.io/units/index.html

Note: with the latest version, this would automatically take care of units getting rendered correctly in plots and ggplots

Things to think about for implementation in microbial kitchen:

  • will have to implement the autoscaling feature
  • will have to find a simple way to set the default base units
@sebkopf
Copy link
Collaborator Author

sebkopf commented Jan 8, 2025

Implementation details:

  • Amount: mole, mol and SI prefixes all work in units package (`set_units(1, "mmole") |> set_units("µmol")
  • Mass: g and all SI prefixes work
  • Volume: l and L and SI prefixes work
  • Temperature: degC, degK (although plain K also works), degF instead of just C/K/F but could be converted in the qty function. Technical mK also works but not sure that's advisable
  • Pressure: bar, atm, psi, torr and SI prefixes all supported, % SP would need to be implemented in the qty function to convert to bar (no units with % symbol allowed)
  • Molecular Weight: Da is not included but easily added with install_unit("Da", "g/mol", "Dalton") and then all SI prefixes work as well
  • Molarity: M is not included but added with install_unit("M", "mol/L", "molarity") and then all SI prefixes and conversions work
  • Density: supported
  • Gas solubility: with the addition of molarity, this is also automatically supported --> e.g. set_units(760, "mM/bar") |> set_units("M/atm") works

With this, ALL the quantity calculations should work automatically. Also units can be kept the way they are when generating a qty (e.g. keep pressure in psi if entered that way) or can be converted with to_base_units = TRUE (default FALSE) and to_best_prefix = TRUE (default TRUE). Just the carbonate chemistry needs a little more adjustments

--> make sure to issue appropriate depreciation messages for old functions

@sebkopf sebkopf changed the title consider units package upgrade to use units package Jan 8, 2025
@sebkopf
Copy link
Collaborator Author

sebkopf commented Jan 8, 2025

consider adding other useful units like "cell" so that "cell/ml" and "cell/L" automatically work for calculations

@sebkopf
Copy link
Collaborator Author

sebkopf commented Jan 8, 2025

--> this will be best done in #1 separate chemunits package

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

No branches or pull requests

1 participant