1
0
Fork 0
mirror of https://github.com/Findus23/collision-analyisis-and-interpolation.git synced 2024-09-19 15:13:50 +02:00
collision-analyisis-and-int.../visualize.py

37 lines
1.2 KiB
Python
Raw Normal View History

2019-02-13 15:27:48 +01:00
import numpy as np
from matplotlib import pyplot as plt
from scipy.interpolate import griddata
from simulation_list import SimulationList
2019-04-18 11:54:15 +02:00
mcode, gamma, wt, wp = [22.0, 1, 10.0, 10.0]
2019-02-13 15:27:48 +01:00
simlist = SimulationList.jsonlines_load()
simulations = simlist.simlist
2019-04-18 11:54:15 +02:00
data = np.array([[s.alphacode, s.vcode, s.mcode, s.gammacode, s.wtcode, s.wpcode] for s in simulations])
values = np.array([s.water_retention_both for s in simulations])
2019-02-13 15:27:48 +01:00
factor = 1
2019-04-18 11:54:15 +02:00
alpharange = np.linspace(-0.5, 60.5, 100)
vrange = np.linspace(0.5, 5.5, 100)
grid_alpha, grid_v = np.meshgrid(alpharange, vrange)
2019-02-13 15:27:48 +01:00
N = factor * np.arange(0., 1.01, 0.01)
2019-04-18 11:54:15 +02:00
# print(grid_alpha)
grid_result = griddata(data, values, (grid_alpha, grid_v, mcode, gamma, wt, wp), method="nearest")
print(grid_alpha.shape)
print(grid_result.shape)
2019-02-13 15:27:48 +01:00
plt.title("m={:3.0f}, gamma={:3.1f}, wt={:2.0f}, wp={:2.0f}\n".format(mcode, gamma, wt, wp))
# plt.contourf(grid_x, grid_y, grid_c, N, cmap="Blues", vmin=0, vmax=1)
2019-04-18 11:54:15 +02:00
plt.pcolormesh(grid_alpha, grid_v, grid_result, cmap="Blues", vmin=0, vmax=1)
2019-04-18 10:50:57 +02:00
plt.colorbar().set_label("water retention")
# plt.scatter(data[:, 0], data[:, 1], c=values, cmap="Blues")
plt.xlabel("impact angle $\\alpha$")
plt.ylabel("velocity $v$")
plt.tight_layout()
2019-04-18 11:54:15 +02:00
# plt.savefig("vis.png", transparent=True)
2019-02-13 15:27:48 +01:00
plt.show()