Page MenuHomec4science

plot_for_lamda_and_gamma.py
No OneTemporary

File Metadata

Created
Tue, Oct 8, 06:04

plot_for_lamda_and_gamma.py

from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
#plt.rc('text', usetex=True)
#plt.rc('font', family='serif')
fig1 = plt.figure(1)
fig2 = plt.figure(2)
ax2 = fig2.add_subplot(111, projection='3d')
#folder = '/scratch/aymanns/Data_R57C10s/2_170608_fly1_007/results/'
#gs = [0,10,20,30,40,50,60,70,80,90,100]
#ls = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
#folder = '/scratch/aymanns/Data_R57C10s/4_170609_fly1_000/results/'
gs_coarse = [0,10,20,30,40,50,60,70,80,90,100]
ls_coarse = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
gs_fine = [0,2,4,6,8,10,12,14,16,18,20]
ls_fine = [100,200,300,400,500,600,700,800,900,1000]
#folder = '/scratch/aymanns/Data_R57C10s/1_170426_fly1_013/results/'
#gs = [0,10,20,30,40,50,100]
#ls = [1000,5000,10000]
#gs = [10]
#ls = [1000,2000,3000,4000,5000,10000]
experiments = ['1_170426_fly1_013','2_170608_fly1_007','4_170609_fly1_000']
z=np.zeros((len(experiments),len(gs_coarse)+len(gs_fine),len(ls_coarse)))
for experiment,eidx in zip(experiments,range(len(experiments))):
folder = '/scratch/aymanns/Data_R57C10s/'+experiment+'/results/'
i=0
j=0
for g in gs_coarse:
for l in ls_coarse:
try:
#plt.figure(1)
#cY = np.loadtxt(folder+'l{}g{}/cY_Out1.dat'.format(l,g))
#plt.plot(cY,label='l={}, g={}'.format(l,g))
#plt.figure(2)
ng = np.loadtxt(folder+'l{}g{}/ng_Out1.dat'.format(l,g))
#ax2.scatter(g,l,ng)
#ax2.text(g,l,ng+13000, str(ng), 'y')
#ax2.plot([g,g],[l,l],[0,ng],color='gray',linestyle=':')
z[eidx,i,j]=ng
except FileNotFoundError:
print(experiment+' l={} g={} does not exist'.format(l,g))
#if g == 0:
# plt.figure(3)
# plt.scatter(l, ng)
j+=1
j=0
i+=1
i=0
j=0
for g in gs_fine:
for l in ls_fine:
try:
ng = np.loadtxt(folder+'l{}g{}/ng_Out1.dat'.format(l,g))
z[eidx,i+len(gs_coarse),j]=ng
except FileNotFoundError:
print(experiment+' l={} g={} does not exist'.format(l,g))
j+=1
j=0
i+=1
#plt.figure(1)
#plt.legend()
#plt.xlabel('frames')
#plt.ylabel('correlation with mean')
#plt.savefig('correlation.pdf')
#plt.show()
#
#plt.figure(2)
#plt.xlabel('gamma')
#plt.ylabel('lambda')
#ax2.set_zlabel('gradient of mean')
##ax2.set_zlim(bottom=0)
#plt.savefig('gradient.pdf')
#plt.show()
vmin = min(z.flatten())
vmax = max(z.flatten())
vmin = 0
vmax = 1
for eidx in range(len(experiments)):
mini = min(z[eidx,:len(gs_coarse)].flatten())
z[eidx,:len(gs_coarse)]=z[eidx,:len(gs_coarse)]-mini
scaling_factor = max(z[eidx,:len(gs_coarse)].flatten())
z[eidx,:len(gs_coarse)]=z[eidx,:len(gs_coarse)]/scaling_factor
mini = min(z[eidx,len(gs_coarse):].flatten())
z[eidx,len(gs_coarse):]=z[eidx,len(gs_coarse):]-mini
scaling_factor = max(z[eidx,len(gs_coarse):].flatten())
z[eidx,len(gs_coarse):]=z[eidx,len(gs_coarse):]/scaling_factor
for experiment,eidx in zip(experiments, range(len(experiments))):
plt.figure()
fig3,ax3=plt.subplots()
im = ax3.imshow(z[eidx,:len(gs_coarse)], vmin=vmin, vmax=vmax)
cbar = ax3.figure.colorbar(im, ax=ax3)
cbar.ax.set_ylabel('Average gradient of mean image', rotation=-90, va="bottom")
idx=np.unravel_index(np.argmax(z[eidx]),z[eidx].shape)
#print(ls[idx[0]],gs[idx[1]])
plt.plot(idx[1],idx[0])
ax3.plot(idx[1],idx[0], 'rx')
ax3.set_xticks(np.arange(len(ls_coarse)))
ax3.set_yticks(np.arange(len(gs_coarse)))
ax3.set_xticklabels(ls_coarse)
ax3.set_yticklabels(gs_coarse)
ax3.set_ylabel('gamma')
ax3.set_xlabel('lambda')
plt.setp(ax3.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor")
fig3.tight_layout()
plt.savefig('coarse_colormap_'+experiment+'.eps')
for experiment,eidx in zip(experiments, range(len(experiments))):
plt.figure()
fig3,ax3=plt.subplots()
im = ax3.imshow(z[eidx,len(gs_coarse):], vmin=vmin, vmax=vmax)
cbar = ax3.figure.colorbar(im, ax=ax3)
cbar.ax.set_ylabel('Average gradient of mean image', rotation=-90, va="bottom")
idx=np.unravel_index(np.argmax(z[eidx,len(gs_coarse):]),z[eidx,len(gs_coarse):].shape)
#print(ls[idx[0]],gs[idx[1]])
plt.plot(idx[1],idx[0])
ax3.plot(idx[1],idx[0], 'rx')
ax3.set_xticks(np.arange(len(ls_coarse)))
ax3.set_yticks(np.arange(len(gs_coarse)))
ax3.set_xticklabels(ls_fine)
ax3.set_yticklabels(gs_fine)
ax3.set_ylabel('gamma')
ax3.set_xlabel('lambda')
plt.setp(ax3.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor")
fig3.tight_layout()
plt.savefig('fine_colormap_'+experiment+'.eps')
#plt.figure(3)
#plt.xlabel('lambda')
#ax.set_zlabel('gradient of mean')
#plt.savefig('gradient_1D.pdf')
#plt.show()

Event Timeline