Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.