unitsml 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/.rubocop_todo.yml +276 -279
  4. data/Gemfile +13 -13
  5. data/Rakefile +2 -2
  6. data/bin/console +3 -3
  7. data/lib/unitsml/dimension.rb +3 -3
  8. data/lib/unitsml/errors.rb +2 -2
  9. data/lib/unitsml/extender.rb +9 -9
  10. data/lib/unitsml/fenced.rb +3 -3
  11. data/lib/unitsml/formula.rb +29 -20
  12. data/lib/unitsml/intermediate_exp_rules.rb +30 -20
  13. data/lib/unitsml/model/dimension.rb +1 -1
  14. data/lib/unitsml/model/dimension_quantities.rb +8 -4
  15. data/lib/unitsml/model/prefix.rb +1 -1
  16. data/lib/unitsml/model/prefixes/name.rb +2 -2
  17. data/lib/unitsml/model/prefixes/symbol.rb +1 -1
  18. data/lib/unitsml/model/quantities/name.rb +2 -2
  19. data/lib/unitsml/model/quantity.rb +2 -2
  20. data/lib/unitsml/model/unit.rb +1 -1
  21. data/lib/unitsml/model/units/name.rb +2 -2
  22. data/lib/unitsml/model/units/root_units.rb +1 -1
  23. data/lib/unitsml/model/units/symbol.rb +4 -2
  24. data/lib/unitsml/model/units/system.rb +2 -2
  25. data/lib/unitsml/model/units.rb +5 -5
  26. data/lib/unitsml/namespace.rb +2 -2
  27. data/lib/unitsml/number.rb +11 -11
  28. data/lib/unitsml/parse.rb +30 -19
  29. data/lib/unitsml/parser.rb +11 -11
  30. data/lib/unitsml/prefix.rb +6 -4
  31. data/lib/unitsml/transform.rb +26 -26
  32. data/lib/unitsml/unit.rb +8 -6
  33. data/lib/unitsml/unitsdb/dimension.rb +6 -4
  34. data/lib/unitsml/unitsdb/dimensions.rb +4 -0
  35. data/lib/unitsml/unitsdb/unit.rb +2 -2
  36. data/lib/unitsml/unitsdb/units.rb +4 -0
  37. data/lib/unitsml/unitsdb.rb +8 -19
  38. data/lib/unitsml/utility.rb +81 -70
  39. data/lib/unitsml/version.rb +1 -1
  40. data/lib/unitsml.rb +31 -31
  41. data/unitsml.gemspec +22 -19
  42. metadata +5 -23
  43. data/unitsdb/Gemfile +0 -6
  44. data/unitsdb/LICENSE.md +0 -53
  45. data/unitsdb/README.adoc +0 -1253
  46. data/unitsdb/RELEASE-NOTES.adoc +0 -269
  47. data/unitsdb/dimensions.yaml +0 -1864
  48. data/unitsdb/prefixes.yaml +0 -874
  49. data/unitsdb/quantities.yaml +0 -3715
  50. data/unitsdb/scales.yaml +0 -97
  51. data/unitsdb/schemas/README.md +0 -159
  52. data/unitsdb/schemas/dimensions-schema.yaml +0 -153
  53. data/unitsdb/schemas/prefixes-schema.yaml +0 -155
  54. data/unitsdb/schemas/quantities-schema.yaml +0 -117
  55. data/unitsdb/schemas/scales-schema.yaml +0 -106
  56. data/unitsdb/schemas/unit_systems-schema.yaml +0 -116
  57. data/unitsdb/schemas/units-schema.yaml +0 -215
  58. data/unitsdb/spec/units_spec.rb +0 -22
  59. data/unitsdb/unit_systems.yaml +0 -78
  60. data/unitsdb/units.yaml +0 -14052
  61. data/unitsdb/validate_schemas.rb +0 -203
