Bug flix and correct import from xml
This commit is contained in:
Binary file not shown.
@@ -5,24 +5,67 @@ from scipy.ndimage import gaussian_filter
|
||||
from matplotlib import ticker, cm
|
||||
import h5py as h5py
|
||||
|
||||
import import_dings as impding
|
||||
from . import import_dings as impding
|
||||
|
||||
def createZeroFieldH5(filename_output):
|
||||
zero = np.zeros((1,1))
|
||||
saveToKarlH5File(filename_output, zero, zero)
|
||||
|
||||
def createFieldH5(filename_derived, filename_output, dx, timestep, cylinder_origin, radius, height, z_start, z_end):
|
||||
L_wgts = 1300
|
||||
num_cells = int((L_wgts - height*dx)/dx)
|
||||
|
||||
|
||||
timestep = 761600
|
||||
filename_derived = "/home/jonas/new_workspace/Coding/Output/LRZ/HugeClassChanges/triangleDensityLonger/reflecting/derived.h5"
|
||||
filename_output = "/home/jonas/new_workspace/Coding/Output/LRZ/HugeClassChanges/triangleDensityLonger/reflecting/karl_input.h5"
|
||||
data_Er = impding.getNumpyArray(filename_derived, timestep, "E_r")
|
||||
data_Er_2d = radialAverage(data_Er[:,:,:-10], cylinder_origin, radius, height)
|
||||
|
||||
dx = 0.13801796042392211
|
||||
L_wgts = 1300
|
||||
data_Er_2d_ext = copyValues(data_Er_2d, z_start, z_end, num_cells)
|
||||
|
||||
cylinder_origin = [35,35,11]
|
||||
radius = 32
|
||||
height = 1434
|
||||
data_Ez = impding.getNumpyArray(filename_derived, timestep, "E_z")
|
||||
data_Ez_2d = radialAverage(data_Ez[:,:,:-10], cylinder_origin, radius, height)
|
||||
|
||||
z_start = 350
|
||||
z_end = 1050
|
||||
data_Ez_2d_ext = copyValues(data_Ez_2d, z_start, z_end, num_cells)
|
||||
|
||||
num_cells = int((L_wgts - height*dx)/dx)
|
||||
saveToKarlH5File(filename_output, data_Er_2d_ext, data_Ez_2d_ext)
|
||||
|
||||
def plotFields(filename_derived, dx, timestep, cylinder_origin, radius, height, z_start, z_end):
|
||||
L_wgts = 1300
|
||||
num_cells = int((L_wgts - height*dx)/dx)
|
||||
|
||||
data_Er = impding.getNumpyArray(filename_derived, timestep, "E_r")
|
||||
data_Er_2d = radialAverage(data_Er[:,:,:-10], cylinder_origin, radius, height)
|
||||
|
||||
data_Er_2d_ext = copyValues(data_Er_2d, z_start, z_end, num_cells)
|
||||
|
||||
data_Ez = impding.getNumpyArray(filename_derived, timestep, "E_z")
|
||||
data_Ez_2d = radialAverage(data_Ez[:,:,:-10], cylinder_origin, radius, height)
|
||||
|
||||
data_Ez_2d_ext = copyValues(data_Ez_2d, z_start, z_end, num_cells)
|
||||
|
||||
fig, (ax0,ax1) = plt.subplots(2,1)
|
||||
pos = ax0.contourf(data_Er_2d_ext, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax0.contourf(data_Er_2d_ext*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
pos = ax1.contourf(data_Er_2d, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax1.contourf(data_Er_2d*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
|
||||
cbar_pos = fig.colorbar(pos)
|
||||
cbar_neg = fig.colorbar(neg)
|
||||
plt.show()
|
||||
|
||||
|
||||
fig, (ax0,ax1) = plt.subplots(2,1)
|
||||
pos = ax0.contourf(data_Ez_2d_ext, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax0.contourf(data_Ez_2d_ext*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
pos = ax1.contourf(data_Ez_2d, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax1.contourf(data_Ez_2d*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
|
||||
cbar_pos = fig.colorbar(pos)
|
||||
cbar_neg = fig.colorbar(neg)
|
||||
plt.show()
|
||||
|
||||
|
||||
def radialAverage(electricField, cylinder_origin, radius, height):
|
||||
@@ -49,7 +92,7 @@ def radialAverage(electricField, cylinder_origin, radius, height):
|
||||
|
||||
return data_mean
|
||||
|
||||
|
||||
# not used right now
|
||||
def extendValues(data_2d, z_start, z_end, num_cells):
|
||||
(size_x, size_y) = np.shape(data_2d)
|
||||
data_ext = np.zeros((size_x, size_y+num_cells))
|
||||
@@ -89,41 +132,7 @@ def copyValues(data_2d, z_start, z_end, num_cells):
|
||||
|
||||
return data_copy
|
||||
|
||||
data_Er = impding.getNumpyArray(filename_derived, timestep, "E_r")
|
||||
data_Er_2d = radialAverage(data_Er[:,:,:-10], cylinder_origin, radius, height)
|
||||
|
||||
data_Er_2d_ext = copyValues(data_Er_2d, z_start, z_end, num_cells)
|
||||
|
||||
data_Ez = impding.getNumpyArray(filename_derived, timestep, "E_z")
|
||||
data_Ez_2d = radialAverage(data_Ez[:,:,:-10], cylinder_origin, radius, height)
|
||||
|
||||
data_Ez_2d_ext = copyValues(data_Ez_2d, z_start, z_end, num_cells)
|
||||
|
||||
|
||||
fig, (ax0,ax1) = plt.subplots(2,1)
|
||||
pos = ax0.contourf(data_Er_2d_ext, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax0.contourf(data_Er_2d_ext*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
pos = ax1.contourf(data_Er_2d, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax1.contourf(data_Er_2d*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
|
||||
cbar_pos = fig.colorbar(pos)
|
||||
cbar_neg = fig.colorbar(neg)
|
||||
plt.show()
|
||||
|
||||
|
||||
fig, (ax0,ax1) = plt.subplots(2,1)
|
||||
pos = ax0.contourf(data_Ez_2d_ext, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax0.contourf(data_Ez_2d_ext*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
pos = ax1.contourf(data_Ez_2d, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = ax1.contourf(data_Ez_2d*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
|
||||
cbar_pos = fig.colorbar(pos)
|
||||
cbar_neg = fig.colorbar(neg)
|
||||
plt.show()
|
||||
|
||||
def saveToKarlH5File(filename, Er, Ez):
|
||||
file = h5py.File(filename, 'w')
|
||||
@@ -131,36 +140,4 @@ def saveToKarlH5File(filename, Er, Ez):
|
||||
file.create_dataset('Ez', data=Ez)
|
||||
file.close()
|
||||
|
||||
saveToKarlH5File(filename_output, data_Er_2d_ext, data_Ez_2d_ext)
|
||||
|
||||
"""
|
||||
win = signal.windows.hann(150)
|
||||
fildered =signal.convolve(data_Er_2d[0,:], win, mode='same')/sum(win)
|
||||
plt.plot(data_Er_2d[0,:])
|
||||
plt.plot(fildered)
|
||||
plt.show()
|
||||
|
||||
plt.contourf(data_Er_2d)
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
filtered_2d = gaussian_filter(data_Er_2d,sigma=(2,10))
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
pos = plt.contourf(filtered_2d, locator=ticker.LogLocator(), cmap=cm.Reds)
|
||||
neg = plt.contourf(filtered_2d*-1, locator=ticker.LogLocator(), cmap = cm.Purples)
|
||||
|
||||
cbar_pos = fig.colorbar(pos)
|
||||
cbar_neg = fig.colorbar(neg)
|
||||
plt.show()
|
||||
|
||||
|
||||
plt.plot(filtered_2d[0,:],label="0")
|
||||
plt.plot(filtered_2d[5,:],label="5")
|
||||
plt.plot(filtered_2d[16,:],label="16")
|
||||
plt.plot(filtered_2d[20,:],label="20")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user