|
5 | 5 | from math import fabs, log10
|
6 | 6 | from scipy.interpolate import griddata
|
7 | 7 |
|
8 |
| -x1 = np.array([{x1}]) |
9 |
| -x2 = np.array([{x2}]) |
10 |
| -z = np.array([{z}]) |
| 8 | +x1 = np.array([{x1}]) # noqa: F821 |
| 9 | +x2 = np.array([{x2}]) # noqa: F821 |
| 10 | +z = np.array([{z}]) # noqa: F821 |
11 | 11 | x = 0.5 * np.log(x1 / x2)
|
12 | 12 | y = np.sqrt(x1 * x2)
|
13 | 13 |
|
14 | 14 | nrap = 50
|
15 | 15 | nmass = 50
|
16 | 16 |
|
17 | 17 | sym_min = -max(fabs(np.min(x)), fabs(np.max(x)))
|
18 |
| -sym_max = max(fabs(np.min(x)), fabs(np.max(x))) |
| 18 | +sym_max = max(fabs(np.min(x)), fabs(np.max(x))) |
19 | 19 |
|
20 | 20 | xi = np.linspace(sym_min, sym_max, (nrap // 2) * 2 + 1)
|
21 | 21 | yi = np.logspace(log10(np.min(y)), log10(np.max(y)), nmass)
|
22 |
| -zi = griddata((x, y), z, (xi[None, :], yi[:, None]), method='linear', rescale=True) |
| 22 | +zi = griddata((x, y), z, (xi[None, :], yi[:, None]), method="linear", rescale=True) |
23 | 23 |
|
24 |
| -#print(xi.shape) |
25 |
| -#print(yi.shape) |
26 |
| -#print(zi.shape) |
| 24 | +# print(xi.shape) |
| 25 | +# print(yi.shape) |
| 26 | +# print(zi.shape) |
27 | 27 |
|
28 | 28 | # mask impossible kinematic values
|
29 | 29 | for iy, ix in np.ndindex(zi.shape):
|
30 |
| - #print(ix, iy) |
| 30 | + # print(ix, iy) |
31 | 31 | x1v = yi[iy] * np.exp(xi[ix])
|
32 | 32 | x2v = yi[iy] / np.exp(xi[ix])
|
33 | 33 |
|
34 |
| - #print('y = {{}} m/s = {{}} -> x1 = {{}} x2 = {{}}'.format(xi[ix], yi[iy], x1v, x2v)) |
| 34 | + # print('y = {{}} m/s = {{}} -> x1 = {{}} x2 = {{}}'.format(xi[ix], yi[iy], x1v, x2v)) |
35 | 35 |
|
36 | 36 | if x1v > 1.0 or x2v > 1.0:
|
37 | 37 | zi[iy, ix] = np.nan
|
38 | 38 |
|
39 | 39 | figure, axes = plt.subplots(1, 2, constrained_layout=True)
|
40 | 40 | figure.set_size_inches(10, 5)
|
41 | 41 |
|
42 |
| -mesh = axes[0].pcolormesh(xi, yi, zi, shading='nearest', linewidth=0, snap=True) |
43 |
| -axes[0].scatter(x, y, marker='*', s=5) |
44 |
| -axes[0].set_yscale('log') |
45 |
| -axes[0].set_xlabel(r'$y = 1/2 \log (x_1/x_2)$') |
46 |
| -axes[0].set_ylabel(r'$M/\sqrt{{s}} = \sqrt{{x_1 x_2}}$') |
47 |
| -#axes[0].set_aspect('equal', share=True) |
| 42 | +mesh = axes[0].pcolormesh(xi, yi, zi, shading="nearest", linewidth=0, snap=True) |
| 43 | +axes[0].scatter(x, y, marker="*", s=5) |
| 44 | +axes[0].set_yscale("log") |
| 45 | +axes[0].set_xlabel(r"$y = 1/2 \log (x_1/x_2)$") |
| 46 | +axes[0].set_ylabel(r"$M/\sqrt{{s}} = \sqrt{{x_1 x_2}}$") |
| 47 | +# axes[0].set_aspect('equal', share=True) |
48 | 48 |
|
49 | 49 | x1i = np.logspace(log10(np.min(x1)), log10(np.max(x1)), 50)
|
50 | 50 | x2i = np.logspace(log10(np.min(x2)), log10(np.max(x2)), 50)
|
51 |
| -z12i = griddata((x1, x2), z, (x1i[None, :], x2i[:, None]), method='linear', rescale=True) |
52 |
| - |
53 |
| -mesh = axes[1].pcolormesh(x1i, x2i, z12i, shading='nearest', linewidth=0, snap=True) |
54 |
| -axes[1].set_xscale('log') |
55 |
| -axes[1].set_yscale('log') |
56 |
| -axes[1].scatter(x1, x2, marker='*', s=5) |
57 |
| -axes[1].set_aspect('equal', share=True) |
58 |
| -axes[1].set_xlabel(r'$x_1$') |
59 |
| -axes[1].set_ylabel(r'$x_2$') |
60 |
| - |
61 |
| -figure.colorbar(mesh, ax=axes, extend='min') |
62 |
| -figure.savefig('plot.pdf') |
| 51 | +z12i = griddata( |
| 52 | + (x1, x2), z, (x1i[None, :], x2i[:, None]), method="linear", rescale=True |
| 53 | +) |
| 54 | + |
| 55 | +mesh = axes[1].pcolormesh(x1i, x2i, z12i, shading="nearest", linewidth=0, snap=True) |
| 56 | +axes[1].set_xscale("log") |
| 57 | +axes[1].set_yscale("log") |
| 58 | +axes[1].scatter(x1, x2, marker="*", s=5) |
| 59 | +axes[1].set_aspect("equal", share=True) |
| 60 | +axes[1].set_xlabel(r"$x_1$") |
| 61 | +axes[1].set_ylabel(r"$x_2$") |
| 62 | + |
| 63 | +figure.colorbar(mesh, ax=axes, extend="min") |
| 64 | +figure.savefig("plot.pdf") |
0 commit comments