@@ -474,9 +474,8 @@ def fit(
474474
475475 # Perform the sliding window DMD fitting.
476476 for k in range (self ._n_slides ):
477- if verbose :
478- if k // 50 == k / 50 :
479- print ("{} of {}" .format (k , self ._n_slides ))
477+ if verbose and k % 50 == 0 :
478+ print ("{} of {}" .format (k , self ._n_slides ))
480479
481480 sample_slice = self .get_window_indices (k )
482481 data_window = data [:, sample_slice ]
@@ -487,8 +486,7 @@ def fit(
487486 time_window = original_time_window - t_start
488487
489488 # Subtract off the time mean before rounding corners.
490- c = np .mean (data_window , 1 , keepdims = True )
491- data_window = data_window - c
489+ data_window -= np .mean (data_window , 1 , keepdims = True )
492490
493491 # Round the corners of the window.
494492 data_window = data_window * lv_kern
@@ -518,8 +516,8 @@ def fit(
518516 self ._amplitudes_array [
519517 k , : optdmd .eigs .shape [0 ]
520518 ] = optdmd .amplitudes
521- self ._window_means_array [k , : ] = c .flatten ()
522- self ._time_array [k , : ] = original_time_window
519+ self ._window_means_array [k ] = c .flatten ()
520+ self ._time_array [k ] = original_time_window
523521
524522 # Reset optdmd between iterations
525523 if not self ._global_svd :
@@ -549,12 +547,11 @@ def get_window_indices(self, k):
549547 # Get the window indices and data.
550548 sample_start = self ._step_size * k
551549 if k == self ._n_slides - 1 and self ._non_integer_n_slide :
552- sample_slice = slice (- self ._window_length , None )
550+ return slice (- self ._window_length , None )
553551 else :
554- sample_slice = slice (
552+ return slice (
555553 sample_start , sample_start + self ._window_length
556554 )
557- return sample_slice
558555
559556 def cluster_omega (
560557 self ,
@@ -875,7 +872,7 @@ def scale_reconstruction(
875872 (self ._n_components , self ._n_data_vars , self ._window_length )
876873 )
877874 for j in np .unique (self ._omega_classes ):
878- xr_sep_window [j , :, : ] = np .linalg .multi_dot (
875+ xr_sep_window [j ] = np .linalg .multi_dot (
879876 [
880877 w [:, classification == j ],
881878 np .diag (b [classification == j ]),
@@ -884,12 +881,12 @@ def scale_reconstruction(
884881 ).real
885882
886883 # Add the constant offset to the lowest frequency cluster.
887- if include_means and ( j == np .argmin (self ._cluster_centroids ) ):
888- xr_sep_window [j , :, : ] += c
889- xr_sep_window [j , :, : ] = xr_sep_window [j , :, : ] * recon_filter
884+ if include_means and j == np .argmin (self ._cluster_centroids ):
885+ xr_sep_window [j ] += c
886+ xr_sep_window [j ] = xr_sep_window [j ] * recon_filter
890887
891888 xr_sep [j , :, window_indices ] = (
892- xr_sep [j , :, window_indices ] + xr_sep_window [j , :, : ]
889+ xr_sep [j , :, window_indices ] + xr_sep_window [j ]
893890 )
894891
895892 xn [window_indices ] += recon_filter
@@ -921,8 +918,8 @@ def scale_separation(
921918 scale_reconstruction_kwargs = {}
922919
923920 xr_sep = self .scale_reconstruction (** scale_reconstruction_kwargs )
924- xr_low_frequency = xr_sep [0 , :, : ]
925- xr_high_frequency = xr_sep [1 :, :, : ].sum (axis = 0 )
921+ xr_low_frequency = xr_sep [0 ]
922+ xr_high_frequency = xr_sep [1 :].sum (axis = 0 )
926923
927924 return xr_low_frequency , xr_high_frequency
928925
0 commit comments