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

R20 update #314

Merged
merged 65 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d51c131
add tests for r20 units and start work on getting the database for r2…
phlptp Mar 22, 2020
23c485f
add more output for the test
phlptp Mar 22, 2020
e1fda20
more additions to r20
phlptp Mar 26, 2020
e0d6233
add a bunch more r20 translations
phlptp Apr 21, 2020
d7ebc63
more r20 conversions
phlptp Apr 23, 2020
f10a690
more updates for r20
phlptp Apr 25, 2020
bafa13e
added some more r20 conversions
phlptp Nov 26, 2020
5717809
add more units and conversions
phlptp Dec 1, 2020
e98e13e
start modifying the commodities to match up with the harmonized system
phlptp Dec 2, 2020
7dac3a9
more commodities updates
phlptp Feb 5, 2021
6932cbb
more commodity definitions.
phlptp May 16, 2022
982aeb5
update commodity docs
phlptp May 16, 2022
05cc4b7
more commodity definitions to merge in main
phlptp Dec 29, 2022
8a0254d
update some more units
phlptp May 27, 2023
c7bdf7f
more work on updating commodities and packaging
phlptp Jun 3, 2023
d5ec57c
Merge branch 'main' into r20_update
phlptp Aug 28, 2023
df2dcf6
Merge remote-tracking branch 'remotes/origin/main' into r20_update
phlptp Sep 2, 2023
aca9ac3
all r20 commodities off default
phlptp Sep 14, 2023
a17fc20
fix more conversions and tests, fix issues with parsing square/square…
phlptp Sep 19, 2023
b6df882
more units to match
phlptp Sep 21, 2023
f138d3e
rework unit constructors to be more unambiguous
phlptp Sep 23, 2023
26cd9a1
more test fixes
phlptp Sep 24, 2023
09359ba
rearrange the bracketmodifiers section
phlptp Sep 27, 2023
c1f4e0f
more work on the unit string conversions
phlptp Oct 1, 2023
017056c
clear more mismatches
phlptp Oct 2, 2023
750512a
fix a few more units
phlptp Oct 2, 2023
f0b2901
fix more unit and conversions
phlptp Oct 5, 2023
f77bb9c
fix a few more conversions
phlptp Oct 16, 2023
ac682f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2023
e2eb613
update pre-commit
phlptp Oct 16, 2023
23b70e1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2023
a57d439
fix a few code checks
phlptp Oct 16, 2023
76fc084
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2023
4b4f6a2
fix a few of the tests
phlptp Oct 17, 2023
2e86472
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 17, 2023
ed6e646
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2023
78055f4
fix a few more unit conversions
phlptp Oct 18, 2023
81d8245
rework pressure units
phlptp Oct 20, 2023
0f9e38c
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 20, 2023
3ce619b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 20, 2023
5d9e9b9
better handing of US and repeated modifiers
phlptp Oct 20, 2023
871c5eb
fix remaining tests
phlptp Oct 22, 2023
6c60d21
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 22, 2023
3a17e7e
fix some compilation issues with the recommendation 20 unit inclusion…
phlptp Oct 23, 2023
78031ed
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2023
6c12255
clang tidy and gcc 4.8 compilation
phlptp Oct 23, 2023
6ed3bdd
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 23, 2023
6b23813
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2023
d10ee52
line length fixes
phlptp Oct 23, 2023
c857f1c
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 23, 2023
1118dd8
add fuzzing test
phlptp Oct 23, 2023
8bf1cff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2023
ea5b4f2
add additional check on the r20 unit conversions
phlptp Oct 23, 2023
0387ff2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2023
40cf626
fix a fuzzing issue
phlptp Oct 24, 2023
c4cf996
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2023
0f31648
clang-tidy fixes
phlptp Oct 24, 2023
71b63dc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2023
f2bdc2c
more clang-tidy fixes
phlptp Oct 24, 2023
83d96e8
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 24, 2023
d5bc696
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2023
ad7a507
fix fuzz issue
phlptp Oct 25, 2023
3af298a
Merge branch 'r20_update' of https://github.com/LLNL/units into r20_u…
phlptp Oct 25, 2023
7303e26
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 25, 2023
de48700
more clang-tidy fixes
phlptp Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add more units and conversions
phlptp committed May 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5717809c51e67e9d02ccc4b8050e270402b22e47
3 changes: 2 additions & 1 deletion docs/user-guide/custom_units.rst
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ there are a few custom count units in use for specific clinical units Many of th
So there is no translation to other units and cannot be converted except to multiple of the same unit. There are often well established tests for these units but no good way to convert them to other units. Many of these units come from `UCUM <https://unitsofmeasure.org/ucum.html>`_.

