"This notebook corresponds to version {{ version }} of the pipeline tool: https://github.com/NSLS-II/pipelines"
In [1]:
from databroker import DataBroker as db, get_images, get_table, get_events
from filestore.api import register_handler, deregister_handler
from filestore.retrieve import _h_registry, _HANDLER_CACHE
In [ ]:
hdr = db[{{ uid }}]
In [2]:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import time
from ipywidgets import interact
In [3]:
cd /home/yuzhang/chx-pipelines/Develops/
In [ ]:
cd /XF11ID/analysis/Analysis_Pipelines/Develop/
In [4]:
%run develop.py
%run two_time.py
In [5]:
%matplotlib notebook
#%matplotlib inline
In [6]:
BlueScan = True
DirectAcq = False
detector = 'eiger_4M_cam_img_image_lightfield' #for 4M
In [7]:
if BlueScan:
uid = '54614d43'
#uid = '95782687'
uid = '95782687'
uid= 'ff9f20c0'
uid='71720966'
uid='1663d34a'
uid = 'f505e052-3baa-47d4-bdc4-61c2eb1bcc7a' #sid= 551, 1%PEG,
uid='ee6975a1-9161' #1% wt PEG
uid='ec41569e' #a gisaxs example,
uid = 'ffe9d518' # 10 mTorr 1sec/frame
else:
uid = '/XF11ID/data/2015/11/23/d01ab510-3cf3-4719-bee3_795_master.h5'
In [11]:
if BlueScan:
hdr = db[uid]
ev, = get_events( hdr, [detector] )
imgs = ev['data'][detector]
else:
imgs = Images(uid)
print (imgs)
Nimg=len(imgs)
In [12]:
if BlueScan:
from datetime import datetime
dt = datetime.fromtimestamp(hdr['start'].time)
path ='/XF11ID/analysis' + '/%s/%s/%s/' % (dt.year, dt.month, dt.day)
else:
path ='/XF11ID/analysis/2015/11/23/'
path
Out[12]:
In [13]:
imgs.md
Out[13]:
In [14]:
# The physical size of the pixels
dpix = imgs.md['x_pixel_size'] * 1000.
lambda_ = imgs.md['incident_wavelength'] # wavelegth of the X-rays in Angstroms
Ldet = 4812. # detector to sample distance (mm)
exposuretime= imgs.md['count_time']
acquisition_period = imgs.md['frame_time']
# deadtime= 0 # 60e-6
# timeperframe = exposuretime + deadtime
timeperframe = acquisition_period
timeperframe, exposuretime
Out[14]:
In [15]:
mask = np.load( path + str(uid)+ "_mask.npy")
In [16]:
maskr = mask[::-1,:]
In [17]:
fig, ax = plt.subplots()
im=ax.imshow(maskr, origin='lower' ,vmin=0,vmax=1,cmap='viridis')
fig.colorbar(im)
plt.show()
In [18]:
def view_image(i):
fig, ax = plt.subplots()
ax.imshow(imgs[i]*mask, interpolation='nearest', cmap='viridis',
origin='lower', norm= LogNorm(vmin=0.001, vmax=1e1) )
ax.set_title("Browse the Image Stack")
plt.show()
In [19]:
#interact(view_image, i=(0, Nimg-1))
In [20]:
def view_image(sleeps=1, ims=0, ime = 1):
fig, ax = plt.subplots()
for i in range( ims, ime ):
im=ax.imshow(imgs[i]*mask, interpolation='nearest', cmap='viridis',
origin='lower', norm= LogNorm( vmin=0.01, vmax=10 ) )
ax.set_title("images_%s"%i)
time.sleep( sleeps )
plt.draw()
#fig.colorbar(im)
#view_image(.2, 0, 2)
In [21]:
kymo_sum = np.load( path + str(uid)+"_kymo_sum.npy" )
In [47]:
bad_frames = np.where( kymo_sum > 1e10)[0]
bad_frames
Out[47]:
In [22]:
fig, axes = plt.subplots( )
axes.plot( kymo_sum, '-go' )
ax.set_ylabel('Intensity')
ax.set_xlabel('Frame')
ax.set_title('Kymograph_sum')
plt.show()
In [23]:
avg_img = np.load( path + str(uid)+"_avg_img.npy" )
avg_imgm = avg_img * mask
In [24]:
avg_imgr = avg_img[::-1,:]
avg_imgmr = avg_imgm[::-1,:]
In [25]:
fig, ax = plt.subplots()
im = ax.imshow(avg_imgmr, cmap='viridis',origin='lower',
norm= LogNorm(vmin=0.001, vmax=1e1))
ax.set_title("Masked Averaged Image_Reversed")
fig.colorbar(im)
plt.show()
In [26]:
# The physical size of the pixels
dpix = imgs.md['x_pixel_size'] * 1000.
lambda_ = imgs.md['incident_wavelength'] # wavelegth of the X-rays in Angstroms
Ldet = 4810 # detector to sample distance (mm)
exposuretime= imgs.md['count_time']
acquisition_period = imgs.md['frame_time']
# deadtime= 0 # 60e-6
# timeperframe = exposuretime + deadtime
timeperframe = acquisition_period
timeperframe, exposuretime
Out[26]:
In [27]:
inc_x0 = 1871
inc_y0 = 339
refl_x0 = 1871
refl_y0 = 811 #1670
Lsd= 4.81
lamda= lambda_ #12.4/9
In [28]:
lamda
Out[28]:
In [29]:
alphaf,thetaf, alphai, phi = get_reflected_angles( inc_x0, inc_y0,refl_x0 , refl_y0, Lsd=Lsd )
In [30]:
qx, qy, qr, qz = convert_gisaxs_pixel_to_q( inc_x0, inc_y0,refl_x0,refl_y0, lamda=lamda, Lsd=Lsd )
In [31]:
fig, ax = plt.subplots()
#im=ax.imshow(alphaf, origin='lower' ,cmap='viridis',norm= LogNorm(vmin=0.0001,vmax=2.00))
im=ax.imshow(alphaf*180/np.pi, origin='lower' ,cmap='viridis',vmin=-1,vmax= 1.5 )
fig.colorbar(im)
ax.set_title( 'alphaf')
plt.show()
In [56]:
fig, ax = plt.subplots()
#im=ax.imshow(alphaf, origin='lower' ,cmap='viridis',norm= LogNorm(vmin=0.0001,vmax=2.00))
im=ax.imshow(qr, origin='lower' ,cmap='viridis',vmin=qr.min(),vmax= qr.max(),)
#extent= [ qr.min(),qr.max(),qr.min(),qr.max()] )
fig.colorbar(im)
ax.set_title( 'Q-Parallel')
#ax.grid(True, which='both', color='r', linestyle='--')
ax.grid(True, color='r', linestyle='--')
#ax.grid(True,color='white')
plt.show()
In [39]:
fig, ax = plt.subplots()
#im=ax.imshow(alphaf, origin='lower' ,cmap='viridis',norm= LogNorm(vmin=0.0001,vmax=2.00))
im=ax.imshow(qz, origin='lower' ,cmap='viridis',vmin=qz.min(),vmax= qz.max() )
fig.colorbar(im)
ax.set_title( 'Q-z')
plt.show()
In [57]:
fig, ax = plt.subplots()
im = ax.imshow(avg_imgr, cmap='viridis', origin = 'lower', norm= LogNorm( vmin=0.00001, vmax=.5e2 ) )
ax.set_title("Masked Averaged Image")
fig.colorbar(im)
plt.show()
In [58]:
vert_rect = ( ( 850, 0, 980- 850, 1600-0) , ( 570, 0, 700- 570, 1600-0) ) #(y,x, hight, wdith)
In [59]:
new_mask = np.ones_like( avg_imgr)
new_mask[ :, 1020:1045] =0
In [43]:
get_qr_intensity( qr, avg_imgr, vert_rect, mask=new_mask, show_roi=True)
In [60]:
qz_start = qz[670,0]
qz_end = qz[950,0]
qz_num= 2
qr_start = qr[600,1700]
qr_end = qr[600,0]
qr_num = 15
In [61]:
qr_edge, qr_center = get_qedge(qr_start , qr_end, ( qr_end- qr_start)/qr_num, qr_num )
qz_edge, qz_center = get_qedge( qz_start, qz_end, (qz_end - qz_start)/(qz_num -0) , qz_num )
label_array_qz = get_qmap_label( qz, qz_edge)
label_array_qr = get_qmap_label( qr, qr_edge)
label_array_qzr,qzc,qrc = get_qzrmap(label_array_qz, label_array_qr,qz_center, qr_center )
labels_qzr, indices_qzr = roi.extract_label_indices( label_array_qzr )
labels_qz, indices_qz = roi.extract_label_indices( label_array_qz )
labels_qr, indices_qr = roi.extract_label_indices( label_array_qr )
num_qz = len(np.unique( labels_qz ))
num_qr = len(np.unique( labels_qr ))
num_qzr = len(np.unique( labels_qzr ))
In [62]:
num_qz,num_qr,num_qzr
Out[62]:
In [63]:
fig, ax = plt.subplots()
#im=ax.imshow(alphaf, origin='lower' ,cmap='viridis',norm= LogNorm(vmin=0.0001,vmax=2.00))
im=ax.imshow(label_array_qz, origin='lower' ,cmap='viridis',vmin=0,vmax= None )
fig.colorbar(im)
ax.set_title( 'Q-z_label')
plt.show()
In [64]:
fig, ax = plt.subplots()
#im=ax.imshow(alphaf, origin='lower' ,cmap='viridis',norm= LogNorm(vmin=0.0001,vmax=2.00))
im=ax.imshow(label_array_qr, origin='lower' ,cmap='viridis',vmin=0,vmax= None )
fig.colorbar(im)
ax.set_title( 'Q-r_label')
plt.show()
In [67]:
boxes = label_array_qzr
box_maskr = boxes*maskr
In [68]:
qind, pixelist = roi.extract_label_indices( box_maskr )
noqs = len( np.unique(qind) )
nopr = np.bincount(qind, minlength=(noqs+1))[1:]
In [69]:
nopr
Out[69]:
In [144]:
# plot the figure
fig, axes = plt.subplots(figsize=(8,8))
axes.set_title("Labeled Array on Averaged Data")
im,im_label = show_label_array_on_image(axes, avg_imgr, box_maskr, imshow_cmap='viridis',
cmap='Paired',
vmin=0.01, vmax=30. , origin="lower")
#rwidth = 200
#x1,x2 = [center[1] - rwidth, center[1] + rwidth]
#y1,y2 = [center[0] - rwidth, center[0] + rwidth]
#axes.set_xlim( [x1,x2])
#axes.set_ylim( [y1,y2])
#fig.colorbar(im)
fig.colorbar(im_label)
plt.show()
In [72]:
imgs_ =imgs
imgsr = Reverse_Coordinate(imgs_, maskr)
In [73]:
t0 = time.time()
data_pixel = Get_Pixel_Array( imgsr, pixelist).get_data()
run_time(t0)
In [74]:
max_inten_ring =2
In [75]:
#kymo = roi.kymograph(imgsr, ring_mask, num = max_inten_ring)
In [76]:
pixelist_qi = np.where( qind == max_inten_ring )[0]
data_pixel_qi = data_pixel[:,pixelist_qi]
In [77]:
data_pixel_qi.shape
Out[77]:
In [78]:
fig, ax = plt.subplots(figsize=(8,6))
ax.set_ylabel('Pixel')
ax.set_xlabel('Frame')
ax.set_title('Kymograph')
im = ax.imshow(data_pixel_qi.T, cmap='viridis', vmax=1.0)
fig.colorbar( im )
ax.set_aspect(1.)
plt.show()
In [79]:
fig, ax = plt.subplots(figsize=(8,6))
ax.set_ylabel('Pixel')
ax.set_xlabel('Frame')
ax.set_title('Kymograph_4000-6000')
im = ax.imshow(data_pixel_qi[4000:6000,:].T, cmap='viridis', vmax=1.0)
fig.colorbar( im )
ax.set_aspect(.1)
plt.show()
In [80]:
mean_inten = get_mean_intensity( data_pixel, qind)
In [81]:
times = np.arange( mean_inten[1].shape[0] ) #*timeperframe # get the time for each frame
fig, ax = plt.subplots(figsize=(8, 6))
ax.set_title("Mean intensity of each ring")
for i in range( num_qzr ):
ax.plot(times, mean_inten[i+1], '--o', label="Ring "+str(i+1))
ax.set_xlabel("Frame")
ax.set_ylabel("Mean Intensity")
ax.set_ylim(0, 6e4)
ax.legend( fontsize = 6)
plt.show()
Note : Enter the number of levels and number of buffers for Muliti tau one time correlation number of buffers has to be even. More details in https://github.com/scikit-xray/scikit-xray/blob/master/skxray/core/correlation.py
In [82]:
nopr
Out[82]:
In [83]:
good_start =4000
good_end = 12001
imgs_ =imgs[good_start: good_end-1]
imgsr = Reverse_Coordinate(imgs_, mask)
num_buf = 8
In [84]:
g2_tx1, lag_steps_tx1 = autocor_one_time( num_buf, box_maskr, imgsr, num_lev=None,
bad_images=None, threshold= 5000 )
In [85]:
g2, lag_steps = g2_tx1, lag_steps_tx1
lags = lag_steps*timeperframe
In [86]:
qz_center,qr_center
Out[86]:
In [99]:
#plt.close('all')
In [ ]:
In [88]:
tg2 = np.hstack( [ lags.reshape( len(lags),1), g2] )
#np.save( path + 'g2_%s-%s--%s'%(uid,good_start, good_end), tg2)
np.savetxt( path + 'g2_%s-%s--%s.txt'%(uid,good_start, good_end), tg2)
In [100]:
vmin = 1.1
vmax= 1.15
for qz_ind in range(num_qz):
fig = plt.figure(figsize=(10, 12))
#fig = plt.figure()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=20, y =1.1)
#print (qz_ind,title_qz)
if num_qz!=1:plt.axis('off')
sx = int(round(np.sqrt(num_qr)) )
if num_qr%sx == 0:
sy = int(num_qr/sx)
else:
sy=int(num_qr/sx+1)
for sn in range(num_qr):
ax = fig.add_subplot(sx,sy,sn+1 )
ax.set_ylabel("g2")
ax.set_xlabel(r"$\tau $ $(s)$", fontsize=16)
title_qr = " Qr= " + '%.5f '%( qr_center[sn]) + r'$\AA^{-1}$'
if num_qz==1:
title = 'uid= %s:--->'%uid + title_qz + '__' + title_qr
else:
title = title_qr
ax.set_title( title )
y=g2[:, sn + qz_ind * num_qr]
ax.semilogx(lags, y, '-o', markersize=6)
ax.set_ylim([min(y)*.95, max(y[1:])*1.05 ])
#ax.set_ylim( vmin, vmax)
plt.show()
fig.tight_layout()
#np.save( path + 'g2_%s--%s'%(good_start, good_end), [lags,g2])
#lags,g2 = np.load( path + 'g2_%s--%s.npy'%(good_start, good_end) )
In [90]:
from lmfit import Model
mod = Model(corr.auto_corr_scat_factor)
In [101]:
vmin = 1.1
vmax= 1.15
rate = {}
for qz_ind in range(num_qz):
rate[qz_ind] =[]
fig = plt.figure(figsize=(10, 12))
#fig = plt.figure()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=20, y =1.1)
#print (qz_ind,title_qz)
if num_qz!=1:plt.axis('off')
sx = int(round(np.sqrt(num_qr)) )
if num_qr%sx == 0:
sy = int(num_qr/sx)
else:
sy=int(num_qr/sx+1)
for sn in range(num_qr):
ax = fig.add_subplot(sx,sy,sn+1 )
ax.set_ylabel("g2")
ax.set_xlabel(r"$\tau $ $(s)$", fontsize=16)
title_qr = " Qr= " + '%.5f '%( qr_center[sn]) + r'$\AA^{-1}$'
if num_qz==1:
title = 'uid= %s:--->'%uid + title_qz + '__' + title_qr
else:
title = title_qr
ax.set_title( title )
y=g2[1:, sn + qz_ind * num_qr]
result1 = mod.fit(y, lags=lags[1:], beta=.1,
relaxation_rate =.5, baseline=1.0)
rate[qz_ind].append(result1.best_values['relaxation_rate'])
ax.semilogx(lags[1:], y, '--o', markersize=6)
ax.semilogx(lags[1:], result1.best_fit, '-r')
ax.set_ylim([min(y)*.95, max(y[1:])*1.05 ])
#ax.set_ylim( vmin, vmax)
plt.show()
fig.tight_layout()
In [102]:
for qz_ind in range(num_qz):
#fig = plt.figure(figsize=(10, 12))
#fig = plt.figure()
fig, ax=plt.subplots()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=16, y =1.05)
#print (qz_ind,title_qz)
#if num_qz!=1:plt.axis('off')
ax.plot(qr_center**2, rate[qz_ind], 'ro', ls='--')
ax.set_ylabel('Relaxation rate 'r'$\gamma$'"($s^{-1}$)")
ax.set_xlabel("$q^2$"r'($\AA^{-2}$)')
plt.show()
In [93]:
if True:
D0={}
gmfit={}
for qz_ind in range(num_qz):
D0[qz_ind] = np.polyfit(qr_center**2, rate[qz_ind], 1)
gmfit[qz_ind] = np.poly1d( D0[qz_ind] )
print ('The fitted diffusion coefficient D0 is: %.2E A^2S-1'%D0[qz_ind][0])
In [103]:
for qz_ind in range(num_qz):
fig,ax = plt.subplots()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=16, y =1.05)
ax.plot(qr_center**2, rate[qz_ind], 'ro', ls='')
ax.plot(qr_center**2, gmfit[qz_ind](qr_center**2), ls='-')
ax.set_ylabel('Relaxation rate 'r'$\gamma$'"($s^{-1}$)")
ax.set_xlabel("$q^2$"r'($\AA^{-2}$)')
plt.show()
In [ ]:
#data_pixel.shape
In [95]:
good_start= 0
good_end = 15000
imgs_ =imgs[good_start: good_end]
imgsr = Reverse_Coordinate(imgs_, mask)
In [107]:
#box_maskr
In [ ]:
#g12b = auto_two_Array( imgsr, box_maskr, data_pixel = data_pixel )
In [108]:
g12b, g12b_not_norm, norms = auto_two_Array_g1_norm( imgsr, box_maskr,
data_pixel = data_pixel )
In [ ]:
#np.save( path + 'g12b_%s-%s--%s'%(uid,good_start, good_end), g12b)
In [ ]:
#g12b.shape
In [109]:
g12_num = 0 #0: the firs box
data = g12b[:,:,g12_num]
fig, ax = plt.subplots()
im=ax.imshow( data, origin='lower' , cmap='viridis',
norm= LogNorm( vmin= 1.8, vmax= 2.2 ),
extent=[0, data.shape[0]*timeperframe, 0, data.shape[0]*timeperframe ] )
ax.set_title('0-%s frames--Qth= %s'%(Nimg,g12_num))
ax.set_xlabel( r'$t_1$ $(s)$', fontsize = 18)
ax.set_ylabel( r'$t_2$ $(s)$', fontsize = 18)
fig.colorbar(im)
plt.show()
In [110]:
g12_num = 1 #0: the second box
data = g12b[:,:,g12_num]
fig, ax = plt.subplots()
im=ax.imshow( data, origin='lower' , cmap='viridis',
norm= LogNorm( vmin= 1.1, vmax= 1.15 ),
extent=[0, data.shape[0]*timeperframe, 0, data.shape[0]*timeperframe ] )
ax.set_title('0-%s frames--Qth= %s'%(Nimg,g12_num))
ax.set_xlabel( r'$t_1$ $(s)$', fontsize = 18)
ax.set_ylabel( r'$t_2$ $(s)$', fontsize = 18)
fig.colorbar(im)
plt.show()
In [111]:
fig,ax = plt.subplots()
ax.plot( g12b[:,:,0][0], 'ro', ls='')
Out[111]:
In [112]:
#np.where( g12b[:,:,0] == g12b[:,:,0].min() )
In [113]:
np.where( g12b[:,:,0][0] <1.1)
Out[113]:
In [114]:
np.where( g12b[:,:,0][100] <1.1)
Out[114]:
In [115]:
bad_frames = np.where( g12b[:,:,0][100] <1.1)[0]
In [116]:
bad_frames
Out[116]:
In [117]:
g12b_mask = make_g12_mask(g12b, bad_frames)
In [127]:
g12bm = masked_g12(g12b, g12b_mask)
In [129]:
g12_num = 1 #0: the second box
data = g12bm[:,:,g12_num]
fig, ax = plt.subplots()
im=ax.imshow( data, origin='lower' , cmap='viridis',
norm= LogNorm( vmin= 1.1, vmax= 1.15 ),
extent=[0, data.shape[0]*timeperframe, 0, data.shape[0]*timeperframe ] )
ax.set_title('0-%s frames--Qth= %s'%(Nimg,g12_num))
ax.set_xlabel( r'$t_1$ $(s)$', fontsize = 18)
ax.set_ylabel( r'$t_2$ $(s)$', fontsize = 18)
fig.colorbar(im)
plt.show()
In [133]:
g2b = get_one_time_from_two_time(g12bm, timeperframe= timeperframe)
In [168]:
vmin = 1.0
vmax= 1.2
#rate_g2b = {}
for qz_ind in range(num_qz):
#rate_g2b[qz_ind] =[]
fig = plt.figure(figsize=(10, 12))
#fig = plt.figure()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=20, y =1.1)
#print (qz_ind,title_qz)
if num_qz!=1:plt.axis('off')
sx = int(round(np.sqrt(num_qr)) )
if num_qr%sx == 0:
sy = int(num_qr/sx)
else:
sy=int(num_qr/sx+1)
for sn in range(num_qr):
ax = fig.add_subplot(sx,sy,sn+1 )
ax.set_ylabel("g2")
ax.set_xlabel(r"$\tau $ $(s)$", fontsize=16)
title_qr = " Qr= " + '%.5f '%( qr_center[sn]) + r'$\AA^{-1}$'
if num_qz==1:
title = 'uid= %s:--->'%uid + title_qz + '__' + title_qr
else:
title = title_qr
ax.set_title( title )
#print (sn + qz_ind * num_qr)
y= g2b[:1000, sn + qz_ind * num_qr]
x= np.arange(len(y))*timeperframe
#print (x[1:])
#y=g2b[1:, sn + qz_ind * num_qr]
#result1 = mod.fit(y, lags=x[1:], beta=.1, relaxation_rate =.5, baseline=1.0)
#rate_g2b[qz_ind].append(result1.best_values['relaxation_rate'])
if not isnan(y.mean()):ax.semilogx( x[1:], y[1:] , '--o', markersize=6)
#ax.plot(x[1:], y[1:], '--o', markersize=6)
#ax.semilogx(x[1:], result1.best_fit, '-r')
ax.set_ylim([min(y[1:])*.95, max(y[1:])*1.05 ])
#ax.set_ylim( vmin, vmax)
plt.show()
fig.tight_layout()
In [170]:
vmin = 1.0
vmax= 1.2
#rate_g2b = {}
for qz_ind in range(num_qz):
#rate_g2b[qz_ind] =[]
fig = plt.figure(figsize=(10, 12))
#fig = plt.figure()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=20, y =1.1)
#print (qz_ind,title_qz)
if num_qz!=1:plt.axis('off')
sx = int(round(np.sqrt(num_qr)) )
if num_qr%sx == 0:
sy = int(num_qr/sx)
else:
sy=int(num_qr/sx+1)
for sn in range(num_qr):
ax = fig.add_subplot(sx,sy,sn+1 )
ax.set_ylabel("g2")
ax.set_xlabel(r"$\tau $ $(s)$", fontsize=16)
title_qr = " Qr= " + '%.5f '%( qr_center[sn]) + r'$\AA^{-1}$'
if num_qz==1:
title = 'uid= %s:--->'%uid + title_qz + '__' + title_qr
else:
title = title_qr
ax.set_title( title )
#print (sn + qz_ind * num_qr)
y= g2b[:1000, sn + qz_ind * num_qr]
x= np.arange(len(y))*timeperframe
#print (x[1:])
#y=g2b[1:, sn + qz_ind * num_qr]
#result1 = mod.fit(y, lags=x[1:], beta=.1, relaxation_rate =.5, baseline=1.0)
#rate_g2b[qz_ind].append(result1.best_values['relaxation_rate'])
if not isnan(y.mean()):ax.semilogx( x[1:], y[1:] , '--o', markersize=6)
#ax.plot(x[1:], y[1:], '--o', markersize=6)
#ax.semilogx(x[1:], result1.best_fit, '-r')
y2=g2[:, sn + qz_ind * num_qr]
ax.semilogx(lags, y2, '-rs', markersize=6)
#ax.set_ylim([min(y)*.95, max(y[1:])*1.05 ])
ax.set_ylim([min(y2[1:])*.95, max(y2[1:])*1.05 ])
#ax.set_ylim( vmin, vmax)
plt.show()
fig.tight_layout()
In [176]:
g12b_not_norm_mask = masked_g12(g12b_not_norm, g12b_mask)
In [194]:
norms_masker = make_norms_mask(norms, bad_frames)
In [195]:
norms_mask = masked_norms( norms, norms_masker)
In [230]:
g2b_not_norm = get_one_time_from_two_time(g12b_not_norm_mask,
norms=norms_mask, nopr=nopr - len(bad_frames), timeperframe= timeperframe)
In [232]:
vmin = 1.0
vmax= 1.2
#rate_g2b = {}
for qz_ind in range(num_qz):
#rate_g2b[qz_ind] =[]
fig = plt.figure(figsize=(10, 12))
#fig = plt.figure()
title_qz = ' Qz= %.5f '%( qz_center[qz_ind]) + r'$\AA^{-1}$'
plt.title('uid= %s:--->'%uid + title_qz,fontsize=20, y =1.1)
#print (qz_ind,title_qz)
if num_qz!=1:plt.axis('off')
sx = int(round(np.sqrt(num_qr)) )
if num_qr%sx == 0:
sy = int(num_qr/sx)
else:
sy=int(num_qr/sx+1)
for sn in range(num_qr):
ax = fig.add_subplot(sx,sy,sn+1 )
ax.set_ylabel("g2")
ax.set_xlabel(r"$\tau $ $(s)$", fontsize=16)
title_qr = " Qr= " + '%.5f '%( qr_center[sn]) + r'$\AA^{-1}$'
if num_qz==1:
title = 'uid= %s:--->'%uid + title_qz + '__' + title_qr
else:
title = title_qr
ax.set_title( title )
#print (sn + qz_ind * num_qr)
y= g2b_not_norm[:1000, sn + qz_ind * num_qr]
x= np.arange(len(y))*timeperframe
#print (x[1:])
#y=g2b[1:, sn + qz_ind * num_qr]
#result1 = mod.fit(y, lags=x[1:], beta=.1, relaxation_rate =.5, baseline=1.0)
#rate_g2b[qz_ind].append(result1.best_values['relaxation_rate'])
if not isnan(y.mean()):ax.semilogx( x[1:], y[1:] , '--o', markersize=6)
#ax.plot(x[1:], y[1:], '--o', markersize=6)
#ax.semilogx(x[1:], result1.best_fit, '-r')
y2=g2[:, sn + qz_ind * num_qr]
ax.semilogx(lags, y2, '-r', markersize=3)
ax.set_ylim([min(y)*.95, max(y[1:])*1.05 ])
#ax.set_ylim([min(y2[1:])*.95, max(y2[1:])*1.05 ])
#ax.set_ylim( vmin, vmax)
plt.show()
fig.tight_layout()
In [239]:
arr= trans_g12_to_square( g12bm[:,:,0] )
In [243]:
arr[1000,:].mean()
Out[243]:
In [ ]:
In [ ]:
In [245]:
g12_num =1
g2b = show_g12_age_cuts( g12bm, g12_num=g12_num, slice_num =3, slice_width= 500,
slice_start=8000, slice_end= 2*15000-8000,
timeperframe= timeperframe,vmin= 1.1, vmax = 1.15) #vmax=g12b[:,:,g12_num].max() )
In [246]:
taus = show_g12_tau_cuts(g12bm, g12_num=1, slice_num = 5, slice_width= 1.0,
slice_start=3, slice_end= 10000-1,draw_scale_tau =5.0, vmin=1.1,vmax=1.15 )
In [247]:
his = his_tau(taus, hisbin = 10, plot=True)
In [ ]: