Skip to content

Commit

Permalink
minor refractoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TannazH committed Aug 30, 2024
1 parent 86df53b commit 5819fa5
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions tests/test_meteorology.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from pyelq.coordinate_system import LLA
from pyelq.meteorology import Meteorology, MeteorologyGroup
from pytictoc import TicToc


@pytest.mark.parametrize(
Expand Down Expand Up @@ -221,24 +220,15 @@ def test_calculate_wind_turbulence_horizontal():
pd.date_range(dt.datetime(2023, 1, 1), dt.datetime(2023, 1, 2), freq="5s"), dtype="datetime64[ns]"
)
met.wind_direction = np.random.normal(180, sigma, met.time.shape[0])
time_met = TicToc()
time_met.tic()
met.calculate_wind_turbulence_horizontal(window="300s")
time_met.toc()
time_elapsed_met = time_met.elapsed

time_circstd = TicToc()
data_series = pd.Series(data=met.wind_direction, index=met.time)
time_circstd.tic()
wind_turbulance_circstd = data_series.rolling(window="300s", center=True, min_periods=3).apply(
circstd, kwargs={"low": 0, "high": 360})
time_circstd.toc()
time_elapsed_circstd = time_circstd.elapsed


tolerance = 3 * np.std(met.wind_turbulence_horizontal)
mean_turbulence = np.mean(met.wind_turbulence_horizontal)
mean_turbilance_circstd = np.mean(wind_turbulance_circstd)
assert time_elapsed_met < 1/100 * time_elapsed_circstd
assert (mean_turbulence - tolerance) < sigma < (mean_turbulence + tolerance)
assert np.isclose(mean_turbulence, mean_turbilance_circstd)

0 comments on commit 5819fa5

Please sign in to comment.