https://github.com/erikerlandson/unit-analysis-json-schema
JSON Schema for algorithmic unit analysis
https://github.com/erikerlandson/unit-analysis-json-schema
dimensional-analysis json json-schema unit-analysis
Last synced: 4 months ago
JSON representation
JSON Schema for algorithmic unit analysis
- Host: GitHub
- URL: https://github.com/erikerlandson/unit-analysis-json-schema
- Owner: erikerlandson
- License: apache-2.0
- Created: 2020-02-08T17:45:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-13T22:54:02.000Z (over 5 years ago)
- Last Synced: 2025-01-06T00:12:48.480Z (6 months ago)
- Topics: dimensional-analysis, json, json-schema, unit-analysis
- Size: 23.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unit-analysis-json-schema
JSON Schema for algorithmic unit analysisEncodes unit-analysis definitions based on the blog post
["Algorithmic Unit Analysis"](http://erikerlandson.github.io/blog/2019/05/03/algorithmic-unit-analysis/)### examples
A unit analysis schema is an array of unit definitions.
The following example shows some `"base"` and `"derived"` unit definitions.
```json
[
{"unit": "base", "name": "meter", "abbv": "m"},{"unit": "base", "name": "second", "abbv": "s"},
{"unit": "derived", "name": "minute", "coef": 60, "expr": "second"},
{"unit": "derived",
"name": "liter", "abbv": "L",
"coef": {"coef": "rational", "num": 1, "den": 1000},
"expr": {"lhs": "meter", "op": "^", "rhs": 3}
},{"unit": "derived",
"name": "gravity", "abbv": "g",
"coef": 9.8,
"expr": {"lhs": "meter", "op": "/", "rhs": {"lhs": "second", "op": "^", "rhs": 2}}
},{"unit": "derived", "name": "kilo", "coef": 1000, "expr": "unitless"}
]
```Here is an Avro schema augmented with unit expressions:
```json
{
"type": "record",
"name": "demo_units",
"fields": [
{ "name": "distance", "type": "float", "unit": "meter" },
{ "name": "velocity",
"type": "float",
"unit": {"lhs": "meter", "op": "/", "rhs": "second"} }
]
}
```