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

Possible replacement for Unitful #209

Open
ph-kev opened this issue Mar 4, 2025 · 0 comments
Open

Possible replacement for Unitful #209

ph-kev opened this issue Mar 4, 2025 · 0 comments

Comments

@ph-kev
Copy link
Member

ph-kev commented Mar 4, 2025

A possible replacement for Unitful.jl is UDUnits.jl.

Compared to Unitful.jl, the pros for using UDUnits.jl are

  1. In place conversion via Converter function.
  2. Support expressions like W m^2 (although, it doesn't support W * m^2, but this can easily be fixed by parsing the expression beforehand and I don't think any of the diagnostics write units like this)
  3. Should be compatible with NetCDF files outside of CliMA since "the values of the units attributes [of NetCDF files] are character strings that are recognized by UNIDATA’s UDUNITS package..." in section 3.1 of the CF Conventions. Note that the UNIDATA’s UDUNITS package is a C library and UDUnits.jl is a Julia port of it.
  4. Support units that we care about like degree_east and is generally more flexible with what units it can parse. For example, s, sec, secs, second, and seconds are all recognizable by UDUnits.jl and only s is recognizable by Unitful.jl. For another example, m**2 (Python syntax) is parseable by UDUnits.jl, but is not by Unitful.jl.
  5. Less dependencies. See Project.toml of Unitful.jl and UDUnits.jl respectively.

The cons for using UDUnits.jl are

  1. Not as popular as Unitful.jl, so there may be potential bugs that have not been discovered.
  2. Doesn't support conversion of non-Float64 numbers.
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

1 participant