Repository navigation
Add Japanese Hydrometer Scale support with conversions and localization - #1746
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.
lipchev
left a comment
There was a problem hiding this comment.
Thanks for documenting the Japanese conventions. The Baumé and Sake Meter Value formulas agree with the published references, and the focused tests passed on .NET 10 and .NET Framework 4.8. JIS Z 8804 · Japan National Tax Agency measurement method
Does this belong in the core catalog? Sake Meter Value and heavy Baumé have established uses in brewing. UnitsNet’s contributor guide favors quantities with wide use, preferably across domains, and suggests Ratio for dimensionless values. Could you explain what makes this quantity a good fit for core UnitsNet and what other applications would benefit from having it built in? UnitsNet v6 also simplifies the IQuantity interface and exposes quantity lookup, making it easier for applications to define and register their own types. Contributor criteria · Custom quantity guide · v6 interface changes · v6 quantity lookup
Issues to resolve before merging
- Use a common scale for comparisons and define the arithmetic. Both
0 Bh > +10 SMVand+10 SMV > 0 Bhreturned true. Multiplying the same reading by two also gave different results in heavy Baumé and reciprocal specific gravity. Please test both cases and define which arithmetic operations the type should expose. Comparison · Arithmetic - Define the valid range and density reference. A default reading produces infinite density, and some out-of-range readings produce negative density. Please define how the helpers handle those inputs and document that
ToDensity()gives equivalent sample density at 15 °C using water at 4 °C as the reference. Conversion helpers - Accept the standard Baumé symbols. Japanese parsing rejects
Bh,Béh,Bl, andBél. Please accept these unambiguous JIS symbols and test them as literal inputs. Unit definitions · JIS Z 8804
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: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.