metrum 0.1.0
A collection of unit of measure.
Requires Python: >=3.9

# metrum

[![PyPI version](https://badge.fury.io/py/metrum.svg)](https://badge.fury.io/py/metrum)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

A collection of unit of measure.

`metrum` is a Python library that provides a simple and intuitive way to work 
with units of measurement in your code. It helps improve code readability and 
ensures consistency by converting all quantities to a standard set of reference 
units (SI units).

## Installation

You can install `metrum` using `pip`:

```bash
pip install metrum
```

## Usage

Using `metrum` is straightforward. Import the units you need and use them in 
your calculations.

```python
from metrum.units import cm, g, usc_in

height = 180 * cm    # cm = 0.01 * m, so height is 1.8 (meters)
weight = 250 * g     # g = 0.001 * kg, so weight is 0.25 (kilograms)
width = 10 * usc_in  # usc_in = 0.0254 * m, so width is 0.254 (meters)

print(f"Height: {height} m")
print(f"Weight: {weight} kg")
print(f"Width: {width} m")
```

This makes your code more explicit and easier to understand, as the units are 
clearly stated. All conversions are handled automatically, bringing the values 
to the base SI units.

## Reference Units

The library converts all units to a consistent set of reference units. The base 
units are the 7 SI base units, and the rest are SI derived units.

| Quantity                 | Unit      | Var. Name |
|--------------------------|-----------|-----------|
| Time                     | second    | s         |
| Length                   | metre     | m         |
| Mass                     | kilogram  | kg        |
| Electric current         | ampere    | A         |
| Temperature              | kelvin    | K         |
| Amount of substance      | mole      | mol       |
| Luminous intensity       | candela   | cd        |
| ... and many more derived units ... |

For each base unit, `metrum` also provides prefixed versions (pico, nano, 
micro, milli, centi, deci, deca, hetto, kilo, mega, giga, tera).

## Special Units

Besides the SI units, `metrum` also supports a variety of special units, 
including:

- Time: `min`, `h`, `d`
- Length: `au` (astronomical unit), US Customary units (`usc_in`, `usc_ft`, `usc_mi`, etc.)
- Mass: `t` (tonne), `Da` (dalton), US Customary units (`usc_oz`, `usc_lb`, etc.)
- and many more.

For a complete list of all available units, see the metrum.units module 
[documentation page](https://www.onlabs.org/metrum/apis/units/).

## Contributing

Contributions are welcome! If you have a unit of measure you'd like to see 
added or want to improve the library in any other way, please feel free to open 
an issue or submit a pull request on our [GitHub repository](https://github.com/onlabsorg/metrum).

## License

This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) 
file for details.

## Author

- **Marcello Del Buono** - [m.delbuono@google.com](mailto:m.delbuono@google.com)

## Project Links

- [Homepage](https://github.com/onlabsorg/metrum)
- [Issue Tracker](https://github.com/onlabsorg/metrum/issues)
- [API Documentation](https://www.onlabs.org/metrum/)