nicer plots
This commit is contained in:
parent
41b63b3634
commit
06b4603220
2 changed files with 28 additions and 16 deletions
|
@ -69,10 +69,10 @@ else:
|
|||
xrange = np.linspace(-0.5, 60.5, 100)
|
||||
yrange = np.linspace(0.5, 5.5, 100)
|
||||
xgrid, ygrid = np.meshgrid(xrange, yrange)
|
||||
mcode = 1e23
|
||||
mcode = 1e24
|
||||
wpcode = 15 / 100
|
||||
wtcode = 15 / 100
|
||||
gammacode = 0.7
|
||||
gammacode = 0.6
|
||||
testinput = np.array([[np.nan, np.nan, mcode, gammacode, wtcode, wpcode]] * 100 * 100)
|
||||
testinput[::, 0] = xgrid.flatten()
|
||||
testinput[::, 1] = ygrid.flatten()
|
||||
|
@ -82,8 +82,15 @@ print(testinput)
|
|||
print(testinput.shape)
|
||||
testoutput = model.predict(testinput)
|
||||
outgrid = np.reshape(testoutput, (100, 100))
|
||||
print("minmax")
|
||||
print(np.nanmin(outgrid), np.nanmax(outgrid))
|
||||
|
||||
plt.pcolormesh(xgrid, ygrid, outgrid, cmap="Blues", vmin=0, vmax=1)
|
||||
plt.colorbar()
|
||||
plt.savefig("keras.png", transparent=True)
|
||||
plt.imshow(outgrid, interpolation='none', cmap="Blues", aspect="auto", origin="lower", vmin=0, vmax=1,
|
||||
extent=[xgrid.min(), xgrid.max(), ygrid.min(), ygrid.max()])
|
||||
|
||||
plt.colorbar().set_label("water retention fraction")
|
||||
plt.xlabel("impact angle $\\alpha$ [$^{\circ}$]")
|
||||
plt.ylabel("velocity $v$ [$v_{esc}$]")
|
||||
plt.tight_layout()
|
||||
plt.savefig("../arbeit/images/plots/nn2.pdf")
|
||||
plt.show()
|
||||
|
|
27
visualize.py
27
visualize.py
|
@ -1,14 +1,13 @@
|
|||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
from matplotlib import pyplot as plt, cm
|
||||
|
||||
from CustomScaler import CustomScaler
|
||||
from interpolators.griddata import GriddataInterpolator
|
||||
from interpolators.rbf import RbfInterpolator
|
||||
from simulation_list import SimulationList
|
||||
|
||||
|
||||
def main():
|
||||
mcode, gamma, wt, wp = [10 ** 23, 0.6, 15 / 100, 15 / 100]
|
||||
mcode, gamma, wt, wp = [10 ** 22, 0.6, 15 / 100, 15 / 100]
|
||||
simlist = SimulationList.jsonlines_load()
|
||||
# for s in simlist.simlist:
|
||||
# if s.type!="original":
|
||||
|
@ -25,8 +24,8 @@ def main():
|
|||
scaler = CustomScaler()
|
||||
scaler.fit(data)
|
||||
scaled_data = scaler.transform_data(data)
|
||||
interpolator = RbfInterpolator(scaled_data, values)
|
||||
# interpolator = GriddataInterpolator(scaled_data, values)
|
||||
# interpolator = RbfInterpolator(scaled_data, values)
|
||||
interpolator = GriddataInterpolator(scaled_data, values)
|
||||
|
||||
alpharange = np.linspace(-0.5, 60.5, 300)
|
||||
vrange = np.linspace(0.5, 5.5, 300)
|
||||
|
@ -36,17 +35,23 @@ def main():
|
|||
scaled_parameters = list(scaler.transform_parameters(parameters))
|
||||
|
||||
grid_result = interpolator.interpolate(*scaled_parameters)
|
||||
print("minmax")
|
||||
print(np.nanmin(grid_result), np.nanmax(grid_result))
|
||||
|
||||
plt.title("m={:3.0e}, gamma={:3.1f}, wt={:2.0f}%, wp={:2.0f}%\n".format(mcode, gamma, wt*100, wp*100))
|
||||
|
||||
# plt.title("m={:3.0e}, gamma={:3.1f}, wt={:2.0f}%, wp={:2.0f}%\n".format(mcode, gamma, wt*100, wp*100))
|
||||
cmap = cm.Blues
|
||||
cmap.set_bad('white', 1.) # show nan white
|
||||
# plt.contourf(grid_alpha, grid_v, grid_result, 100, cmap="Blues", vmin=0, vmax=1)
|
||||
plt.pcolormesh(grid_alpha, grid_v, grid_result, cmap="Blues", vmin=0, vmax=1)
|
||||
plt.colorbar().set_label("water retention")
|
||||
# plt.pcolormesh(grid_alpha, grid_v, grid_result, cmap="Blues", vmin=0, vmax=1)
|
||||
plt.imshow(grid_result, interpolation='none', cmap=cmap, aspect="auto", origin="lower", vmin=0, vmax=1,
|
||||
extent=[grid_alpha.min(), grid_alpha.max(), grid_v.min(), grid_v.max()])
|
||||
plt.colorbar().set_label("water retention fraction")
|
||||
# plt.scatter(data[:, 0], data[:, 1], c=values, cmap="Blues")
|
||||
plt.xlabel("impact angle $\\alpha$")
|
||||
plt.ylabel("velocity $v$")
|
||||
plt.xlabel("impact angle $\\alpha$ [$^{\circ}$]")
|
||||
plt.ylabel("velocity $v$ [$v_{esc}$]")
|
||||
plt.tight_layout()
|
||||
# plt.savefig("vis.png", transparent=True)
|
||||
plt.savefig("../arbeit/images/plots/griddata1.pdf")
|
||||
plt.show()
|
||||
|
||||
|
||||
|
|
Reference in a new issue