|
1 | 1 | import os
|
2 | 2 |
|
3 |
| -import imaspy.training |
4 | 3 | import matplotlib
|
5 | 4 | import numpy as np
|
6 | 5 | from scipy.interpolate import RegularGridInterpolator
|
7 | 6 |
|
| 7 | +import imaspy.training |
| 8 | + |
8 | 9 | if "DISPLAY" not in os.environ:
|
9 | 10 | matplotlib.use("agg")
|
10 | 11 | else:
|
|
20 | 21 | input_times = eq_in.time
|
21 | 22 |
|
22 | 23 | # Create output data entry
|
23 |
| -output_entry = imaspy.DBEntry( |
24 |
| - imaspy.ids_defs.MEMORY_BACKEND, "imaspy-course", 2, 1) |
| 24 | +output_entry = imaspy.DBEntry(imaspy.ids_defs.MEMORY_BACKEND, "imaspy-course", 2, 1) |
25 | 25 | output_entry.create()
|
26 | 26 |
|
27 | 27 | # Loop over each time slice
|
|
53 | 53 | grid_z = z_axis + rho_grid * np.sin(theta_grid)
|
54 | 54 | interpolation_points = np.dstack((grid_r.flatten(), grid_z.flatten()))
|
55 | 55 |
|
56 |
| - # Interpolate all data nodes on the new grid |
57 |
| - for data_node in ["b_field_r", "b_field_z", "b_field_tor", "psi"]: |
| 56 | + # Interpolate data nodes on the new grid |
| 57 | + for data_node in ["b_field_r", "b_field_z", "psi"]: |
58 | 58 | # `.value` so we can plot the original values after the IDS node is overwritten
|
59 | 59 | data = p2d[data_node].value
|
60 | 60 | interp = RegularGridInterpolator((r, z), data)
|
61 | 61 | new_data = interp(interpolation_points).reshape(grid_r.shape)
|
62 | 62 | p2d[data_node] = new_data
|
63 | 63 |
|
64 | 64 | # Update coordinate identifier
|
65 |
| - p2d.grid_type.index = 2 |
66 |
| - p2d.grid_type.name = "inverse" |
67 |
| - p2d.grid_type.description = "Rhopolar_polar 2D polar coordinates (rho=dim1, theta=dim2) with magnetic axis as centre of grid; theta and values following the COCOS=11 convention; the polar angle is theta=atan2(z-zaxis,r-raxis)" # noqa: E501 |
| 65 | + p2d.grid_type = "inverse" |
68 | 66 |
|
69 | 67 | # Update coordinates
|
70 | 68 | p2d.grid.dim1 = rho
|
|
83 | 81 |
|
84 | 82 | rzmesh = np.meshgrid(r, z, indexing="ij")
|
85 | 83 | mesh = ax1.pcolormesh(*rzmesh, data, vmin=vmin, vmax=vmax)
|
86 |
| -ax1.contour(*rzmesh, data, contour_levels, colors='black') |
| 84 | +ax1.contour(*rzmesh, data, contour_levels, colors="black") |
87 | 85 |
|
88 | 86 | ax2.pcolormesh(grid_r, grid_z, new_data, vmin=vmin, vmax=vmax)
|
89 |
| -ax2.contour(grid_r, grid_z, new_data, contour_levels, colors='black') |
| 87 | +ax2.contour(grid_r, grid_z, new_data, contour_levels, colors="black") |
90 | 88 |
|
91 | 89 | rho_theta_mesh = np.meshgrid(rho, theta, indexing="ij")
|
92 | 90 | ax3.pcolormesh(*rho_theta_mesh, new_data, vmin=vmin, vmax=vmax)
|
93 |
| -ax3.contour(*rho_theta_mesh, new_data, contour_levels, colors='black') |
| 91 | +ax3.contour(*rho_theta_mesh, new_data, contour_levels, colors="black") |
94 | 92 |
|
95 | 93 | ax1.set_xlabel("r [m]")
|
96 | 94 | ax2.set_xlabel("r [m]")
|
|
0 commit comments