diff --git a/src/si_ref_point/aboxes/constants_abox.py b/src/si_ref_point/aboxes/constants_abox.py index b696615..62aabc7 100644 --- a/src/si_ref_point/aboxes/constants_abox.py +++ b/src/si_ref_point/aboxes/constants_abox.py @@ -3,6 +3,7 @@ from datetime import datetime, timezone import git import os +from decimal import Decimal from rdflib import Graph, URIRef, RDF, OWL, SKOS, XSD, RDFS, DCTERMS, Literal, PROV import yaml @@ -180,7 +181,7 @@ def main(): si_graph.has_unit, si_graph.set_unit_uri(cst['unit']))) constants_graph.add((element, si_graph.has_value, - Literal(cst['value'], datatype=XSD[cst['xsd_type']], normalize=False))) + Literal(str(format(Decimal(cst['value']), 'f')), datatype=XSD[cst['xsd_type']], normalize=False))) constants_graph.add((element, si_graph.has_datatype, XSD[cst['xsd_type']])) # note on xsd:double : # RDFLib has a known bug that loses precision in value for xsd:double diff --git a/src/si_ref_point/aboxes/prefixes_abox.py b/src/si_ref_point/aboxes/prefixes_abox.py index c6e3269..69a9656 100644 --- a/src/si_ref_point/aboxes/prefixes_abox.py +++ b/src/si_ref_point/aboxes/prefixes_abox.py @@ -5,6 +5,7 @@ import git import os import yaml +from decimal import Decimal from rdflib import Graph, URIRef, RDF, OWL, SKOS, XSD, RDFS, DCTERMS, Literal, PROV from si_ref_point.tboxes.si_tbox import SiElements from si_ref_point.settings import PKG_ROOT, CC_LICENCE, CC_LICENCE_TEXT_EN, CC_LICENCE_TEXT_FR, SI_FILES_FOLDER, GITHUB_BASE_PATH @@ -155,7 +156,7 @@ def main(): uri_text = prfx['URI'] pref_label_en = prfx['prefLabel_en'] pref_label_fr = prfx['prefLabel_fr'] - scaling_factor = prfx['ScalingFactor'] + scaling_factor = format(Decimal(prfx['ScalingFactor']), 'f') exponent = prfx['Exponent'] symbol = prfx['hasSymbol'] defres = prfx['hasDefiningResolution'] @@ -168,7 +169,7 @@ def main(): prefix_graph.add((element, SKOS.prefLabel, Literal(pref_label_fr, lang='fr'))) prefix_graph.add((element, SKOS.prefLabel, Literal(pref_label_en, lang='en'))) prefix_graph.add((element, si_graph.has_scaling_factor, - Literal(scaling_factor, datatype=XSD[xsd_type], normalize=False))) + Literal(str(scaling_factor), datatype=XSD[xsd_type], normalize=False))) prefix_graph.add((element, si_graph.has_datatype, XSD[xsd_type])) prefix_graph.add( ( diff --git a/src/si_ref_point/aboxes/units_abox.py b/src/si_ref_point/aboxes/units_abox.py index cd1ada6..2dce6bb 100644 --- a/src/si_ref_point/aboxes/units_abox.py +++ b/src/si_ref_point/aboxes/units_abox.py @@ -7,6 +7,7 @@ import os import logging import yaml +from decimal import Decimal from rdflib import Graph, URIRef, BNode, Literal, RDF, OWL, SKOS, XSD, RDFS, DCTERMS, PROV from si_ref_point.tboxes.si_tbox import SiElements import si_ref_point.aboxes.symbols_format as sf @@ -704,13 +705,13 @@ def main(): if isinstance(nsi["ConversionFactor"], int): conv_factor_type = XSD.integer - elif isinstance(nsi["ConversionFactor"], float): - conv_factor_type = XSD.float + elif isinstance(nsi["ConversionFactor"], str): + conv_factor_type = XSD.decimal else: logging.error('Error : unknown ConversionFactor type : %s ', nsi["ConversionFactor"]) conv_factor_type = None - conversion_factor = Literal(nsi["ConversionFactor"], + conversion_factor = Literal(str(format(Decimal(nsi["ConversionFactor"]), 'f')), datatype=conv_factor_type) conversion_factor_as_string = Literal( nsi["ConversionFactorAsString"], diff --git a/src/si_ref_point/inputs/si/base_units_defs.yaml b/src/si_ref_point/inputs/si/base_units_defs.yaml index a0f335e..f749a75 100644 --- a/src/si_ref_point/inputs/si/base_units_defs.yaml +++ b/src/si_ref_point/inputs/si/base_units_defs.yaml @@ -3,7 +3,7 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - URI: ampere1948 prefLabel_fr: ampère1948 diff --git a/src/si_ref_point/inputs/si/def_collectors.yaml b/src/si_ref_point/inputs/si/def_collectors.yaml index 7e99bb9..9ea3064 100644 --- a/src/si_ref_point/inputs/si/def_collectors.yaml +++ b/src/si_ref_point/inputs/si/def_collectors.yaml @@ -4,7 +4,7 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - URI: ampere prefLabel(fr): ampère diff --git a/src/si_ref_point/inputs/si/non_si_units.yaml b/src/si_ref_point/inputs/si/non_si_units.yaml index 88bb73a..3190c43 100644 --- a/src/si_ref_point/inputs/si/non_si_units.yaml +++ b/src/si_ref_point/inputs/si/non_si_units.yaml @@ -3,7 +3,7 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - URI: minute prefLabel_fr: minute @@ -46,7 +46,7 @@ data: prefLabel_en: degree Symbol: ° UnitOfQtyKind: ANGP - ConversionFactor: 0.0174532925199433 + ConversionFactor: "0.017453292519943295769236907684886" ConversionFactorAsString: "(π \\; / \\; 180)" ConversionUnit: radian PrefixRestriction: true @@ -55,7 +55,7 @@ data: prefLabel_en: arcminute Symbol: ′ UnitOfQtyKind: ANGP - ConversionFactor: 0.000290888208665722 + ConversionFactor: "0.00029088820866572159615394846141476" ConversionFactorAsString: "(π \\; / \\; 10800)" ConversionUnit: radian PrefixRestriction: true @@ -64,7 +64,7 @@ data: prefLabel_en: arcsecond Symbol: ″ UnitOfQtyKind: ANGP - ConversionFactor: 4.84813681109536e-06 + ConversionFactor: "4.8481368110953599358991410235794e-6" ConversionFactorAsString: "(π \\; / \\; 648000)" ConversionUnit: radian PrefixRestriction: true @@ -74,7 +74,7 @@ data: Symbol: L AltSymbol: l UnitOfQtyKind: VOLU - ConversionFactor: 0.001 + ConversionFactor: "0.001" ConversionFactorAsString: "0.001" ConversionUnit: - [metre, "3"] @@ -92,15 +92,15 @@ data: prefLabel_en: dalton Symbol: Da UnitOfQtyKind: MASS - ConversionFactor: 1.66053906660e-27 - ConversionFactorAsString: "1.660\\:539\\:066\\:60(50) \\times 10^{-27}" + ConversionFactor: "1.66053906892e-27" + ConversionFactorAsString: "1.660\\:539\\:068\\:92(52) \\times 10^{-27}" ConversionUnit: kilogram - URI: electronvolt prefLabel_fr: électronvolt prefLabel_en: electronvolt Symbol: eV UnitOfQtyKind: ENGY - ConversionFactor: 1.602176634e-19 + ConversionFactor: "1.602176634e-19" ConversionFactorAsString: "1.602\\:176\\:634 \\times 10^{-19}" ConversionUnit: joule - URI: neper diff --git a/src/si_ref_point/inputs/si/notes.yaml b/src/si_ref_point/inputs/si/notes.yaml index d015998..d196222 100644 --- a/src/si_ref_point/inputs/si/notes.yaml +++ b/src/si_ref_point/inputs/si/notes.yaml @@ -3,7 +3,7 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - dbid: 1 uri: second2018 diff --git a/src/si_ref_point/inputs/si/prefixes.yaml b/src/si_ref_point/inputs/si/prefixes.yaml index 764c088..676e163 100644 --- a/src/si_ref_point/inputs/si/prefixes.yaml +++ b/src/si_ref_point/inputs/si/prefixes.yaml @@ -3,57 +3,57 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - URI: quetta prefLabel_en: quetta prefLabel_fr: quetta - ScalingFactor: 1e+30 + ScalingFactor: 1e30 Exponent: +30 hasSymbol: Q hasDefiningResolution: CGPM27-Res3 - xsd_type: float + xsd_type: integer Comments: - URI: ronna prefLabel_en: ronna prefLabel_fr: ronna - ScalingFactor: 1e+27 + ScalingFactor: 1e27 Exponent: +27 hasSymbol: R hasDefiningResolution: CGPM27-Res3 - xsd_type: float + xsd_type: integer Comments: - URI: yotta prefLabel_en: yotta prefLabel_fr: yotta - ScalingFactor: 1e+24 + ScalingFactor: 1e24 Exponent: +24 hasSymbol: Y hasDefiningResolution: CGPM19-Res4 - xsd_type: float + xsd_type: integer Comments: - URI: zetta prefLabel_en: zetta prefLabel_fr: zetta - ScalingFactor: 1e+21 + ScalingFactor: 1e21 Exponent: +21 hasSymbol: Z hasDefiningResolution: CGPM19-Res4 - xsd_type: float + xsd_type: integer Comments: - URI: exa prefLabel_en: exa prefLabel_fr: exa - ScalingFactor: 1e+18 + ScalingFactor: 1e18 Exponent: +18 hasSymbol: E hasDefiningResolution: CGPM15-Res10 - xsd_type: float + xsd_type: integer Comments: - URI: peta prefLabel_en: peta prefLabel_fr: péta - ScalingFactor: 1000000000000000 + ScalingFactor: 1e15 Exponent: +15 hasSymbol: P hasDefiningResolution: CGPM15-Res10 @@ -62,7 +62,7 @@ data: - URI: tera prefLabel_en: tera prefLabel_fr: téra - ScalingFactor: 1000000000000 + ScalingFactor: 1e12 Exponent: +12 hasSymbol: T hasDefiningResolution: CGPM11-Res12 @@ -71,7 +71,7 @@ data: - URI: giga prefLabel_en: giga prefLabel_fr: giga - ScalingFactor: 1000000000 + ScalingFactor: 1e9 Exponent: +9 hasSymbol: G hasDefiningResolution: CGPM11-Res12 @@ -80,7 +80,7 @@ data: - URI: mega prefLabel_en: mega prefLabel_fr: méga - ScalingFactor: 1000000 + ScalingFactor: 1e6 Exponent: +6 hasSymbol: M hasDefiningResolution: CGPM11-Res12 @@ -89,7 +89,7 @@ data: - URI: kilo prefLabel_en: kilo prefLabel_fr: kilo - ScalingFactor: 1000 + ScalingFactor: 1e3 Exponent: +3 hasSymbol: k hasDefiningResolution: CGPM11-Res12 @@ -98,7 +98,7 @@ data: - URI: hecto prefLabel_en: hecto prefLabel_fr: hecto - ScalingFactor: 100 + ScalingFactor: 1e2 Exponent: +2 hasSymbol: h hasDefiningResolution: CGPM11-Res12 @@ -107,7 +107,7 @@ data: - URI: deca prefLabel_en: deca prefLabel_fr: déca - ScalingFactor: 10 + ScalingFactor: 1e1 Exponent: +1 hasSymbol: da hasDefiningResolution: CGPM11-Res12 @@ -116,7 +116,7 @@ data: - URI: deci prefLabel_en: deci prefLabel_fr: déci - ScalingFactor: 0.1 + ScalingFactor: 1e-1 Exponent: -1 hasSymbol: d hasDefiningResolution: CGPM11-Res12 @@ -125,7 +125,7 @@ data: - URI: centi prefLabel_en: centi prefLabel_fr: centi - ScalingFactor: 0.01 + ScalingFactor: 1e-2 Exponent: -2 hasSymbol: c hasDefiningResolution: CGPM11-Res12 @@ -134,7 +134,7 @@ data: - URI: milli prefLabel_en: milli prefLabel_fr: milli - ScalingFactor: 0.001 + ScalingFactor: 1e-3 Exponent: -3 hasSymbol: m hasDefiningResolution: CGPM11-Res12 @@ -147,7 +147,7 @@ data: Exponent: -6 hasSymbol: µ hasDefiningResolution: CGPM11-Res12 - xsd_type: float + xsd_type: decimal Comments: Tried with latex - fine without bold, but more difficult with. Would require two symbols one bolded the other not. - URI: nano @@ -157,7 +157,7 @@ data: Exponent: -9 hasSymbol: n hasDefiningResolution: CGPM11-Res12 - xsd_type: float + xsd_type: decimal Comments: - URI: pico prefLabel_en: pico @@ -166,7 +166,7 @@ data: Exponent: -12 hasSymbol: p hasDefiningResolution: CGPM11-Res12 - xsd_type: float + xsd_type: decimal Comments: - URI: femto prefLabel_en: femto @@ -175,7 +175,7 @@ data: Exponent: -15 hasSymbol: f hasDefiningResolution: CGPM12-Res8 - xsd_type: float + xsd_type: decimal Comments: - URI: atto prefLabel_en: atto @@ -184,7 +184,7 @@ data: Exponent: -18 hasSymbol: a hasDefiningResolution: CGPM12-Res8 - xsd_type: float + xsd_type: decimal Comments: - URI: zepto prefLabel_en: zepto @@ -193,7 +193,7 @@ data: Exponent: -21 hasSymbol: z hasDefiningResolution: CGPM19-Res4 - xsd_type: float + xsd_type: decimal Comments: - URI: yocto prefLabel_en: yocto @@ -202,7 +202,7 @@ data: Exponent: -24 hasSymbol: y hasDefiningResolution: CGPM19-Res4 - xsd_type: float + xsd_type: decimal Comments: - URI: ronto prefLabel_en: ronto @@ -211,7 +211,7 @@ data: Exponent: -27 hasSymbol: r hasDefiningResolution: CGPM27-Res3 - xsd_type: float + xsd_type: decimal Comments: - URI: quecto prefLabel_en: quecto @@ -220,7 +220,7 @@ data: Exponent: -30 hasSymbol: q hasDefiningResolution: CGPM27-Res3 - xsd_type: float + xsd_type: decimal Comments: - URI: none prefLabel_en: none @@ -229,5 +229,5 @@ data: Exponent: 0 hasSymbol: hasDefiningResolution: - xsd_type: float + xsd_type: decimal Comments: "not an official prefix" diff --git a/src/si_ref_point/inputs/si/si_constants.yaml b/src/si_ref_point/inputs/si/si_constants.yaml index edf6ae2..e7e5a30 100644 --- a/src/si_ref_point/inputs/si/si_constants.yaml +++ b/src/si_ref_point/inputs/si/si_constants.yaml @@ -3,7 +3,7 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - id: HyperfineTransitionFrequencyOfCs-133 hidden_label: HyperfineSplitting @@ -11,7 +11,7 @@ data: name_fr: fréquence de la transition hyperfine du césium xsd_type: integer value_str: 9 192 631 770 - value: 9192631770 + value: "9192631770" unit: hertz symbol: '@hfcs@' updateddate: '1967-10-13' @@ -23,7 +23,7 @@ data: name_fr: vitesse de la lumière dans le vide xsd_type: integer value_str: 299 792 458 - value: 299792458 + value: "299792458" unit: - [metre, "1"] - [second, "-1"] @@ -35,9 +35,9 @@ data: hidden_label: Planck name_en: Planck constant name_fr: constante de Planck - xsd_type: float + xsd_type: decimal value_str: 6.626 070 15 x 10⁻³⁴ - value: 6.62607015e-34 + value: "6.62607015e-34" unit: - [joule, "1"] - [second, "1"] @@ -49,9 +49,9 @@ data: hidden_label: ElementaryCharge name_en: elementary charge name_fr: charge élementaire - xsd_type: float + xsd_type: decimal value_str: 1.602 176 634 x 10⁻¹⁹ - value: 1.602176634e-19 + value: "1.602176634e-19" unit: coulomb symbol: '@elms@' updateddate: '2019-05-20' @@ -61,9 +61,9 @@ data: hidden_label: Boltzmann name_en: Boltzmann constant name_fr: constante de Boltzmann - xsd_type: float + xsd_type: decimal value_str: 1.380 649 x 10⁻²³ - value: 1.380649e-23 + value: "1.380649e-23" unit: - [joule, "1"] - [kelvin, "-1"] @@ -75,9 +75,9 @@ data: hidden_label: Avogadro name_en: Avogadro constant name_fr: constante d'Avogadro - xsd_type: float + xsd_type: integer value_str: 6.022 140 76 x 10²³ - value: 6.02214076e+23 + value: "6.02214076e+23" unit: - [mole, "-1"] symbol: '@avos@' @@ -90,7 +90,7 @@ data: name_fr: efficacité lumineuse xsd_type: integer value_str: '683' - value: 683 + value: "683" unit: - [lumen, "1"] - [watt, "-1"] diff --git a/src/si_ref_point/inputs/si/si_units_special_names.yaml b/src/si_ref_point/inputs/si/si_units_special_names.yaml index 2a0cf9f..0d74511 100644 --- a/src/si_ref_point/inputs/si/si_units_special_names.yaml +++ b/src/si_ref_point/inputs/si/si_units_special_names.yaml @@ -3,7 +3,7 @@ meta: wasAssociatedWith: "Frédéric Meynadier" wasGeneratedBy: "manual YAML generation" startedAtTime: "2023-01-01" - wasDerivedFrom: "SI Brochure 9th ed, V3.01" + wasDerivedFrom: "SI Brochure 9th ed, V3.02" data: - URI: becquerel prefLabel_fr: becquerel