@@ -1469,16 +1469,16 @@ def fit(self, X, t):
14691469
14701470 return self
14711471
1472- def fit_econ (self , U , s , V , t ):
1472+ def fit_econ (self , s , V , t ):
14731473 """
14741474 Compute the Optimized Dynamic Mode Decomposition using the
14751475 SVD results of the snapshot matrix.
14761476 Use this method if you have pre-computed the SVD and the
14771477 original snapshot matrix is not avaialble or too large to
14781478 store in memory.
1479+ The left singular vectors (U) must be specified as the projection
1480+ basis when initializing the BOPDMD object.
14791481
1480- :param U: the left singular vectors.
1481- :type U: numpy.ndarray
14821482 :param s: the singular values.
14831483 :type s: numpy.ndarray
14841484 :param V: the right singular vectors.
@@ -1489,32 +1489,34 @@ def fit_econ(self, U, s, V, t):
14891489 self ._reset ()
14901490 self ._time = np .array (t ).squeeze ()
14911491
1492+ if self ._proj_basis is None :
1493+ msg = "proj_basis must be provided when using fit_econ."
1494+ raise ValueError (msg )
1495+
14921496 # Check that input time vector is one-dimensional.
14931497 if self ._time .ndim > 1 :
14941498 msg = "Input time vector t must be one-dimensional."
14951499 raise ValueError (msg )
14961500
1497- # Check that U is a 2D numpy.ndarray.
1498- if not isinstance (U , np .ndarray ) or U .ndim != 2 :
1499- msg = "U must be a 2D numpy.ndarray."
1500- raise ValueError (msg )
1501-
15021501 # Check that s is a 1D numpy.ndarray.
1503- if not isinstance (s , np .ndarray ) or s .ndim != 1 or len (s ) != U .shape [1 ]:
1504- msg = "s must be a 1D numpy.ndarray with length equal to the number of columns in U."
1502+ if not isinstance (s , np .ndarray ) or s .ndim != 1 or len (s ) != self ._proj_basis .shape [1 ]:
1503+ msg = """
1504+ s must be a 1D numpy.ndarray with length equal to the number
1505+ of columns in the projection basis (U).
1506+ """
15051507 raise ValueError (msg )
15061508
15071509 # Check that V is a 2D numpy.ndarray.
15081510 if (
15091511 not isinstance (V , np .ndarray )
15101512 or V .ndim != 2
1511- or V .shape [0 ] != U .shape [1 ]
1513+ or V .shape [0 ] != self . _proj_basis .shape [1 ]
15121514 or V .shape [1 ] != len (self ._time )
15131515 ):
15141516 msg = """
15151517 V must be a 2D numpy.ndarray with the same number of rows
1516- as U has columns and the same number of columns as the length
1517- of the time vector t.
1518+ as the projection basis (U) has columns and the same number of columns
1519+ as the length of the time vector t.
15181520 """
15191521 raise ValueError (msg )
15201522
0 commit comments