| 1 | import numpy as np |
| 2 | import pylab as plt |
| 3 | import skfmm |
| 4 | |
| 5 | X, Y = np.meshgrid(np.linspace(-1,1,501), np.linspace(-1,1,501)) |
| 6 | phi = (X+0.8)**2+(Y+0.8)**2 - 0.01 |
| 7 | speed = 1+X**2+Y**2 |
| 8 | |
| 9 | plt.subplot(221) |
| 10 | plt.title("Zero-contour of phi") |
| 11 | plt.contour(X, Y, phi, [0], colors='black', linewidths=(3)) |
| 12 | plt.gca().set_aspect(1) |
| 13 | plt.xticks([]); plt.yticks([]) |
| 14 | |
| 15 | plt.subplot(222) |
| 16 | plt.title("Distance") |
| 17 | plt.contour(X, Y, phi, [0], colors='black', linewidths=(3)) |
| 18 | plt.contour(X, Y, skfmm.distance(phi, dx=2.0/500), 15) |
| 19 | plt.gca().set_aspect(1) |
| 20 | plt.xticks([]); plt.yticks([]) |
| 21 | |
| 22 | plt.subplot(223) |
| 23 | plt.title("Distance with x- \nand y- directions periodic") |
| 24 | plt.contour(X, Y, phi, [0], colors='black', linewidths=(3)) |
| 25 | plt.contour(X, Y, skfmm.distance(phi, dx=2.0/500, periodic=True), 15) |
| 26 | plt.gca().set_aspect(1) |
| 27 | plt.xticks([]); plt.yticks([]) |
| 28 | |
| 29 | plt.subplot(224) |
| 30 | plt.title("Travel time with y- \ndirection periodic ") |
| 31 | plt.contour(X, Y, phi, [0], colors='black', linewidths=(3)) |
| 32 | plt.contour(X, Y, skfmm.travel_time(phi, speed, dx=2.0/500, periodic=(1,0)), 15) |
| 33 | plt.gca().set_aspect(1) |
| 34 | plt.xticks([]); plt.yticks([]) |
| 35 | |
| 36 | plt.show() |