In [72]:
from chxanalys.chx_libs import (np, roi, time, datetime, os,
getpass, db, get_images,LogNorm, plt,ManualMask)
from chxanalys.chx_generic_functions import (get_detector, get_fields,
get_sid_filenames,load_data, RemoveHot, show_img,
get_avg_img, reverse_updown,create_cross_mask )
from skimage.draw import line_aa, line, polygon, circle
%matplotlib notebook
In [73]:
path = '/XF11ID/analysis/2016_3/masks/'
print ("The analysis results will be saved in : %s"%path)
In [74]:
uid = '5765b8' #count : 1 ['5765b8'] (scan num: 9887) (Measurement: XPCS series alpha=0.1,.1s &4.9s 100 frames )
In [75]:
detector = get_detector( db[uid ] )
print ('Detector is: %s'%detector )
sud = get_sid_filenames(db[uid])
print ('scan_id, full-uid, data path are: %s--%s--%s'%(sud[0], sud[1], sud[2][0] ))
In [76]:
#imgs = load_data( uid, detector, reverse= True )
imgs = load_data( uid, detector, reverse= False )
md = imgs.md
In [77]:
imgs
Out[77]:
In [78]:
Nimg=len(imgs)
In [79]:
md
Out[79]:
In [80]:
pixel_mask = 1- np.int_( np.array( md['pixel_mask'], dtype= bool) )
In [81]:
show_img( imgs[0] , vmin=.0001, vmax=1000, logs=True, image_name ='uid=%s'%uid )
In [82]:
show_img(pixel_mask, vmin=0, vmax=1, image_name ='pixel_mask--uid=%s'%uid )
In [83]:
avg_img = get_avg_img( imgs, sampling = 1000, plot_ = True, uid =uid)
In [84]:
mask_rh = RemoveHot( avg_img, 5E8, plot_=True)
In [85]:
md['beam_center_x'],2167-md['beam_center_y']
Out[85]:
In [86]:
full_mask1 = create_cross_mask( avg_img, center=[ 1473, 1300],
wy_left=0, wy_right= 0,
wx_up= 25, wx_down= 0,center_radius= 0 )
In [87]:
full_mask2 = create_cross_mask( avg_img, center=[ 1477, 1815],
wy_left=0, wy_right= 0,
wx_up= 0, wx_down= 0,center_radius= 50 )
In [88]:
full_mask = full_mask1 #* full_mask2
In [89]:
show_img( full_mask )
In [90]:
mask = np.array ( full_mask * pixel_mask*mask_rh , dtype = bool )
In [91]:
fig, ax = plt.subplots()
#new_mask =
im=ax.imshow( (~mask) * avg_img,origin='lower' ,
norm= LogNorm( vmin=0.1, vmax= 1e2 ), cmap='viridis')
#im = ax.imshow(avg_img, cmap='viridis',origin='lower', norm= LogNorm( vmin=0.001, vmax=100 ) )
plt.show()
In [92]:
fig, ax = plt.subplots()
im = ax.imshow((mask)*avg_img, cmap='viridis',origin='lower', norm= LogNorm( vmin=1, vmax=1000 ) )
plt.show()
In [93]:
#mask = np.array ( ~new_mask* ~plgon_mask * md['pixel_mask']*mask_rh, dtype = bool )
fig, ax = plt.subplots()
im=ax.imshow(mask, origin='lower' ,vmin=0, vmax=1,cmap='viridis')
fig.colorbar(im)
plt.show()
In [94]:
np.save( path + uid +"_mask", mask)
In [95]:
path + uid +"_mask"
Out[95]:
In [96]:
#np.save( path + 'Nov16_4M-GiSAXS' +"_mask", mask)
In [97]:
uid
Out[97]:
In [ ]:
In [ ]: