@@ -37,6 +37,18 @@ def time(clear_sky_index):
3737 return np .arange (0 , len (clear_sky_index ))
3838
3939
40+ @pytest .fixture
41+ def time_60s (clear_sky_index ):
42+ # Sample time vector 60s resolution
43+ return np .arange (0 , len (clear_sky_index ))* 60
44+
45+
46+ @pytest .fixture
47+ def time_500ms (clear_sky_index ):
48+ # Sample time vector 0.5s resolution
49+ return np .arange (0 , len (clear_sky_index ))* 0.5
50+
51+
4052@pytest .fixture
4153def positions ():
4254 # Sample positions based on the previous lat/lon (calculated manually)
@@ -51,6 +63,18 @@ def expect_tmscale():
5163 return [1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 ]
5264
5365
66+ @pytest .fixture
67+ def expect_tmscale_1min ():
68+ # Expected timescales for dt = 60
69+ return [60 , 120 , 240 , 480 , 960 , 1920 , 3840 ]
70+
71+
72+ @pytest .fixture
73+ def expect_tmscale_500ms ():
74+ # Expected timescales for dt = 0.5
75+ return [0.5 , 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 ]
76+
77+
5478@pytest .fixture
5579def expect_wavelet ():
5680 # Expected wavelet for indices 5000:5004 for clear_sky_index above (Matlab)
@@ -68,6 +92,13 @@ def expect_cs_smooth():
6892 return np .array ([1. , 1. , 1.05774 , 0.94226 , 1. ])
6993
7094
95+ @pytest .fixture
96+ def expect_vr ():
97+ # Expected VR for expecttmscale
98+ return np .array ([3. , 3. , 3. , 3. , 3. , 3. , 2.9997844 , 2.9708118 , 2.6806291 ,
99+ 2.0726611 , 1.5653324 , 1.2812714 , 1.1389995 ])
100+
101+
71102def test_latlon_to_xy_zero ():
72103 coord = [0 , 0 ]
73104 pos_e = [0 , 0 ]
@@ -109,6 +140,25 @@ def test_compute_wavelet_series_numindex(clear_sky_index, time,
109140 assert_almost_equal (wavelet [:, 5000 :5005 ], expect_wavelet )
110141
111142
143+ def test_compute_wavelet_series_highres (clear_sky_index , time_500ms ,
144+ expect_tmscale_500ms , expect_wavelet ):
145+ dtindex = pd .to_datetime (time_500ms , unit = 's' )
146+ csi_series = pd .Series (clear_sky_index , index = dtindex )
147+ wavelet , tmscale = scaling ._compute_wavelet (csi_series )
148+ assert_almost_equal (tmscale , expect_tmscale_500ms )
149+ assert_almost_equal (wavelet [:, 5000 :5005 ].shape , (14 , 5 ))
150+
151+
152+ def test_compute_wavelet_series_minuteres (clear_sky_index , time_60s ,
153+ expect_tmscale_1min , expect_wavelet ):
154+ dtindex = pd .to_datetime (time_60s , unit = 's' )
155+ csi_series = pd .Series (clear_sky_index , index = dtindex )
156+ wavelet , tmscale = scaling ._compute_wavelet (csi_series )
157+ assert_almost_equal (tmscale , expect_tmscale_1min )
158+ assert_almost_equal (wavelet [:, 5000 :5005 ].shape ,
159+ expect_wavelet [0 :len (tmscale ), :].shape )
160+
161+
112162def test_compute_wavelet_array (clear_sky_index ,
113163 expect_tmscale , expect_wavelet ):
114164 wavelet , tmscale = scaling ._compute_wavelet (clear_sky_index , dt )
@@ -129,6 +179,11 @@ def test_compute_wavelet_dwttheory(clear_sky_index, time,
129179 assert_almost_equal (np .sum (wavelet , 0 ), csi_series )
130180
131181
182+ def test_compute_vr (positions , expect_tmscale , expect_vr ):
183+ vr = scaling ._compute_vr (positions , cloud_speed , np .array (expect_tmscale ))
184+ assert_almost_equal (vr , expect_vr )
185+
186+
132187def test_wvm_series (clear_sky_index , time , positions , expect_cs_smooth ):
133188 csi_series = pd .Series (clear_sky_index , index = time )
134189 cs_sm , _ , _ = scaling .wvm (csi_series , positions , cloud_speed )
0 commit comments