Repository navigation
Add Japanese Hydrometer Scale support with conversions and localization - #1746
Open
Nishiwaki-Takao wants to merge 1 commit into
Open
Nishiwaki-Takao wants to merge 1 commit into
Nishiwaki-Takao wants to merge 1 commit into
Conversation
- Introduced a new quantity `JapaneseHydrometerScale` with methods for converting to density. - Generated code for `JapaneseHydrometerScale` including unit definitions and conversion functions. - Added localization resources for Japanese and English, including unit abbreviations. - Defined units for `JapaneseHydrometerScale`: Degree Baumé Heavy, Degree Baumé Light, Reciprocal Specific Gravity, and Sake Meter Value.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
JapaneseHydrometerScale, a dimensionless quantity for Japanese hydrometer readings derived from reciprocal specific gravity.The quantity includes:
It also provides conversions from the scale to
Ratioas specific gravity and to an equivalentDensityusing the density of water at 4 °C as the reference.Definition
Let specific gravity be$SG$ , and define reciprocal specific gravity as:
ReciprocalSpecificGravityis used as the base unit ofJapaneseHydrometerScale.Heavy Baumé
Equivalently:
Examples:
Light Baumé
Equivalently:
At$R = 1$ , the light Baumé value is $10,^\circ\mathrm{Bé}_{\mathrm{light}}$ .
Sake Meter Value
Equivalently:
At$R = 1$ , the Sake Meter Value is zero.
Motivation
These scales are conventional hydrometer readings used in Japanese industrial and brewing contexts. They are not plain ratios: each scale has its own name, formula, abbreviation, parsing behavior, and localization requirements.
Representing them as a dedicated quantity provides typed conversions between the related scales while keeping their convention separate from a generic
Ratio.Design
The new quantity is named
JapaneseHydrometerScale, with the following units:ReciprocalSpecificGravityDegreeBaumeHeavyDegreeBaumeLightSakeMeterValueReciprocal specific gravity is used as the base unit because all three scale conversions are affine functions of it.
The implementation also provides:
ToSpecificGravity(), returning aRatioToDensity(), returning an equivalentDensityToDensity()uses a water density of999.974950 kg/m³at 4 °C:$$
\rho_{\mathrm{sample}}
\frac{\rho_{\mathrm{water},,4,^\circ\mathrm{C}}}{R}
$$
The resulting density therefore depends on that explicit reference condition. Reciprocal specific gravity is not treated as density itself.
Implementation
JapaneseHydrometerScalequantity definition.ReciprocalSpecificGravityas its base unit.1/SG°Bé heavy/°Bh°Bé light/°BlSMV/日本酒度ToSpecificGravity()andToDensity()conversion methods.Tests
The generated tests cover:
As()andToUnit()The custom conversion expectations verify that$R = 1$ gives:
0100Scope
This PR implements the Japanese hydrometer convention represented by the formulas above.
It does not attempt to provide a generic or internationally interchangeable
DegreeBaumeunit. Other Baumé conventions, API gravity, and Twaddell scales may use different constants or reference conditions and remain outside the scope of this change.References
[- JIS Z 8804 : 2012 液体の密度及び比重の測定方法] (https://kikakurui.com/z8/Z8804-2012-01.html)
- Authoritative reference for the Sake Meter Value formula.