Skip to content

Commit e74041c

Browse files
committed
Changed mode_prox functionality
1 parent 9edbf04 commit e74041c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pydmd/bopdmd.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ class BOPDMDOperator(DMDOperator):
7373
of the variable projection routine.
7474
:type eig_constraints: set(str) or function
7575
:param mode_prox: Optional proximal operator function to apply to the DMD
76-
modes at every iteration of the variable projection routine.
76+
modes. If `use_proj` is False, this function is applied at every
77+
iteration of the variable projection routine. If `use_proj` is True,
78+
this function is instead applied at the end of the variable projection
79+
routine after the modes have been projected back to the space of the
80+
full input data.
7781
:type mode_prox: function
7882
:param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
7983
at which to terminate the fit. Set this parameter to infinity for no
@@ -529,8 +533,8 @@ def compute_B(alpha):
529533
# Compute B using least squares.
530534
B = np.linalg.lstsq(Phi(alpha, t), H, rcond=None)[0]
531535

532-
# Apply proximal operator if given.
533-
if self._mode_prox is not None:
536+
# Apply proximal operator if given, and if data isn't projected.
537+
if self._mode_prox is not None and not self._use_proj:
534538
B = self._mode_prox(B)
535539

536540
return B
@@ -727,6 +731,9 @@ def _single_trial_compute_operator(self, H, t, init_alpha):
727731
Atilde = np.linalg.multi_dot([w, np.diag(e), np.linalg.pinv(w)])
728732
# Unproject the dmd modes.
729733
w = self._proj_basis.dot(w)
734+
# Apply mode proximal operator if given.
735+
if self._mode_prox is not None:
736+
w = self._mode_prox(w)
730737
else:
731738
w_proj = self._proj_basis.conj().T.dot(w)
732739
Atilde = np.linalg.multi_dot(
@@ -949,7 +956,11 @@ class BOPDMD(DMDBase):
949956
of the variable projection routine.
950957
:type eig_constraints: set(str) or function
951958
:param mode_prox: Optional proximal operator function to apply to the DMD
952-
modes at every iteration of variable projection routine.
959+
modes. If `use_proj` is False, this function is applied at every
960+
iteration of the variable projection routine. If `use_proj` is True,
961+
this function is instead applied at the end of the variable projection
962+
routine after the modes have been projected back to the space of the
963+
full input data.
953964
:type mode_prox: function
954965
:param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
955966
at which to terminate the fit. Set this parameter to infinity for no

0 commit comments

Comments
 (0)