Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zero division error: tutorial 3 #81

Closed
fnauman opened this issue Mar 4, 2019 · 1 comment
Closed

zero division error: tutorial 3 #81

fnauman opened this issue Mar 4, 2019 · 1 comment

Comments

@fnauman
Copy link

fnauman commented Mar 4, 2019

I was going through the tutorials trying different values for various parameters. I found an error. In tutorial 3 (cell 6):

dmd = MrDMD(svd_rank=6, max_level=7, max_cycles=1)

Instead of using svd_rank=-1, I used 6. I get a ZeroDivisionError.

I get a ZeroDivisionError for a dataset I am using as well. I was wondering if there are some guidelines on which parameters to use to avoid such errors, or is it the case that there is a bug in the code.

Thanks for making your package available.


ZeroDivisionError Traceback (most recent call last)
in
1 dmd = MrDMD(svd_rank=6, max_level=7, max_cycles=1)
2 dmd.fit(X=sample_data)
----> 3 make_plot(dmd.reconstructed_data.T, x=x, y=t)

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/pydmd/mrdmd.py in reconstructed_data(self)
79 np.array([
80 self.partial_reconstructed_data(i)
---> 81 for i in range(self.max_level)
82 ]),
83 axis=0)

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/pydmd/mrdmd.py in (.0)
79 np.array([
80 self.partial_reconstructed_data(i)
---> 81 for i in range(self.max_level)
82 ]),
83 axis=0)

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/pydmd/mrdmd.py in partial_reconstructed_data(self, level, node)
208 level, self.max_level))
209 modes = self.partial_modes(level, node)
--> 210 dynamics = self.partial_dynamics(level, node)
211
212 return modes.dot(dynamics)

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/pydmd/mrdmd.py in partial_dynamics(self, level, node)
162 level_dynamics = [
163 dynamic(self._eigs[idx], self._b[idx], self._steps[idx],
--> 164 self._nsamples[idx]) for idx in indeces
165 ]
166 return scipy.linalg.block_diag(*level_dynamics)

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/pydmd/mrdmd.py in (.0)
162 level_dynamics = [
163 dynamic(self._eigs[idx], self._b[idx], self._steps[idx],
--> 164 self._nsamples[idx]) for idx in indeces
165 ]
166 return scipy.linalg.block_diag(*level_dynamics)

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/pydmd/mrdmd.py in dynamic(eigs, amplitudes, step, nsamples)
149 def dynamic(eigs, amplitudes, step, nsamples):
150 omega = old_div(
--> 151 np.log(np.power(eigs, old_div(1., step))),
152 self.original_time['dt'])
153 partial_timestep = np.arange(nsamples) * self.dmd_time['dt']

~/anaconda3/envs/pydmd/lib/python3.7/site-packages/past/utils/init.py in old_div(a, b)
93 return a // b
94 else:
---> 95 return a / b
96
97 all = ['PY3', 'PY2', 'PYPY', 'with_metaclass', 'native', 'old_div']

ZeroDivisionError: float division by zero

@ndem0
Copy link
Member

ndem0 commented Mar 4, 2019

@fnauman Thank you for reporting this problem. It looks the sampling step becomes zero changing the truncation in SVD. I'll investigate better, anyway we will implement some useful warnings for this kind of errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants