Code Monkey home page Code Monkey logo

Comments (2)

ndem0 avatar ndem0 commented on May 21, 2024

Dear @rfmiotto, thank you for the effort! We'll check the Merge Request as soon as possible.

Regarding your dubts:

  • the dictionaries initialization is performed for all the DMD classes, only to initialize the attributes (nothing related with the MrDMD prediction).
  • if I remember correctly, the try:...except lines have been added in order to avoid errors that occur when the step variable is too large to fit in a single window. Better (and cleaner) solutions are very welcome!

from pydmd.

rfmiotto avatar rfmiotto commented on May 21, 2024

Dear @ndem0,

Thank you for clarifying.

But can I say that the mrDMD cannot handle predictions? (the dmd_time is a copy of original_time)


The solution that I propose in this PR is to limit the maximum level such that the bins at the topmost level are composed of at least 4 snapshots.

# Redefine max level if it is too big.
lvl_threshold = int(np.log(self._snapshots.shape[1]/4.)/np.log(2.))
if self.max_level > lvl_threshold:
    self.max_level = lvl_threshold
    print('Too many levels. Redefining `max_level` to {}'.format(self.max_level))

Also, I ensured that the minimum admissible step was 1, since slice step cannot be zero:
step = max(1, int(np.floor(old_div(n_samples, nyq))))

The reason for doing that is because (and please, correct me if I am wrong):

In the original code (I mean before this proposed commit), as we go to higher resolution levels the n_samples decreases up to a point when the n_samples/nyq becomes < 1. At this point, the step variable becomes zero, causing a ValueError to be raised in Xsub = Xraw[:, ::step]. So the code goes to the exception block and sets the DMD variables (modes, eigenvalues, etc) of that bin as zero.

This approach solves for the zero slice step in Xsub = Xraw[:, ::step], but when one tries to reconstruct the dynamics, these zero-valued bins are included in the computation and cause a division by zero error.

To my understanding, the try:..except blocks were added to solve this step problem. However, I didn't understand what exactly did you mean by the try:...except to be related to the step being large to fit a window. For example, the code below gives no errors:

a = np.arange(10)

print( a[::7] )  # Out: array([0, 7])
print( a[::25] ) # Out: array([0])

Please, let me know if you agree with that or if my conclusions are wrong.

Thank you and best regards,
Renato Miotto

from pydmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.