Skip to content

Commit

Permalink
iss #317 updated tests for ti_by_speed and ti_by_sector
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaMorandi committed Sep 23, 2022
1 parent fec466a commit c1b017f
Showing 1 changed file with 78 additions and 47 deletions.
125 changes: 78 additions & 47 deletions tests/test_analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,55 +240,77 @@ def test_freq_distribution():

def test_ti_by_speed():

test_ti_by_speed_bin_array = {'Mean_TI': {4.5: 0.15124581667455453,
test_ti_by_speed_bin_array = {'Mean_TI': {4.5: 0.15124777491566763,
7.5: 0.13158122759240676,
12.0: 0.12473334724384767},
'TI_Count': {4.5: 25027, 7.5: 27213, 12.0: 26437},
'Rep_TI': {4.5: 0.22572568437604773,
'TI_Count': {4.5: 25031, 7.5: 27213, 12.0: 26437},
'Rep_TI': {4.5: 0.22573060127645284,
7.5: 0.1881407118736615,
12.0: 0.16969818181818183},
'TI_2Sigma': {4.5: 0.05911507994665081,
'TI_2Sigma': {4.5: 0.059115807168742804,
7.5: 0.044441958424280635,
12.0: 0.03520805434851466},
'Char_TI': {4.5: 0.16438250110714359,
'Char_TI': {4.5: 0.16438462095316603,
7.5: 0.13750682204897752,
12.0: 0.12766735177289057}}

test_ti_by_speed_bin_array2 = {'Mean_TI': {'low': 0.13944474768114679,
test_ti_by_speed_bin_array2 = {'Mean_TI': {'low': 0.13944637051406314,
'mid': 0.12372651374784537,
'high': 0.12254109581590693},
'TI_Count': {'low': 59288, 'mid': 17195, 'high': 6663},
'Rep_TI': {'low': 0.20381879897546248,
'TI_Count': {'low': 59292, 'mid': 17195, 'high': 6663},
'Rep_TI': {'low': 0.20382511623126082,
'mid': 0.1673447365400069,
'high': 0.16159546015544596},
'TI_2Sigma': {'low': 0.0516085535560296,
'TI_2Sigma': {'low': 0.05160972850404876,
'mid': 0.0341280596615336,
'high': 0.029851100229302402},
'Char_TI': {'low': 0.1497664583923527,
'Char_TI': {'low': 0.14976831621487288,
'mid': 0.12657051871963984,
'high': 0.12345959120757777}}

test_ti_by_speed_60 = {'Mean_TI': {3: 0.17129148712660225,
4: 0.15753962700071988,
5: 0.14482158443013746,
6: 0.13641813322761087,
7: 0.1325670736954525},
'TI_Count': {3: 3429, 4: 7963, 5: 8852, 6: 9519, 7: 9594},
'Rep_TI': {3: 0.17543035254262307,
4: 0.16245464044034938,
5: 0.15040443470563478,
6: 0.1418432505128954,
7: 0.13854835151131448},
'TI_2Sigma': {3: 0.06698115776542371,
test_ti_by_speed_min_speed = {'Mean_TI': {4: 0.15310683024630714,
5: 0.14482158443013746,
6: 0.13641813322761087,
7: 0.1325670736954525,
8: 0.13020676103259748},
'TI_Count': {4: 4135, 5: 8852, 6: 9519, 7: 9594, 8: 8915},
'Rep_TI': {4: 0.2285380119079891,
5: 0.21378763321929659,
6: 0.1987517397608554,
7: 0.19137987964978603,
8: 0.18528433875229525},
'TI_2Sigma': {4: 0.058280365304773825,
5: 0.054828671650069015,
6: 0.04931461395056968,
7: 0.045463561091098434,
8: 0.04349206789697012},
'Char_TI': {4: 0.1676769215725006,
5: 0.15578731876015126,
6: 0.14463723555270583,
7: 0.139061868137038,
8: 0.13564326951971875}}

test_ti_by_speed_60 = {'Mean_TI': {3: 0.17128240878447984,
4: 0.15753962700071988,
5: 0.14482158443013746,
6: 0.13641813322761087,
7: 0.1325670736954525},
'TI_Count': {3: 3433, 4: 7963, 5: 8852, 6: 9519, 7: 9594},
'Rep_TI': {3: 0.1754213503976292,
4: 0.16245464044034938,
5: 0.15040443470563478,
6: 0.1418432505128954,
7: 0.13854835151131448},
'TI_2Sigma': {3: 0.066976430190277,
4: 0.061226153615559394,
5: 0.054828671650069015,
6: 0.04931461395056968,
7: 0.045463561091098434},
'Char_TI': {3: 0.1936185397150768,
4: 0.17284616540460973,
5: 0.15578731876015126,
6: 0.14463723555270583,
7: 0.139061868137038}}
'Char_TI': {3: 0.19360788551457217,
4: 0.17284616540460973,
5: 0.15578731876015126,
6: 0.14463723555270583,
7: 0.139061868137038}}

# Test plot TI distribution by speed bins using default inputs
bw.TI.by_speed(DATA[['Spd80mN']], DATA[['Spd80mNStd']])
Expand All @@ -311,6 +333,15 @@ def test_ti_by_speed():
for sub_key in ti_by_speed[key]:
assert round(ti_by_speed[key][sub_key], 5) == round(test_ti_by_speed_bin_array2[key][sub_key], 5)

# Test plot TI distribution by speed bins and give as input min_speed
fig_ti_by_speed, ti_by_speed = bw.TI.by_speed(DATA.Spd80mN, DATA.Spd80mNStd, min_speed=4, return_data=True)

ti_by_speed = ti_by_speed.iloc[0:5].to_dict()
for k, key in enumerate(ti_by_speed):
assert key == list(test_ti_by_speed_min_speed.keys())[k]
for sub_key in ti_by_speed[key]:
assert round(ti_by_speed[key][sub_key], 5) == round(test_ti_by_speed_min_speed[key][sub_key], 5)

# 60 percentile
fig_ti_by_speed, ti_by_speed = bw.TI.by_speed(DATA.Spd80mN, DATA.Spd80mNStd, percentile=60, return_data=True)
ti_by_speed = ti_by_speed.iloc[0:5].to_dict()
Expand All @@ -322,27 +353,27 @@ def test_ti_by_speed():

def test_ti_by_sector():

test_ti_by_sector0 = {'Mean_TI': {'345.0-15.0': 0.13583575955142652,
test_ti_by_sector0 = {'Mean_TI': {'345.0-15.0': 0.13589964861155734,
'15.0-45.0': 0.11667924414431009,
'45.0-75.0': 0.16933195767316922,
'75.0-105.0': 0.15813582737310894,
'75.0-105.0': 0.15813569517792542,
'105.0-135.0': 0.11642412861819129},
'TI_Count': {'345.0-15.0': 2052,
'TI_Count': {'345.0-15.0': 2053,
'15.0-45.0': 3783,
'45.0-75.0': 2688,
'75.0-105.0': 3548,
'75.0-105.0': 3549,
'105.0-135.0': 3694}}

test_ti_by_sector1 = {'Mean_TI': {'330.0-30.0': 0.13162127717869374,
'30.0-90.0': 0.150479856228039,
'90.0-150.0': 0.12436564388457913,
'150.0-210.0': 0.13782265164954294,
'210.0-270.0': 0.129002769976217},
'TI_Count': {'330.0-30.0': 4498,
'30.0-90.0': 6896,
'90.0-150.0': 6247,
'150.0-210.0': 17391,
'210.0-270.0': 19893}}
test_ti_by_sector1 = {'Mean_TI': {'330.0-30.0': 0.14156137001941677,
'30.0-90.0': 0.1554269271296417,
'90.0-150.0': 0.1329863186637839,
'150.0-210.0': 0.14145589008973855,
'210.0-270.0': 0.13242499161437354},
'TI_Count': {'330.0-30.0': 5171,
'30.0-90.0': 7921,
'90.0-150.0': 7010,
'150.0-210.0': 18255,
'210.0-270.0': 20905}}

test_ti_by_sector2 = {'Mean_TI': {'330.0-30.0': 0.1223750677509429,
'30.0-90.0': 0.14552262920219694,
Expand All @@ -355,14 +386,14 @@ def test_ti_by_sector():
'150.0-210.0': 14525,
'210.0-270.0': 16995}}

test_ti_by_sector3 = {'Mean_TI': {'northerly': 0.14386005120623407,
test_ti_by_sector3 = {'Mean_TI': {'northerly': 0.14386147442192937,
'easterly': 0.12732598484437524,
'southerly': 0.13147666075903275,
'westerly': 0.13579682449004113},
'TI_Count': {'northerly': 9700,
'southerly': 0.13147531335946452,
'westerly': 0.13579958704050313},
'TI_Count': {'northerly': 9701,
'easterly': 4645,
'southerly': 14454,
'westerly': 40808}}
'southerly': 14455,
'westerly': 40810}}

# Test plot TI distribution by sector using default inputs
bw.TI.by_sector(DATA[['Spd80mN']], DATA[['Spd80mNStd']], DATA[['Dir78mS']])
Expand Down

0 comments on commit c1b017f

Please sign in to comment.