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

Incorporate filters to enhance LD plots appearance #11

Open
broncio123 opened this issue Jun 5, 2020 · 3 comments
Open

Incorporate filters to enhance LD plots appearance #11

broncio123 opened this issue Jun 5, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@broncio123
Copy link
Member

For the future, this can be done by defining our own filters, OR
Use other filters implemented by other Python libraries for image-processing.

@broncio123 broncio123 added enhancement New feature or request help wanted Extra attention is needed labels Jun 5, 2020
@vkrajnak vkrajnak mentioned this issue Oct 2, 2020
@broncio123 broncio123 changed the title Provide an option to play around with filters to enhance plots appearance Incorporate filters to enhance LD plots appearance Oct 8, 2020
@broncio123
Copy link
Member Author

broncio123 commented Oct 8, 2020

So far, the use of gradient-based filters for extraction of manifold curves from LD maps has been explored. See Issues #17 #18 #20 #25

However, the above seems ineffective to provide neat curves as graphical outputs highlighting the distinction of stable and unstable manifolds.
Instead, the use of a Laplacian-based filter - which relies on second derivatives, seem to be more effective to this end.

@vkrajnak ... below, I provide example code-lines implementing this, alongside their graphical output.
This was found thanks to @VikJGG who kindly shared with me his implementation in MatLab.

After computing LD values

LD_forward = compute_lagrangian_descriptor(grid_parameters, vector_field, tau, p_value)
LD_backward = compute_lagrangian_descriptor(grid_parameters, vector_field, -tau, p_value)

We used pcolor instead of contourf (Need to verify if this makes a difference)

import matplotlib.pyplot as plt
from scipy.ndimage import laplace

fig, (ax1,ax2) = plt.subplots(1,2,figsize=(8,4),dpi=200,sharex=True,sharey=True)

ax1_min, ax1_max, N1 = slice_parameters[0]
ax2_min, ax2_max, N2 = slice_parameters[1]
points_ax1 = np.linspace(ax1_min, ax1_max, N1)
points_ax2 = np.linspace(ax2_min, ax2_max, N2)

X, Y = np.meshgrid(points_ax1, points_ax2)

LD = LD_forward + LD_backward
ax1.contourf(points_ax1, points_ax2,LD,cmap='bone',levels=200)

tol = 0.01
#compute laplacian
LD = LD_forward
scalar = laplace(LD)
scalar = scalar/scalar.max()
scalar = scalar**2
LDm = np.ma.masked_where(scalar < tol, scalar )
ax2.pcolor(X, Y, LDm, cmap='bwr')

# compute laplacian
LD = LD_backward
scalar = laplace(LD)
scalar = scalar/scalar.max()
scalar = scalar**2
LDm = np.ma.masked_where(scalar < tol, scalar )
ax2.pcolor(X, Y, -LDm, cmap='bwr')

#ax1.set_xlim(-4,4)
#ax1.set_ylim(-1,1)
ax1.set_xlim(-5.5, 5.5)
ax1.set_ylim(-1.25, 1.25)

fig.suptitle("$ PES(k = k_c), \Delta H_0 = "+str(dH)+" :  LD_p^{total}, p = 1/2, \\tau$ = "+str(tau), fontsize=14, y=1.04)
ax1.set_xlabel("$x$")
ax2.set_xlabel("$x$")
ax1.set_ylabel("$p_x$")

fig.tight_layout()
plt.show()

image

@broncio123
Copy link
Member Author

@vkrajnak Just remembered I posted some code where I show how to use the Laplacian to highlight the location of invariant manifolds. Maybe keep this in mind when working on the implementation of filters.

@vkrajnak
Copy link
Member

A proof of concept can be found on the max_gradient branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants