Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mossr/si.jl
Julia SI unit types for validated unit conversions.
https://github.com/mossr/si.jl
Last synced: about 1 month ago
JSON representation
Julia SI unit types for validated unit conversions.
- Host: GitHub
- URL: https://github.com/mossr/si.jl
- Owner: mossr
- Created: 2014-06-03T02:22:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-03T03:24:00.000Z (over 10 years ago)
- Last Synced: 2023-08-10T09:07:03.755Z (over 1 year ago)
- Language: Julia
- Size: 137 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
SI.jl
=============A Julia library for unit types validated unit conversions.
- **[Robert Moss](mailto:[email protected])**
### Initialization
Load the library via ```require("SI.jl")``` then display the available types and explicit conversions with ```showSI()``` .
**Note:**
Implicit types and conversions are available as long as each unit is defined within SI.jl
**Example**:
The type ```m/s``` is not defined, but both ```m``` (meters) and ```s``` (seconds) are defined.### Unit Types
distance = SI(90.2, :km) # kilometers
time = SI(4.2, :s) # seconds### Unit Arithmetic
velocity = distance/time
SI(21.476190476190474,:km/s,"kilometers per second",:velocity)### Unit Conversion
velocity >> symbol("m/s") # use symbol function for units containing '/'
SI(21476.190079180236,:m/s,"meters per second",:velocity)### User defined unit conversions
To add your own unit conversions to the ```unit_conversions.jl``` file.
##### Nomenclature for user defined unit conversions
1. Use the macro ```@conversion``` to include the user defined function within ```showSI()```.
2. Use the style of ```this_to_that(this)``` function names.