- custom_unit(37): is `hounsfield units <https://radiopaedia.org/articles/hounsfield-unit?lang=us>`_ used it CT and radiology
- many units in UCUM are defined like `[MPL'U]` or `[mclg'U]` for this context they define some unit which doesn't interact with other units in any known fashion. The notion used in the units library for string translations is that these define custom units. Rather than individually define the library takes a hash of the part of the unit coming before the `'U]'` and generates a 10 bit hash. That 10 bit hash is used as the custom code for the units.
- custom_unit(49): is `erlang` used in telephone carrying capacity <https://en.wikipedia.org/wiki/Erlang_(unit)>`_
- many units in UCUM are defined like `[MPL'U]` or `[mclg'U]` for this context they define some unit which doesn't interact with other units in any known fashion. The notion used in the units library for string translations is that these define custom units. Rather than individually defining them, the library takes a hash of the part of the unit coming before the `'U]'` and generates a 10 bit hash. That 10 bit hash is used as the custom code for the units.
- custom_unit(77): is global warming potential related to climate operations
- custom_unit(78): is global temperature change potential

28 changes: 14 additions & 14 deletions units/r20_conv.cpp
Original file line number Diff line number Diff line change
@@ -770,7 +770,7 @@ namespace precise {
unitD{"E08", "megawatt per hertz", electrical::MW/Hz},
unitD{"E09", "milliampere hour", milli*A*hr},
unitD{"E10", "degree day", deg*day},
unitD{"E11", "gigacalorie",giga*calorie},
unitD{"E11", "gigacalorie",giga*energy::cal_it},
unitD{"E12", "mille", one / count},
unitD{"E14", "kilocalorie (international table)",kilo*energy::cal_it},
unitD{"E15", "kilocalorie (thermochemical) per hour", kilo*energy::cal_th},
@@ -2134,7 +2134,7 @@ namespace precise {
unitD{"P5", "five pack", {5, one}},
unitD{"P50", "weber metre", Wb*m},
unitD{"P51", "mol per kilogram pascal", mol/(kg*Pa)},
unitD{"P52", "mol per cubic metre pascal", mol/(m.pow(3)*m*Pa)},
unitD{"P52", "mol per cubic metre pascal", mol/(m.pow(3)*Pa)},
unitD{"P53", "unit pole", cgs::unitpole},
unitD{"P54", "milligray per second", milli* gray / s},
unitD{"P55", "microgray per second", micro* gray / s},
@@ -2163,7 +2163,7 @@ namespace precise {
unitD{"P76", "microsievert per minute", micro* sievert / min},
unitD{"P77", "nanosievert per minute", nano* sievert / min},
unitD{"P78", "reciprocal square inch", in.pow(2).inv()},
unitD{"P79", "pascal square metre per kilogram", one / count},
unitD{"P79", "pascal square metre per kilogram", Pa*m.pow(2)/kg},
unitD{"P8", "eight pack", {8, one}},
unitD{"P80", "millipascal per metre", milli* Pa / m},
unitD{"P81", "kilopascal per metre", kilo* Pa / m},
@@ -2190,7 +2190,7 @@ namespace precise {
one / count},
unitD{
"P99",
"mole per cubiv metre to the power sum of stoichiometric numbers",
"mole per cubic metre to the power sum of stoichiometric numbers",
one / count},
unitD{"PA", "packet", one / count},
unitD{"PAL", "pascal", Pa},
@@ -2221,9 +2221,9 @@ namespace precise {
unitD{"PY", "peck dry (US)", us::dry::peck},
unitD{"PZ", "peck dry (UK)", imp::peck},
unitD{"Q10", "joule per tesla", J / T},
unitD{"Q11", "erlang", one / count},
unitD{"Q12", "octet", one / count},
unitD{"Q13", "octet per second", one / count},
unitD{"Q11", "erlang", generate_custom_unit(49)},
unitD{"Q12", "octet", precise_unit(8.0, precise::count)},
unitD{"Q13", "octet per second", precise_unit(8.0, precise::count)/s},
unitD{"Q14", "shannon", data::shannon},
unitD{"Q15", "hartley", data::hartley},
unitD{"Q16", "natural unit of information", data::bit_s},
@@ -2261,15 +2261,15 @@ namespace precise {
unitD{"RH", "running or operating hour", one / count},
unitD{"RK", "roll metric measure", one / count},
unitD{"RL", "reel", one / count},
unitD{"RM", "ream", one / count},
unitD{"RM", "ream", {500, count, commodities::paper}},
unitD{"RN", "ream metric measure", one / count},
unitD{"RO", "roll", one / count},
unitD{"ROM", "room", one / count},
unitD{"RP", "pound per ream", one / count},
unitD{"RP", "pound per ream", lb / precise_unit{500, count, commodities::paper}},
unitD{"RPM", "revolutions per minute", rpm},
unitD{"RPS", "revolutions per second", {constants::tau, rad* Hz}},
unitD{"RS", "reset", one / count},
unitD{"RT", "revenue ton mile", one / count},
unitD{"RT", "revenue ton mile", currency*ton*mile},
unitD{"RU", "run", one / count},
unitD{"S3", "square foot per second", ft.pow(2) / s},
unitD{"S4", "square metre per second", m.pow(2) / s},
@@ -2278,7 +2278,7 @@ namespace precise {
unitD{"S7", "storage unit", one / count},
unitD{"S8", "standard advertising unit", one / count},
unitD{"SA", "sack", one / count},
unitD{"SAN", "half year (6 months)", precise_unit(0.5, precise::yr)},
unitD{"SAN", "half year (6 months)", {0.5, precise::yr}},
unitD{"SCO", "score", {20.0, count}},
unitD{"SCR", "scruple", apothecaries::scruple},
unitD{"SD", "solid pound", one / count},
@@ -2343,7 +2343,7 @@ namespace precise {
"thousand cubic metre per day",
kilo* m.pow(3) / time::day},
unitD{"TR", "ten square foot", ten* ft.pow(2)},
unitD{"TRL", "trillion (EUR)", tera*count},
unitD{"TRL", "trillion (EUR)", tera*currency},
unitD{"TS", "thousand square foot", kilo* ft.pow(2)},
unitD{"TSD", "tonne of substance 90 % dry", one / count},
unitD{"TSH", "ton of steam per hour", one / count},
@@ -2371,7 +2371,7 @@ namespace precise {
unitD{"VQ", "bulk", one / count},
unitD{"VS", "visit", one / count},
unitD{"W2", "wet kilo", one / count},
unitD{"W4", "two week", precise_unit(2.0, time::week)},
unitD{"W4", "two week", {2.0, time::week}},
unitD{"WA", "watt per kilogram", W / kg},
unitD{"WB", "wet pound", one / count},
unitD{"WCD", "cord", us::cord},
@@ -2386,7 +2386,7 @@ namespace precise {
unitD{"WR", "wrap", one / count},
unitD{"WSD", "standard", one / count},
unitD{"WTT", "watt", W},
unitD{"WW", "millilitre of water", pressure::mmH2O},
unitD{"WW", "millilitre of water", mL},
unitD{"X1", "Gunter's chain", us::engineers::chain},
unitD{"YDK", "square yard", yd.pow(2)},
unitD{"YDQ", "cubic yard", yd.pow(3)},
5 changes: 3 additions & 2 deletions units/unit_definitions.hpp
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ static_assert(
"nan is used to signify invalid values");
static_assert(
std::numeric_limits<double>::has_infinity,
"nan is used to signify invalid values");
"infinity value is required for some constructs");
namespace constants {
constexpr double pi = 3.14159265358979323846;
constexpr double tau = 2.0 * pi;
@@ -80,6 +80,7 @@ namespace commodities {
feeder_cattle = 602,
lean_hogs = 603,
milk = 604,
paper = 606,

// soft
cotton = 945,
@@ -1476,7 +1477,7 @@ namespace precise {
constexpr precise_unit ppm(1e-6, count);
constexpr precise_unit ppb(1e-9, count);

constexpr precise_unit candle{0.981, cd};
constexpr precise_unit candle{0.98135426889107, cd};
// 2019 redefinition
constexpr precise_unit faraday{96485.3321233100184, C};
// others