Commit bbdbd78d authored by jansen31's avatar jansen31
Browse files

plot complex orbitals as color for phase and intensity for amplitude

parent 4ca48457
......@@ -30,47 +30,50 @@
from matplotlib.pyplot import subplots, show
import numpy as np
from .complex_field_visualization import complex_to_rgb
def Phase_graphics(config, output):
#algortihm=config['algorithm']
#beta0 = config['beta_0']
#beta_max = config['beta_max']
#u_0 = config['u_0']
# algortihm=config['algorithm']
# beta0 = config['beta_0']
# beta_max = config['beta_max']
# u_0 = config['u_0']
if output['u1'].ndim == 2:
u = output['u1']
u2 = output['u2']
else:
u = output['u1'][:,:,0]
u2 = output['u2'][:,:,0]
#iter = output['iter']
u = output['u1'][:, :, 0]
u2 = output['u2'][:, :, 0]
# iter = output['iter']
change = output['change']
# if 'time' in output:
# time = output['time']
# else:
# time=999
# if 'time' in output:
# time = output['time']
# else:
# time=999
f, ((ax1, ax2), (ax3, ax4)) = subplots(2, 2)
f, ((ax1, ax2), (ax3, ax4)) = subplots(2, 2, figsize=(12,8))
im=ax1.imshow(np.abs(u),cmap='gray')
im = ax1.imshow(np.abs(u), cmap='gray')
f.colorbar(im, ax=ax1)
ax1.set_title('best approximation amplitude - physical constraint satisfied')
im=ax2.imshow(np.real(u),cmap='gray')
f.colorbar(im, ax=ax2)
im = ax2.imshow(complex_to_rgb(u))
# im = ax2.imshow(np.real(u), cmap='gray')
# f.colorbar(im, ax=ax2)
ax2.set_title('best approximation phase - physical constraint satisfied')
im=ax3.imshow(np.abs(u2),cmap='gray')
im = ax3.imshow(np.abs(u2), cmap='gray')
f.colorbar(im, ax=ax3)
ax3.set_title('best approximation amplitude - Fourier constraint satisfied')
im=ax4.imshow(np.real(u2),cmap='gray')
f.colorbar(im, ax=ax4)
im = ax4.imshow(complex_to_rgb(u2))
# im = ax4.imshow(np.real(u2), cmap='gray')
# f.colorbar(im, ax=ax4)
ax4.set_title('best approximation amplitude - Fourier constraint satisfied')
g, ((bx1, bx2), (bx3, bx4)) = subplots(2, 2)
im=bx1.imshow(np.abs(u),cmap='gray')
g, ((bx1, bx2), (bx3, bx4)) = subplots(2, 2, figsize=(12,8))
im = bx1.imshow(np.abs(u), cmap='gray')
f.colorbar(im, ax=bx1)
bx1.set_title('best approximation amplitude - physical constraint satisfied')
im = bx2.imshow(np.real(u), cmap='gray')
......
import numpy as np
from matplotlib.colors import hsv_to_rgb
def complex_to_hsv(arr, background='dark'):
"""
2d complex field to colorfull field
Args:
arr: numpy array with complex dtype
background: 'dark' or 'light'
Returns:
"""
objecthsv = np.zeros((3,) + arr.shape)
objecthsv[0] = np.angle(-arr) / 2 / np.pi + 0.5
if background == 'dark':
objecthsv[1] = np.ones(arr.shape)
objecthsv[2] = abs(arr) / np.max(abs(arr))
else:
objecthsv[2] = np.ones(arr.shape)
objecthsv[1] = abs(arr) / np.max(abs(arr))
return np.transpose(objecthsv, (1, 2, 0))
def complex_to_rgb(arr, background='dark'):
return hsv_to_rgb(complex_to_hsv(arr, background=background))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment