|
| 1 | +""" |
| 2 | +ASV benchmarks for scaling.py |
| 3 | +""" |
| 4 | + |
| 5 | +import pandas as pd |
| 6 | +from pvlib import scaling |
| 7 | +import numpy as np |
| 8 | + |
| 9 | + |
| 10 | +class Scaling: |
| 11 | + |
| 12 | + def setup(self): |
| 13 | + self.n = 1000 |
| 14 | + lat = np.array((9.99, 10, 10.01)) |
| 15 | + lon = np.array((4.99, 5, 5.01)) |
| 16 | + self.coordinates = np.array([(lati, loni) for |
| 17 | + (lati, loni) in zip(lat, lon)]) |
| 18 | + self.times = pd.date_range('2019-01-01', freq='1T', periods=self.n) |
| 19 | + self.positions = np.array([[0, 0], [100, 0], [100, 100], [0, 100]]) |
| 20 | + self.clearsky_index = pd.Series(np.random.rand(self.n), |
| 21 | + index=self.times) |
| 22 | + self.cloud_speed = 5 |
| 23 | + self.tmscales = np.array((1, 2, 4, 8, 16, 32, 64, |
| 24 | + 128, 256, 512, 1024, 2048, 4096)) |
| 25 | + |
| 26 | + def time_latlon_to_xy(self): |
| 27 | + scaling.latlon_to_xy(self.coordinates) |
| 28 | + |
| 29 | + def time__compute_wavelet(self): |
| 30 | + scaling._compute_wavelet(self.clearsky_index, dt=1) |
| 31 | + |
| 32 | + def time__compute_vr(self): |
| 33 | + scaling._compute_vr(self.positions, self.cloud_speed, self.tmscales) |
| 34 | + |
| 35 | + def time_wvm(self): |
| 36 | + scaling.wvm(self.clearsky_index, self.positions, |
| 37 | + self.cloud_speed, dt=1) |
0 commit comments