champsproject / ldds

Python package for computing and visualizing Lagrangian Descriptors in Dynamical Systems
BSD 3-Clause "New" or "Revised" License
17 stars 2 forks source link

Sliders for interactive manipulation of LD-gradient filtering thresholds. #25

Closed vkrajnak closed 3 years ago

vkrajnak commented 3 years ago

Added sliders. They work quite well, but there are a couple limitations:

And I've made LD normalisation compulsory, as discussed last week

vkrajnak commented 3 years ago

Tell me how it works on your side. It may be too limiting to merge into the develop branch.

broncio123 commented 3 years ago

Hi @vkrajnak I just saw your pull-request. I will review it before Thursday.

Thanks. b

broncio123 commented 3 years ago

Added sliders. They work quite well, but there are a couple limitations:

  • requires ipympl,
  • works only in interactive mode %matplotlib widget,
  • my computer struggles to execute the whole notebook at once when the mode is enabled,
  • complains once more than 20 figures are open. For now it is optional only.

And I've made LD normalisation compulsory, as discussed last week

Hi @vkrajnak It's working for me! I can see the sliders and manipulate them. image

What version of ipympl did you install? I installed ipympl-0.3.3 Add it to the requirements.txt file in the future, please.

Well done! Now, we need to fix the colours, remember #20 ?

Mad love, b

vkrajnak commented 3 years ago

Glad it works. ipympl 0.3.3 is the one I'm using.

How does your computer behave when you run the whole notebook with %matplotlib widget? Mine seems overloaded.

vkrajnak commented 3 years ago

ipympl will only be added to the requirements if we decide to add the sliders to develop. Right now I have doubts whether it is a good idea.

broncio123 commented 3 years ago

Glad it works. ipympl 0.3.3 is the one I'm using.

How does your computer behave when you run the whole notebook with %matplotlib widget? Mine seems overloaded.

I ran the NB in two different machines.

I also tried 300x300 grid and unsurprisingly it slowed down, taking roughly 6-12 secs for consecutive changes.

No idea how it would behave if I had other animations running in the background.

I wonder if ipympl performance can be enhanced using parallel CPUs or threads, if possible. Perhaps a little research is needed

Also, I noticed that optimal visibility of manifold-slices happens for a short interval of gradient values. Maybe also worth considering further filtering from the distribution of LD values.

@VikJGG , can you try to run the NB in your machine too? Using GitKraken just click on the branch named slider, and it will instantly allow you to run the NB. Install ipympl before running the NB at all. If you see any changes after running, with GitKraken just discard all changes (top right-hand side bin-button), to keep the original version.

vkrajnak commented 3 years ago

Thanks for testing. It runs smoothly on my machine, but with %matplotlib widget some figures crash over time. I'm not sure this is acceptable.

Parallellisation would only help if you could parallelise contourf. As you found, a denser grid slows the calculation down. The slider widget itself should not be demanding, it only runs a given function with a given parameter when changed.

Filtering the LD values deserves attention indeed, but in a system- and LD definition-independent way, i.e. as an image.

Let's see how the NB runs for VikJGG and then decide what to do with it. Merging doesn't seem like a good idea.

vkrajnak commented 3 years ago

Apparently matplotlib threads processes already, but it can be implemented using multiprocessing to boost speed. Have a look at this example - I haven't tested myself but seems worth trying out with plt.contourf instead of plt.plot https://stackoverflow.com/questions/4659680/matplotlib-simultaneous-plotting-in-multiple-threads

Interesting example, but how would you use batch processing for our purpose in the notebook?

vkrajnak commented 3 years ago

I've changed the function inside the slider, so that it doesn't recalculate the plot every single time. Should be faster now.

VikJGG commented 3 years ago

I have tried the slider feature for the forced Duffing oscillator system in my desktop computer, which is a DELL with an Intel core i7-8700 processor and 16 GB of RAM and it works smoothly :) I have tried different grid sizes, the largest is 1000x1000, and every time it has worked fine. The computation of LDs with the denser grid of 1000x1000 took around 2 minutes and 42 seconds to execute.