data/unitsdb/README.adoc DELETED
@@ -1,1253 +0,0 @@
1
- = UnitsDB
2
-
3
- == Purpose
4
-
5
- This data repository is used in conjunction with UnitsML.
6
-
7
- Sources include:
8
-
9
- * https://www.bipm.org/en/publications/si-brochure/[BIPM SI Brochure]
10
- * https://www.nist.gov/pml/special-publication-811[NIST SP 811]
11
- * ISO 80000 series
12
- * (in some cases, "Encyclopaedia of Scientific Units, Weights and Measures, Their SI Equivalences and Origins" by François Cardarelli, is consulted)
13
-
14
- NOTE: Conversion factors here are not updated with the revised SI.
15
-
16
- == Structure
17
-
18
- This repository contains the following YAML files:
19
-
20
- `dimensions.yaml`:: Contains the base dimensions and their symbols.
21
-
22
- `prefixes.yaml`:: Contains the SI prefixes and their symbols.
23
-
24
- `scales.yaml`:: Contains the measurement scale types and their properties.
25
-
26
- `units.yaml`:: Contains the units and their symbols, with English and French
27
- names. French translations come from BIPM.
28
-
29
- `unit_systems.yaml`:: Contains the unit systems and their symbols.
30
-
31
- `quantities.yaml`:: Contains the quantities and their symbols, with English and
32
- French names. French translations come from BIPM.
33
-
34
-
35
- == Supported languages
36
-
37
- The database currently supports the following languages:
38
-
39
- * English (en): Primary language for all entries
40
-
41
- * French (fr): Provided for units and quantities, sourced from the BIPM SI
42
- Digital Framework
43
-
44
-
45
- == Versioning
46
-
47
- === Version scheme
48
-
49
- UnitsDB follows semantic versioning (https://semver.org/[SemVer]) using a
50
- `MAJOR.MINOR.PATCH` structure.
51
-
52
- Where,
53
-
54
- `MAJOR`:: Incremented for incompatible changes that may require updates to consuming applications
55
-
56
- `MINOR`:: Incremented for backwards-compatible additions or changes
57
-
58
- `PATCH`:: Incremented for backwards-compatible bug fixes
59
-
60
-
61
- === Version field
62
-
63
- Each YAML file in the database contains a `schema_version` field (string) at the
64
- top level.
65
-
66
- [source,yaml]
67
- ----
68
- schema_version: "2.0.0"
69
- dimensions:
70
- # content follows
71
- ----
72
-
73
- The version number is consistent across all files in a given release, ensuring
74
- the database is treated as a cohesive unit.
75
-
76
- === Version changes
77
-
78
- [cols="1,3a"]
79
- |===
80
- |Version level |Types of changes
81
-
82
- |`MAJOR`
83
- |
84
- * Structural changes to the data model
85
- * Removal of units, dimensions, or quantities
86
- * Changes to identifier schemes
87
- * Any other backwards-incompatible changes
88
-
89
- |`MINOR`
90
- |
91
- * Addition of new units, dimensions, or quantities
92
- * Addition of new properties to existing entities
93
- * Other backwards-compatible enhancements
94
-
95
- |`PATCH`
96
- |
97
- * Corrections to symbols, names, or other properties
98
- * Fixes to references between entities
99
- * Other backwards-compatible fixes
100
-
101
- |===
102
-
103
- === Version usage
104
-
105
- Applications consuming UnitsDB should:
106
-
107
- . Check the `schema_version` field to ensure compatibility, ensure all files are
108
- consistent with the same version
109
- . Handle version transitions appropriately based on the semantic versioning rules
110
- . Document which version(s) of UnitsDB they support
111
-
112
- == Content classes
113
-
114
- === Basic structures
115
-
116
- ==== General
117
-
118
- Several shared content models are used across the different entities.
119
-
120
- ==== Identifier
121
-
122
- The Identifier object represents a unique identifier within the identifier type.
123
-
124
- Every entity in the database includes an `identifiers` array that contains one or
125
- more identifiers.
126
-
127
- Each identifier has:
128
-
129
- `id`:: A unique string that identifies the entity
130
- `type`:: The system or authority that defines the identifier
131
-
132
- The `type: unitsml` identifier is mandatory for every entry, where it uniquely
133
- identifies the entity within the UnitsML framework.
134
-
135
- Other types of identifier types are also supported, such as `type: nist` for
136
- legacy UnitsML identifiers that start with a prefix of `NIST`.
137
-
138
- The UnitsML identifier follows a specific format:
139
-
140
- [source,yaml]
141
- ----
142
- id: {entity-type}:{entity-name}
143
- type: unitsml
144
- ----
145
-
146
- Where,
147
-
148
- `entity-type`:: Abbreviated code for the type of entity.
149
- `u`::: Unit
150
- `d`::: Dimension
151
- `p`::: Prefix
152
- `q`::: Quantity
153
- `s`::: Scale
154
- `us`::: Unit system
155
-
156
- `entity-name`:: The short name of the entity, typically identical to the
157
- `short:` attribute of the entity.
158
-
159
- The legacy UnitsML identifier ("NIST" prefix) is used for backward compatibility
160
- and is not required for new entries.
161
-
162
- [source,yaml]
163
- ----
164
- id: NIST{entity-type}{entity-code}
165
- type: nist
166
- ----
167
-
168
- Where,
169
-
170
- `entity-type`:: Abbreviated code for the type of entity.
171
- `u`::: Unit
172
- `d`::: Dimension
173
- `p`::: Prefix
174
- `q`::: Quantity
175
-
176
- `entity-code`:: A unique code for the entity. It is a number for units, quantities and
177
- dimensions, and a string pattern of `{base_number}_{power}` for prefixes.
178
-
179
- [example]
180
- ====
181
- [source,yaml]
182
- ----
183
- identifiers:
184
- - id: u:meter
185
- type: unitsml
186
- - id: NISTu1
187
- type: nist
188
- ----
189
- ====
190
-
191
-
192
- ==== Symbols
193
-
194
- The Symbol object represents the notation used to represent the entity in different
195
- contexts and formats.
196
-
197
- The Symbol object is used for units, prefixes, certain quantities and certain dimensions.
198
-
199
- A Symbol object contains the following attributes which allow for rendering in
200
- various formats:
201
-
202
- `id`:: A unique identifier identifying the symbol across UnitsDB
203
- `ascii`:: Plain text ASCII representation
204
- `unicode`:: Unicode representation, used in UnicodeMath
205
- `html`:: HTML markup representation
206
- `mathml`:: MathML markup representation
207
- `latex`:: LaTeX markup representation
208
-
209
- This multi-format approach ensures that the symbols can be rendered correctly
210
- across various applications and documents.
211
-
212
- [example]
213
- ====
214
- [source,yaml]
215
- ----
216
- symbols:
217
- - latex: "\\ensuremath{\\mathrm{m}}"
218
- unicode: m
219
- ascii: m
220
- html: m
221
- id: m
222
- mathml: "<mi mathvariant='normal'>m</mi>"
223
- ----
224
- ====
225
-
226
- ==== Localized string
227
-
228
- The localized string object represents a human-readable string that can be
229
- localized into different languages.
230
-
231
- It is used for names, descriptions, and other text fields that may require
232
- translation or localization. Multiple values are allowed per language.
233
-
234
- A localized string object contains the following attributes:
235
-
236
- `value`:: The localized string value
237
- `lang`:: The language code (e.g., "en" for English, "fr" for French)
238
-
239
- [example]
240
- ====
241
- [source,yaml]
242
- ----
243
- names:
244
- - value: metre
245
- lang: en
246
- - value: meter
247
- lang: en
248
- - value: mètre
249
- lang: fr
250
- ----
251
- ====
252
-
253
- ==== References
254
-
255
- ===== General
256
-
257
- A reference object represents a link to an external resource or standard
258
- that provides additional context or information about the entity.
259
-
260
- Currently, UnitsDB units, quantities and prefixes link to:
261
-
262
- * https://si-digital-framework.org[BIPM SI Digital Framework] (normative references)
263
- * https://ucum.org/[UCUM] (informative references)
264
- * https://qudt.org[QUDT] (informative references)
265
-
266
- A reference contains the following attributes:
267
-
268
- `uri`:: The URI or URL of the reference
269
- `type`:: The type of reference (e.g., "normative", "informative")
270
- `authority`:: The authority responsible for the reference
271
-
272
- [example]
273
- ====
274
- [source,yaml]
275
- ----
276
- references:
277
- - type: normative
278
- uri: http://si-digital-framework.org/SI/units/metre
279
- authority: si-digital-framework
280
- - type: informative
281
- uri: ucum:base-unit:code:m
282
- authority: ucum
283
- - type: informative
284
- uri: http://qudt.org/vocab/unit/M
285
- authority: qudt
286
- ----
287
- ====
288
-
289
-
290
- ===== SI Digital Framework
291
-
292
- The SI Digital Framework reference is a normative reference to the
293
- official SI unit definitions.
294
-
295
- SI references are added to:
296
-
297
- * `units.yaml` for units
298
- * `quantities.yaml` for quantities
299
- * `prefixes.yaml` for prefixes
300
- * `dimensions.yaml` for dimensions
301
-
302
-
303
- ===== UCUM
304
-
305
- The UCUM URI format is a custom one used inside UnitsML with the pattern
306
- `ucum:{type}:{klass}:code:{unit_code}`, and is listed as informative.
307
-
308
- UCUM references are added to:
309
-
310
- * `units.yaml` for units
311
- * `prefixes.yaml` for prefixes
312
-
313
- The UCUM file is located at: `spec/fixtures/ucum/ucum-essence.xml`
314
-
315
-
316
- ===== QUDT
317
-
318
- The QUDT URI format is a custom one used inside UnitsML with the pattern
319
- `http://qudt.org/{version}/vocab/{vocab_type}/{code}`, and is listed as informative.
320
-
321
- QUDT references are added to:
322
-
323
- * `units.yaml` for units (`http://qudt.org/{version}/vocab/unit`)
324
- * `quantities.yaml` for quantities (`http://qudt.org/{version}/vocab/quantitykind`)
325
- * `dimensions.yaml` for dimensions (`http://qudt.org/{version}/vocab/dimensionvector`)
326
- * `unit_systems.yaml` for unit systems (`http://qudt.org/{version}/vocab/sou`)
327
-
328
- The current version mapped to QUDT is `3.1.2`.
329
-
330
-
331
- === Dimensions
332
-
333
- ==== General
334
-
335
- Dimensions represent the fundamental physical quantities that form the basis of
336
- any measurement system. They are the abstract properties that define the nature
337
- of a physical quantity, independent of any specific unit of measurement.
338
-
339
- * The SI system defines seven base dimensions (length, mass, time, electric
340
- current, thermodynamic temperature, amount of substance, and luminous intensity).
341
-
342
- * A special dimensionless dimension is also defined, which has no physical
343
- significance but is used in certain contexts.
344
-
345
- * Derived dimensions are formed by combining base dimensions through
346
- multiplication, division, or exponentiation. For example, velocity is a derived
347
- dimension formed from length and time (L/T), and force is derived from mass
348
- and acceleration (ML/T²).
349
-
350
- A dimension object in `dimensions.yaml` typically has the following structure:
351
-
352
- [source,yaml]
353
- ----
354
- - identifiers:
355
- - id: dimension_id
356
- type: type_identifier
357
- short: short_name
358
- {dimension_name}:
359
- power: power_numerator
360
- symbol: ASCII representation
361
- symbols:
362
- - ascii: ASCII representation
363
- html: "HTML representation"
364
- id: dimension_symbol_id
365
- latex: "LaTeX representation"
366
- mathml: "MathML representation"
367
- unicode: "Unicode representation"
368
- ----
369
-
370
- For example:
371
-
372
- [source,yaml]
373
- ----
374
- - identifiers:
375
- - id: NISTd1
376
- type: nist
377
- length:
378
- power: 1
379
- symbol: L
380
- symbols:
381
- - ascii: L
382
- html: "&#x1D5AB;"
383
- id: dim_L
384
- latex: "\\ensuremath{\\mathsf{L}}"
385
- mathml: "<mi mathvariant='sans-serif'>L</mi>"
386
- unicode: "\U0001D5AB"
387
- short: length
388
- - identifiers:
389
- - id: NISTd2
390
- type: nist
391
- mass:
392
- power: 1
393
- symbol: M
394
- symbols:
395
- - ascii: M
396
- html: "&#x1D5AC;"
397
- id: dim_M
398
- latex: "\\ensuremath{\\mathsf{M}}"
399
- mathml: "<mi mathvariant='sans-serif'>M</mi>"
400
- unicode: "\U0001D5AC"
401
- short: mass
402
- ----
403
-
404
- ==== Notes
405
-
406
- The following dimensions are identified by NIST but they are excluded from
407
- `dimensions.yaml` since they are unused:
408
-
409
- [source,yaml]
410
- ----
411
- - identifiers:
412
- - id: NISTd87
413
- type: nist
414
- dimensionless: true
415
- short: dimensionless
416
-
417
- - identifiers:
418
- - id: NISTd86
419
- type: nist
420
- dimensionless: true
421
- short: dimensionless
422
-
423
- - identifiers:
424
- - id: NISTd81
425
- type: nist
426
- dimensionless: true
427
- short: dimensionless
428
- ----
429
-
430
-
431
- === Prefixes
432
-
433
- ==== General
434
-
435
- Prefixes are modifiers that can be attached to units to indicate decimal
436
- multiples or submultiples. They provide a concise way to express very large or
437
- small quantities without resorting to scientific notation.
438
-
439
- [example]
440
- The prefix "kilo" (k) multiplies a unit by 1000, so 1 kilometer equals 1000
441
- meters.
442
-
443
- The SI system defines a set of standard prefixes included in UnitsDB.
444
-
445
- A prefix object in `prefixes.yaml` typically has the following structure:
446
-
447
- [source,yaml]
448
- ----
449
- - identifiers:
450
- - id: prefix_id
451
- type: type_identifier
452
- base: base
453
- names:
454
- - prefix_name
455
- short: prefix_short_name
456
- power: power
457
- symbol:
458
- id: symbol_id
459
- ascii: ASCII representation
460
- html: "HTML representation"
461
- latex: "LaTeX representation"
462
- unicode: "Unicode representation"
463
- mathml: "MathML representation"
464
- ----
465
-
466
- For example:
467
-
468
- [source,yaml]
469
- ----
470
- - identifiers:
471
- - id: NISTp10_2
472
- type: nist
473
- base: 10
474
- names:
475
- - hecto
476
- short: hecto
477
- power: 2
478
- symbol:
479
- latex: h
480
- unicode: h
481
- ascii: h
482
- html: h
483
- id: hecto
484
- mathml: "<mi>h</mi>"
485
- - identifiers:
486
- - id: NISTp10_1
487
- type: nist
488
- base: 10
489
- names:
490
- - deka
491
- short: deka
492
- power: 1
493
- symbol:
494
- latex: da
495
- unicode: da
496
- ascii: da
497
- html: da
498
- id: deka
499
- mathml: "<mi>da</mi>"
500
- ----
501
-
502
- ==== Notes
503
-
504
- Decimal prefixes are identified by their power of 10, e.g. `NISTp10_1`
505
-
506
- The prefix `NISTp10_0` is a placeholder for unity.
507
-
508
- Binary prefixes are identified by their power of 2, e.g. `NISTp2_10`
509
-
510
-
511
- === Quantities
512
-
513
- ==== General
514
-
515
- Quantities are measurable properties of physical phenomena, objects, or
516
- substances. They represent the attributes that can be measured and expressed
517
- with numbers. Each quantity is associated with a specific dimension (or
518
- combination of dimensions) and can be measured using various units.
519
-
520
- The SI system categorizes quantities into two main types:
521
-
522
- * Base quantities: The seven fundamental quantities from which all others are
523
- derived (length, mass, time, electric current, thermodynamic temperature, amount
524
- of substance, and luminous intensity)
525
-
526
- * Derived quantities: Quantities formed by algebraic combinations of base
527
- quantities (e.g., area, volume, velocity, force)
528
-
529
- Each quantity has a unique identity and can be measured in specific units that
530
- share the same dimension.
531
-
532
- [example]
533
- "length" is a quantity that can be measured in meters, feet, or kilometers.
534
-
535
- A quantity can be combined with other quantities to form compound quantities,
536
- such as velocity (length/time) or force (mass × acceleration).
537
-
538
- A quantity object in `quantities.yaml` typically has the following structure:
539
-
540
- [source,yaml]
541
- ----
542
- - identifiers:
543
- - id: quantity_id
544
- type: type_identifier
545
- names:
546
- - names
547
- quantity_type: {base|derived}
548
- short: short_name
549
- unit_references:
550
- - id: unit_id
551
- type: type_identifier
552
- dimension_reference:
553
- id: dimension_id
554
- type: type_identifier
555
- references:
556
- - uri: http://si-digital-framework.org/quantities/QUANTITY_ID
557
- type: normative
558
- authority: si-digital-framework
559
- ----
560
-
561
- For example:
562
-
563
- [source,yaml]
564
- ----
565
- - identifiers:
566
- - id: NISTq8
567
- type: nist
568
- names:
569
- - value: area
570
- lang: en
571
- - value: superficie
572
- lang: fr
573
- quantity_type: base
574
- unit_references:
575
- - id: NISTu164
576
- type: nist
577
- - id: NISTu165
578
- type: nist
579
- - id: NISTu1e2/1
580
- type: nist
581
- - id: NISTu283
582
- type: nist
583
- - id: NISTu317
584
- type: nist
585
- - id: NISTu42
586
- type: nist
587
- - id: NISTu43
588
- type: nist
589
- - id: NISTu44
590
- type: nist
591
- - id: NISTu45
592
- type: nist
593
- - id: NISTu46
594
- type: nist
595
- dimension_reference:
596
- id: NISTd8
597
- type: nist
598
- references:
599
- - uri: http://si-digital-framework.org/quantities/AREA
600
- type: normative
601
- authority: si-digital-framework
602
- - identifiers:
603
- - id: NISTq166
604
- type: nist
605
- names:
606
- - electric potential
607
- quantity_type: derived
608
- unit_references:
609
- - id: NISTu261
610
- type: nist
611
- - id: NISTu268
612
- type: nist
613
- dimension_reference:
614
- id: NISTd18
615
- type: nist
616
- - identifiers:
617
- - id: NISTq7
618
- type: nist
619
- names:
620
- - luminous intensity
621
- quantity_type: base
622
- short: luminous_intensity
623
- unit_references:
624
- - id: NISTu7
625
- type: nist
626
- dimension_reference:
627
- id: NISTd7
628
- type: nist
629
- ----
630
-
631
-
632
- === Units
633
-
634
- ==== General
635
-
636
- Units are standardized quantities used to express measurements of physical
637
- properties. They provide a reference scale for measuring quantities, allowing
638
- values to be communicated uniformly. Each unit is associated with a specific
639
- physical quantity and dimension, and has a defined relationship to other units
640
- in the same dimension.
641
-
642
- The SI system classifies units into several categories:
643
-
644
- * Base units: The seven fundamental units corresponding to the base quantities
645
- (meter, kilogram, second, ampere, kelvin, mole, and candela)
646
-
647
- * Derived units: Units formed from combinations of base units (e.g., newton,
648
- joule, pascal)
649
-
650
- * Special named units: Derived units that have been given unique names for
651
- convenience (e.g., newton for kg·m/s²)
652
-
653
- * Units outside the SI: Non-SI units that are accepted for use with the SI
654
- (e.g., minute, hour, degree)
655
-
656
- Units can be combined with prefixes to express multiples or submultiples, and
657
- can be combined algebraically (through multiplication and division) to form
658
- compound units.
659
-
660
- A unit object in `units.yaml` typically has the following structure:
661
-
662
- [source,yaml]
663
- ----
664
- - identifiers:
665
- - id: unit_id
666
- type: type_identifier
667
- quantity_references:
668
- - id: quantity_id
669
- type: type_identifier
670
- names:
671
- - names
672
- root: true|false
673
- short: unit_short_name
674
- symbols:
675
- - id: symbol_id
676
- ascii: ASCII representation
677
- html: "HTML representation"
678
- mathml: "MathML representation"
679
- latex: "LaTeX representation"
680
- unicode: "Unicode representation"
681
- dimension_reference:
682
- id: dimension_id
683
- type: type_identifier
684
- unit_system_reference:
685
- - id: unit_system_id
686
- type: type_identifier
687
- # Optional fields for derived units:
688
- prefixed: true|false
689
-
690
- # Note: Use either root_units OR si_derived_bases, but not both together
691
-
692
- # Use root_units for composite units that include any non-SI or non-SI-derived units
693
- # root_units can also contain SI units
694
- root_units:
695
- - power: power_numerator
696
- unit_reference:
697
- id: unit_id
698
- type: type_identifier
699
- prefix_reference:
700
- id: prefix_id
701
- type: type_identifier
702
-
703
- # Use si_derived_bases only for composite units that use exclusively SI base units
704
- si_derived_bases:
705
- - power: power_numerator
706
- unit_reference:
707
- id: unit_id
708
- type: type_identifier
709
- prefix_reference:
710
- id: prefix_id
711
- type: type_identifier
712
- ----
713
-
714
- For example:
715
-
716
- [source,yaml]
717
- ----
718
- - identifiers:
719
- - id: NISTu5
720
- type: nist
721
- quantity_references:
722
- - id: NISTq5
723
- type: nist
724
- names:
725
- - value: kelvin
726
- lang: en
727
- - value: kelvin
728
- lang: fr
729
- root: true
730
- short: kelvin
731
- symbols:
732
- - latex: "\\ensuremath{\\mathrm{K}}"
733
- unicode: K
734
- ascii: K
735
- html: K
736
- id: K
737
- mathml: "<mi mathvariant='normal'>K</mi>"
738
- - latex: "\\ensuremath{\\mathrm{^{\\circ}K}}"
739
- unicode: "°K"
740
- ascii: degK
741
- html: "&#176;K"
742
- id: degK
743
- mathml: "<mi mathvariant='normal'>&#176;K</mi>"
744
- dimension_reference:
745
- id: NISTd5
746
- type: nist
747
- unit_system_reference:
748
- - id: si-base
749
- type: unitsml
750
- ----
751
-
752
-
753
- === Scales
754
-
755
- ==== General
756
-
757
- Scales define the mathematical properties of measurement systems and how values
758
- relate to each other. They specify important characteristics like whether a
759
- scale has a true zero point, whether equal intervals represent equal
760
- differences, or whether the scale uses logarithmic relationships.
761
-
762
- Understanding the scale type is crucial for proper interpretation of
763
- measurements and for determining what mathematical operations can legitimately
764
- be performed on the values.
765
-
766
- [example]
767
- On a ratio scale (like length), you can say that 10 meters is twice as long as 5
768
- meters. On an interval scale (like Celsius temperature), 20°C is not "twice as
769
- hot" as 10°C.
770
-
771
- UnitsDB defines several scale types including continuous ratio scales,
772
- continuous interval scales, logarithmic scales, and discrete scales, each with
773
- specific properties that determine how measurements should be interpreted and
774
- what mathematical operations are valid.
775
-
776
- A scale object in `scales.yaml` typically has the following structure:
777
-
778
- [source,yaml]
779
- ----
780
- - identifiers:
781
- - id: scale_id
782
- type: type_identifier
783
- names:
784
- - scale_name
785
- short: short_name
786
- description:
787
- - description of scale type
788
- properties:
789
- continuous: true|false
790
- ordered: true|false
791
- logarithmic: true|false
792
- interval: true|false
793
- ratio: true|false
794
- ----
795
-
796
- For example:
797
-
798
- [source,yaml]
799
- ----
800
- - identifiers:
801
- - id: continuous_ratio
802
- type: unitsml
803
- names:
804
- - continuous ratio scale
805
- short: continuous_ratio
806
- description:
807
- - A measurement scale with continuous values and a true zero point, allowing for ratio comparisons
808
- properties:
809
- continuous: true
810
- ordered: true
811
- logarithmic: false
812
- interval: true
813
- ratio: true
814
- - identifiers:
815
- - id: logarithmic_ratio
816
- type: unitsml
817
- names:
818
- - logarithmic ratio scale
819
- short: logarithmic_ratio
820
- description:
821
- - A scale where equal ratios appear as equal intervals, with a zero point representing a reference value
822
- properties:
823
- continuous: true
824
- ordered: true
825
- logarithmic: true
826
- interval: true
827
- ratio: true
828
- ----
829
-
830
- Units refer to scales using a `scale_reference` object:
831
-
832
- [source,yaml]
833
- ----
834
- scale_reference:
835
- id: scale_id
836
- type: type_identifier
837
- ----
838
-
839
- ==== Notes
840
-
841
- The following scale types are currently defined:
842
-
843
- `continuous_ratio`:: A measurement scale with continuous values and a true zero
844
- point (most physical quantities)
845
-
846
- `continuous_interval`:: A measurement scale with continuous values but an
847
- arbitrary zero point (e.g., temperature in °C)
848
-
849
- `logarithmic_ratio`:: A logarithmic scale where equal ratios appear as equal
850
- intervals (e.g., decibels)
851
-
852
- `logarithmic_field`:: A logarithmic scale used for field quantities that uses
853
- natural logarithms (e.g., neper)
854
-
855
- `discrete`:: A scale consisting of discrete, countable values (e.g., bits)
856
-
857
-
858
- == Unit systems
859
-
860
- === General
861
-
862
- Unit systems are coherent collections of units that are used together to express
863
- measurements in a consistent way. Each unit system has its own set of base units
864
- and derived units, organized according to specific principles.
865
-
866
- The most widely used unit system is the International System of Units (SI), but
867
- the database also includes information about other unit systems and their
868
- relationships to SI.
869
-
870
- Unit systems help provide context for units, indicating whether they are part of
871
- the official SI system, acceptable for use with SI (like minutes or degrees), or
872
- belong to entirely different measurement frameworks (like imperial units). This
873
- context is important for interoperability and conversion between different
874
- measurement standards.
875
-
876
- In the UnitsDB, units are associated with their respective unit systems through
877
- references, allowing applications to identify which units belong to which
878
- systems and to determine compatibility between measurements expressed in
879
- different systems.
880
-
881
- A unit system object in `unit_systems.yaml` typically has the following structure:
882
-
883
- [source,yaml]
884
- ----
885
- - acceptable: {true|false} # whether the unit system is SI acceptable
886
- short: short_name
887
- identifiers:
888
- - id: unit_system_id
889
- type: type_identifier
890
- name: unit_system_name
891
- ----
892
-
893
- For example:
894
-
895
- [source,yaml]
896
- ----
897
- - acceptable: true
898
- short: si-compatible
899
- identifiers:
900
- - id: SI_compatible
901
- type: nist
902
- name: Units compatible with SI
903
- - acceptable: true
904
- short: si-base
905
- identifiers:
906
- - id: SI_base
907
- type: nist
908
- name: SI base units
909
- ----
910
-
911
- === Notes
912
-
913
- The following unit systems are currently defined:
914
-
915
- `si-base`:: Contains the seven SI base units (meter, kilogram, second, ampere,
916
- kelvin, mole, and candela). These form the foundation of the SI system.
917
-
918
- `si-derived-special`:: Contains SI-derived units with special names and symbols
919
- (e.g., newton, pascal, joule). These units are derived from base units but have
920
- been given unique names for convenience.
921
-
922
- `si-derived-nonspecial`:: Contains SI-derived units that use combinations of
923
- base unit symbols without special names (e.g., m/s, kg/m³).
924
-
925
- `si-compatible`:: Contains all units that are compatible with the SI system,
926
- including base units, derived units, and accepted non-SI units.
927
-
928
- `nonsi-acceptable`:: Contains non-SI units that are accepted for use with the SI
929
- system based on the BIPM SI Brochure (e.g., minute, hour, degree).
930
-
931
- `nonsi-unacceptable`:: Contains non-SI units that are not acceptable for use
932
- with the SI system (e.g., deprecated or obsolete units).
933
-
934
- `nonsi-nist-acceptable`:: Contains non-SI units that are acceptable according to
935
- NIST SP 811 but may not be officially accepted by BIPM (e.g., certain customary
936
- or traditional units).
937
-
938
-
939
- In UnitsDB, a unit can belong to multiple unit systems. This classification
940
- helps applications determine the appropriate use contexts for each unit.
941
-
942
- [example]
943
- A unit might be categorized as both `nonsi-unacceptable` (meaning it is not
944
- acceptable for SI usage) but also as `nonsi-nist-acceptable` (meaning NIST SP
945
- 811 considers it acceptable in certain contexts).
946
-
947
- When using unit systems in applications, the `acceptable` property can be used
948
- as a quick filter for SI-compliant units, while more specific categorization can
949
- be achieved using the individual unit system references.
950
-
951
-
952
- == Contributing
953
-
954
- === General
955
-
956
- When contributing to this repository, please follow these guidelines.
957
-
958
- === Proposing a new unit, dimension, or quantity
959
-
960
- . Check if the unit already exists in the database.
961
- . If it does not exist, create a new YAML file in the appropriate directory
962
- (e.g., `units.yaml`, `dimensions.yaml`, etc.).
963
- . Follow the structure outlined in the "Content classes" section.
964
- . Ensure that the new unit is properly referenced in the relevant files.
965
- . Add a test case for the new unit in the appropriate test file.
966
- . Run the tests to ensure everything is working correctly.
967
- . Submit a pull request with a clear description of the changes made.
968
- . Include any relevant references or sources for the new unit.
969
- . Ensure that the pull request is against the `main` branch of the repository.
970
- . Wait for review and feedback from the repository maintainers.
971
- . Address any comments or suggestions made during the review process.
972
- . Once approved, the pull request will be merged into the main branch.
973
-
974
-
975
- === Database normalization
976
-
977
- For ease of use, the database is normalized to avoid redundancy and ensure
978
- consistency.
979
-
980
- UnitsDB uses the `unitsdb` gem to normalize the database.
981
-
982
- NOTE: The `--sort=nist` option ensures that the output is sorted according to
983
- legacy NIST identifiers for stability reasons, which may change in the future.
984
-
985
- Please run the following commands to ensure that the database is
986
- normalized before submitting a pull request:
987
-
988
- [source,bash]
989
- ----
990
- $ gem install unitsdb
991
-
992
- $ unitsdb _modify normalize --all --database={unitsdb_yaml_dir} --sort=nist
993
-
994
- Normalized {unitsdb_yaml_dir}/dimensions.yaml
995
- Normalized {unitsdb_yaml_dir}/prefixes.yaml
996
- Normalized {unitsdb_yaml_dir}/quantities.yaml
997
- Normalized {unitsdb_yaml_dir}/unit_systems.yaml
998
- Normalized {unitsdb_yaml_dir}/units.yaml
999
- All YAML files normalized successfully!
1000
-
1001
- ----
1002
-
1003
- === Database validation
1004
-
1005
- All YAML files must be validated before submitting a pull request.
1006
-
1007
- UnitsDB uses the `unitsdb` gem to validate the database.
1008
-
1009
- [source,bash]
1010
- ----
1011
- # Validate all references
1012
- $ unitsdb validate references --database={unitsdb_yaml_dir}
1013
-
1014
- # Validate all identifiers
1015
- $ unitsdb validate identifiers --database={unitsdb_yaml_dir}
1016
-
1017
- # Check for duplicate SI references:
1018
- $ unitsdb validate si_references --database={unitsdb_yaml_dir}
1019
- ----
1020
-
1021
- === Creating release files
1022
-
1023
- When preparing an official release of UnitsDB, create unified release files for
1024
- users.
1025
-
1026
- UnitsDB uses the `unitsdb` gem to create release files.
1027
-
1028
- [source,bash]
1029
- ----
1030
- # Create both unified YAML and ZIP archive files
1031
- $ unitsdb release --database={unitsdb_yaml_dir} --output-dir=release
1032
-
1033
- # Create only unified YAML file
1034
- $ unitsdb release --format=yaml --database={unitsdb_yaml_dir} --output-dir=release
1035
-
1036
- # Create only ZIP archive
1037
- $ unitsdb release --format=zip --database={unitsdb_yaml_dir} --output-dir=release --version=2.1.0
1038
-
1039
- # Specify a version (required, must be in semantic format x.y.z)
1040
- $ unitsdb release --version=2.1.0 --database={unitsdb_yaml_dir} --output-dir=release
1041
- ----
1042
-
1043
- === Automated releases with GitHub Actions
1044
-
1045
- This repository includes a GitHub Actions workflow that automatically creates
1046
- release artifacts when a new version tag is pushed. To create a new release:
1047
-
1048
- . Tag the repository with the version number (prefixed with 'v'):
1049
- +
1050
- [source,bash]
1051
- ----
1052
- $ git tag v2.1.0
1053
- $ git push origin v2.1.0
1054
- ----
1055
-
1056
- . The GitHub Actions workflow will automatically:
1057
-
1058
- ** Generate the unified YAML file
1059
- ** Create a ZIP archive of all database files
1060
- ** Upload both files as release assets
1061
- ** Create a GitHub release with the tag name
1062
-
1063
- The release artifacts will be available on the GitHub releases page.
1064
-
1065
- The unified YAML file combines all database files into a single file for easier
1066
- integration:
1067
-
1068
- [source,yaml]
1069
- ----
1070
- schema_version: "2.0.0"
1071
- version: "2.1.0"
1072
- dimensions:
1073
- - identifiers: [...]
1074
- length: {...}
1075
- names: [...]
1076
- # ...
1077
- prefixes: [...]
1078
- quantities: [...]
1079
- units: [...]
1080
- unit_systems: [...]
1081
- ----
1082
-
1083
- This unified format makes it more convenient for users to work with the entire
1084
- database while ensuring all components are compatible with each other.
1085
-
1086
- The ZIP archive contains all individual database files for users who prefer to
1087
- work with separate files.
1088
-
1089
- Both release formats include version information in their filenames (e.g.,
1090
- `unitsdb-2.0.0.yaml` and `unitsdb-2.0.0.zip`).
1091
-
1092
-
1093
-
1094
- == Instructions for maintainers
1095
-
1096
- === Pre-publication
1097
-
1098
- Before publishing a new version of the UnitsDB, ensure that the following steps
1099
- are completed:
1100
-
1101
- . Run the normalization command to ensure all YAML files are consistent and
1102
- properly formatted.
1103
- . Run the validation commands to check for any issues with internal references,
1104
- identifiers and external references.
1105
-
1106
- === Normalize dataset
1107
-
1108
- [source,sh]
1109
- ----
1110
- bundle exec unitsdb _modify normalize --all --database=spec/fixtures/unitsdb --sort=nist
1111
- ----
1112
-
1113
- === Validate dataset
1114
-
1115
- Check for duplicate identifiers:
1116
-
1117
- [source,sh]
1118
- ----
1119
- bundle exec unitsdb validate identifiers --database=spec/fixtures/unitsdb
1120
- ----
1121
-
1122
- Check for duplicate internal references (e.g. units referencing quantities,
1123
- quantities referencing dimensions):
1124
-
1125
- [source,sh]
1126
- ----
1127
- bundle exec unitsdb validate references --database=spec/fixtures/unitsdb
1128
- ----
1129
-
1130
- Check for duplicate SI references:
1131
-
1132
- [source,sh]
1133
- ----
1134
- bundle exec unitsdb validate si_references --database=spec/fixtures/unitsdb
1135
- ----
1136
-
1137
- Check for duplicate UCUM references:
1138
-
1139
- [source,sh]
1140
- ----
1141
- bundle exec unitsdb validate ucum_references --database=spec/fixtures/unitsdb
1142
- ----
1143
-
1144
-
1145
- Check for duplicate QUDT references:
1146
-
1147
- [source,sh]
1148
- ----
1149
- bundle exec unitsdb validate qudt_references --database=spec/fixtures/unitsdb
1150
- ----
1151
-
1152
- QUDT references can be duplicated as some units do not uniquely map to a
1153
- QUDT URI. This is acceptable as long as the duplicates are documented in the
1154
- README file.
1155
-
1156
- These are the duplicated units:
1157
-
1158
- [source]
1159
- ----
1160
- QUDT URI: http://qudt.org/vocab/unit/IN3
1161
- Used by 2 entities:
1162
- - NISTu168 (cubic inch (en)) at index 81
1163
- - NISTu209 (inch cubed (en)) at index 122
1164
-
1165
- QUDT URI: http://qudt.org/vocab/unit/TSP
1166
- Used by 3 entities:
1167
- - NISTu303 (teaspoon (en)) at index 234
1168
- - NISTu306 (teaspoon (FDA) (en)) at index 237
1169
-
1170
- QUDT URI: http://qudt.org/vocab/unit/YD
1171
- Used by 2 entities:
1172
- - NISTu314 (yard (based on US survey foot) (en)) at index 246
1173
- - NISTu84 (yard (en)) at index 362
1174
-
1175
- QUDT URI: http://qudt.org/vocab/unit/IN
1176
- Used by 2 entities:
1177
- - NISTu316 (inch (based on US survey foot) (en)) at index 248
1178
- - NISTu8 (inch (en)) at index 360
1179
- ----
1180
-
1181
- These are the duplicated quantities:
1182
-
1183
- [source]
1184
- ----
1185
- QUDT URI: http://qudt.org/vocab/quantitykind/SecondAxialMomentOfArea
1186
- Used by 2 entities:
1187
- - NISTq127 (mass moment of inertia (en)) at index 31
1188
- - NISTq144 (second axial moment of area (en)) at index 50
1189
-
1190
- QUDT URI: http://qudt.org/vocab/quantitykind/Capacitance
1191
- Used by 2 entities:
1192
- - NISTq169 (electric capacitance (en)) at index 75
1193
- - NISTq27 (capacitance (en)) at index 120
1194
-
1195
- QUDT URI: http://qudt.org/vocab/quantitykind/Inductance
1196
- Used by 2 entities:
1197
- - NISTq171 (electric inductance (en)) at index 78
1198
- - NISTq32 (inductance (en)) at index 126
1199
- ----
1200
-
1201
- UnitsDB and QUDT take a different approach to dimensions:
1202
-
1203
- * QUDT focuses on the exponents of the dimensions, allowing only for
1204
- a single dimension to have the same exponent combination.
1205
-
1206
- * UnitsDB allows for multiple dimensions to have the same exponent combination,
1207
- as long as they are associated with different quantities.
1208
-
1209
- Naturally, multiple UnitsDB Dimensions can be mapped to a single QUDT Dimension,
1210
- hence there are no duplicate dimensions.
1211
-
1212
- The dimension mapping warnings are as follows (acceptable):
1213
-
1214
- [source]
1215
- ----
1216
- QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L0I0M0H0T0D0
1217
- Used by 12 entities:
1218
- - NISTd100 (traffic intensity (en)) at index 2
1219
- - NISTd102 (information content (en)) at index 4
1220
- - NISTd64 (solid angle (en)) at index 63
1221
- - NISTd67 (logarithmic ratio (en)) at index 66
1222
- - NISTd80 (ratio quantity (en)) at index 81
1223
- - NISTd83 (level of field quantity (en)) at index 82
1224
- - NISTd84 (field power level (en)) at index 83
1225
- - NISTd85 (mass mole fraction (en)) at index 84
1226
- - NISTd9 (plane angle (en)) at index 85
1227
- - NISTd94 (acidity index (en)) at index 86
1228
- - NISTd95 (storage capacity (en)) at index 87
1229
- - NISTd98 (phase (en)) at index 90
1230
-
1231
- QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L-0dot5I0M0dot5H0T-1D0
1232
- Used by 2 entities:
1233
- - NISTd101 (symbol rate (en)) at index 3
1234
- - NISTd24 (frequency (en)) at index 19
1235
-
1236
- QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L1I0M-1H0T2D0
1237
- Used by 2 entities:
1238
- - NISTd63 (compressibility (en)) at index 62
1239
- - NISTd70 (isothermal compressibility (en)) at index 70
1240
-
1241
- QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L-2I0M0H0T0D0
1242
- Used by 2 entities:
1243
- - NISTd96 (fluence (en)) at index 88
1244
- - NISTd99 (fuel efficiency (en)) at index 91
1245
- ----
1246
-
1247
- == Copyright and license
1248
-
1249
- Copyright CalConnect. Incorporates public domain work from NIST.
1250
-
1251
- This work is licensed under the Creative Commons Attribution 4.0 International
1252
- License. To view a copy of this license, visit
1253
- https://creativecommons.org/licenses/by/4.0/[CC-BY 4.0]