From 411625fe1b80222330e08e08f31a098eb4085572 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Mon, 17 Sep 2018 17:13:11 +1000 Subject: [PATCH] Update readme --- README.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 30eb47d..7e86ded 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pip install git+http://git.wrl.unsw.edu.au:3000/danh/scaling.git ## Usage -```sh +```python >>> from scaling import Froude >>> froude = FroudeConverter() @@ -27,9 +27,44 @@ pip install git+http://git.wrl.unsw.edu.au:3000/danh/scaling.git 'L^2 M^1 T^-2' ``` +Dataframes are also accepted, and specific units can be specified for the values in the index. + +```python +>>> T = 2 +>>> H = 100 + +>>> # Generate regular waves with height=100mm, and period=2s +>>> t = np.arange(0, 10.1, 0.1) +>>> eta = 0.5 * H * np.sin(t * 2 * np.pi / T) + +>>> df_model = pd.DataFrame(index=t, data=eta) +>>> df_model.columns = ['$\eta$ (mm)'] +>>> df_model.index.name = 'Time (s)' + +>>> df_model.plot() +``` + +![](doc/model.png#0) + +```python +>>> # Convert to prototype dimensions, with length scale=25 +df_proto = froude.model_to_proto( + df_model, + length_scale=25, + input_unit='mm', + target_unit='m', + index_input_unit='s', + index_target_unit='s') + +df_proto.columns = ['$\eta$ (m)'] +df_proto.plot() +``` +![](doc/proto.png#0) + + `scaling` uses `pint` for unit and dimension conversions. `pint` is able to interpret a wide range of different input units. -```sh +```python >>> # Convert water head model value (mm) to prototype pressure value (kPa) >>> froude.model_to_proto(10, length_scale=100, 'mm.H20', 'kPa') 9.80665