3333for i , t_c in enumerate (t_component ):
3434 p [i ] = s_component * t_c
3535
36- # Let's take a look at the dimension of our data
37- # to make sure it is compatible with pyspod
38- print ('p.shape = ' , p .shape )
39-
4036# Let's define the required parameters into a dictionary
4137params = dict ()
4238
5854params ['n_modes_save' ] = 3 # modes to be saved
5955params ['normvar' ] = False # normalize data by data variance
6056params ['conf_level' ] = 0.95 # calculate confidence level
61- params ['savefft' ] = True # save FFT blocks to reuse them in the future (saves time)
57+ params ['savefft' ] = False # save FFT blocks to reuse them in the future (saves time)
6258
6359
6460
@@ -68,7 +64,7 @@ def test_basic_spod_low_storage():
6864 # Initialize libraries for the low_storage algorithm
6965 spod_ls = SPOD_low_storage (p , params = params , data_handler = False , variables = ['p' ])
7066 spod_ls .fit ()
71-
67+
7268 # Let's plot the data
7369 spod_ls .plot_2D_data (time_idx = [1 ,2 ], filename = 'tmp.png' )
7470 spod_ls .plot_data_tracers (coords_list = [(5 ,2.5 )], time_limits = [0 ,t .shape [0 ]], filename = 'tmp.png' )
@@ -77,13 +73,13 @@ def test_basic_spod_low_storage():
7773 bashCmd = ["ffmpeg" , " --version" ]
7874 sbp = subprocess .Popen (bashCmd , stdin = subprocess .PIPE )
7975 spod_ls .generate_2D_data_video (
80- sampling = 10 ,
81- time_limits = [0 ,t .shape [0 ]],
76+ sampling = 10 ,
77+ time_limits = [0 ,t .shape [0 ]],
8278 filename = 'video.mp4' )
8379 except :
84- print ('[test_basic_file_spod_low_storage]: ' ,
80+ print ('[test_basic_file_spod_low_storage]: ' ,
8581 'Skipping video making as `ffmpeg` not present.' )
86-
82+
8783 # Show results
8884 T_approx = 10 # approximate period = 10 days (in days)
8985 freq = spod_ls .freq
@@ -100,15 +96,15 @@ def test_basic_spod_low_storage():
10096 modes_idx = [0 ,1 ],
10197 vars_idx = [0 ],
10298 filename = 'tmp.png' )
103-
104-
10599
106- @pytest .mark .order2
107- def test_basic_spod_low_ram ():
100+
101+
102+ @pytest .mark .order2
103+ def test_basic_spod_low_ram ():
108104 # Let's try the low_ram algorithm
109105 spod_ram = SPOD_low_ram (p , params = params , data_handler = False , variables = ['p' ])
110106 spod_ram .fit ()
111-
107+
112108 # Show results
113109 T_approx = 10 # approximate period = 10 days (in days)
114110 freq = spod_ram .freq
@@ -126,16 +122,16 @@ def test_basic_spod_low_ram():
126122 vars_idx = [0 ],
127123 filename = 'tmp.png' )
128124 tol = 1e-10
129- assert ((np .abs (modes_at_freq [5 ,10 ,0 ,0 ]) < 0.010068515759308167 + tol ) & \
130- (np .abs (modes_at_freq [5 ,10 ,0 ,0 ]) > 0.010068515759308167 - tol ))
131- assert ((np .abs (modes_at_freq [0 ,0 ,0 ,0 ]) < 0.012180208154393609 + tol ) & \
132- (np .abs (modes_at_freq [0 ,0 ,0 ,0 ]) > 0.012180208154393609 - tol ))
133- assert ((np .abs (modes_at_freq [5 ,10 ,0 ,1 ]) < 5.117415619566953e -09+ tol ) & \
134- (np .abs (modes_at_freq [5 ,10 ,0 ,1 ]) > 5.117415619566953e -09- tol ))
135- assert ((np .abs (modes_at_freq [5 ,10 ,0 ,2 ]) < 6.929706983609628e -09+ tol ) & \
136- (np .abs (modes_at_freq [5 ,10 ,0 ,2 ]) > 6.929706983609628e -09- tol ))
137- assert ((np .max (np .abs (modes_at_freq )) < 0.029919118328162627 + tol ) & \
138- (np .max (np .abs (modes_at_freq )) > 0.029919118328162627 - tol ))
125+ assert ((np .abs (modes_at_freq [5 ,10 ,0 ,0 ]) < 0.010068515759308162 + tol ) & \
126+ (np .abs (modes_at_freq [5 ,10 ,0 ,0 ]) > 0.010068515759308162 - tol ))
127+ assert ((np .abs (modes_at_freq [0 ,0 ,0 ,0 ]) < 0.01218020815439358 + tol ) & \
128+ (np .abs (modes_at_freq [0 ,0 ,0 ,0 ]) > 0.01218020815439358 - tol ))
129+ assert ((np .abs (modes_at_freq [5 ,10 ,0 ,1 ]) < 2.7677058004877376e -09+ tol ) & \
130+ (np .abs (modes_at_freq [5 ,10 ,0 ,1 ]) > 2.7677058004877376e -09- tol ))
131+ assert ((np .abs (modes_at_freq [5 ,10 ,0 ,2 ]) < 4.204229641776651e -09 + tol ) & \
132+ (np .abs (modes_at_freq [5 ,10 ,0 ,2 ]) > 4.204229641776651e -09 - tol ))
133+ assert ((np .max (np .abs (modes_at_freq )) < 0.02991911832816271 + tol ) & \
134+ (np .max (np .abs (modes_at_freq )) > 0.02991911832816271 - tol ))
139135
140136
141137
@@ -144,7 +140,7 @@ def test_basic_spod_streaming():
144140 # Finally, we can try the streaming algorithm
145141 spod_st = SPOD_streaming (p , params = params , data_handler = False , variables = ['p' ])
146142 spod_st .fit ()
147-
143+
148144 # Show results
149145 T_approx = 10 # approximate period = 10 days (in days)
150146 freq = spod_st .freq
@@ -178,10 +174,6 @@ def test_basic_spod_streaming():
178174 shutil .rmtree (os .path .join (CWD ,'results' ))
179175 except OSError as e :
180176 print ("Error: %s : %s" % (os .path .join (CWD ,'results' ), e .strerror ))
181- try :
182- shutil .rmtree (os .path .join (CFD ,'__pycache__' ))
183- except OSError as e :
184- print ("Error: %s : %s" % (os .path .join (CFD ,'__pycache__' ), e .strerror ))
185177
186178
187179
@@ -190,5 +182,3 @@ def test_basic_spod_streaming():
190182 test_basic_spod_low_storage ()
191183 test_basic_spod_low_ram ()
192184 test_basic_spod_streaming ()
193-
194-
0 commit comments