source_dir = './merge_images/' infiles = glob.glob(os.path.join(source_dir, pattern + '.npy')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) thumb_merged = Protocols.thumbnails(crop=None, resize=1, blur=None, cmap=cmap_vge_hdr, ztrim=[0.1, 0.002]) thumb_merged.name = 'thumbnails_merged' q_images_merged = Protocols.q_image(cmap=cmap_vge, plot_range=[-0.1, 7.0, 0, 5.5], xticks=[0, 2, 4, 6], yticks=[0, 2, 4], plot_buffers=[0.2, 0.05, 0.15, 0.05], ztrim=[0.3, 0.001]) q_images_merged.name = 'q_images_merged'
infiles = glob.glob(os.path.join(source_dir, pattern + '.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: #protocols = [ Protocols.circular_average_q2I(plot_range=[0, 0.2, 0, None]) ] #protocols = [ Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) ] #protocols = [ Protocols.q_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.2, 0.01]) ] #protocols = [ Protocols.qr_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], zmin=1010., ztrim=[None, 0.01]) ] #protocols = [ Protocols.qr_image(blur=None, bins_relative=0.8, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.38, 0.002], dezing_fill=True) ] #protocols = [ Protocols.q_phi_image(bins_relative=0.25, plot_range=[0, 3.0, 0, +90]) ] protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=1.369*0.25, dq=0.002, num_rings=10, ztrim=[0.2, 0.01], dpi=300) , #Protocols.circular_average(ylog=False, plot_range=[0, 3.5, None, None]) , Protocols.thumbnails(crop=None, blur=None, resize=1.0,
# Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, #'background' : source_dir+'empty*saxs.tiff', #'transmission_int': '../../data/Transmission_output.csv', # Can also specify an float value. } run_args = { 'verbosity': 3, #'save_results' : ['xml', 'plots', 'txt', 'hdf5'], } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) #process.connect_databroker('cms') # Access databroker metadata patterns = [ ['theta', '.+_th(\d+\.\d+)_.+'], ['x_position', '.+_x(-?\d+\.\d+)_.+'], ['y_position', '.+_yy(-?\d+\.\d+)_.+'], #['anneal_time', '.+_anneal(\d+)_.+'] , #['cost', '.+_Cost(\d+\.\d+)_.+'] , ['annealing_temperature', '.+_T(\d+\.\d\d\d)C_.+'], #['annealing_time', '.+_(\d+\.\d)s_T.+'] , #['annealing_temperature', '.+_localT(\d+\.\d)_.+'] , #['annealing_time', '.+_clock(\d+\.\d\d)_.+'] , #['o_position', '.+_opos(\d+\.\d+)_.+'] , #['l_position', '.+_lpos(\d+\.\d+)_.+'] , ['exposure_time', '.+_(\d+\.\d+)s_\d+_saxs.+'],
infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, #'rot180' : False, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) protocols = [ #Protocols.export_STL( stl_zscale=150, stl_pedestal=8, blur=1.0, resize=1.0, crop_GI=700, logo_file='logo.png', logo_resize=0.5), Protocols.export_STL(stl_zscale=150, stl_pedestal=8, blur=1.0, resize=1.0, crop_beam=[900, 900], logo_file='logo.png', logo_resize=0.5), ] # Run ######################################## print('Processing {} infiles...'.format(len(infiles)))
infiles = glob.glob(os.path.join(source_dir, pattern + '.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 4, #'save_results' : ['xml', 'plots', 'txt', 'npz', 'hdf5'], } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: #protocols = [ Protocols.q_image(q_max=0.14, blur=2.0, bins_relative=0.25, xticks=[-.1, 0, .1], ztrim=[0.01, 0.001])] #protocols = [ Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) ] q0, qw = 0.0259, 0.0015 #q0, qw = 0.0313, 0.0008 protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4, ztrim=[0.05, 0.05], ) , #Protocols.circular_average(ylog=True, plot_range=[0, 0.12, None, None]) , #Protocols.thumbnails(name='thumbnails_hdr_goldish', cmap=cmap_hdr_goldish, blur=None, crop=None, resize=1), #Protocols.thumbnails(name='thumbnails_jet', crop=None, blur=None, resize=1) , #Protocols.thumbnails(crop=None, resize=1.0, blur=None, cmap=cmap_vge, ztrim=[0.01, 0.001]) , #Protocols.q_image(blur=None, cmap='jet', plot_range=[-0.05, 0.05, 0, 0.1], ztrim=[0.05, 0.002], colorbar=False, plot_buffers=[0.25, 0.06, 0.2, 0.05], xticks=[-0.04, 0, 0.04]), Protocols.linecut_qz_fit(
infiles = glob.glob(os.path.join(source_dir, pattern + '.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, #'save_results' : ['xml', 'plots', 'txt', 'npz', 'hdf5'], } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: #protocols = [ Protocols.q_image(q_max=0.14, blur=2.0, bins_relative=0.25, xticks=[-.1, 0, .1], ztrim=[0.01, 0.001])] #protocols = [ Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) ] protocols = [ #Protocols.HDF5(save_results=['hdf5']) #Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4, ztrim=[0.05, 0.05], ) , #Protocols.circular_average(ylog=True, plot_range=[0, 0.15, None, None], show=False) , #Protocols.circular_average_q2I_fit(ylog=False, plot_range=[0, 0.15, None, None], show=False, label_filename=False) , #Protocols.linecut_angle(q0=0.108, dq=0.005, show_region=False) , Protocols.q_image(q_max=0.14, blur=2.0, bins_relative=0.25, xticks=[-.1, 0, .1],
# Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, #'rot180' : False, #'flip' : True, # PSCCD } run_args = { 'verbosity': 3, #'save_results' : ['xml', 'plots', 'txt', 'hdf5'], } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) #process.connect_databroker('cms') # Access databroker metadata # Examples: # Protocols.circular_average_q2I(plot_range=[0, 0.2, 0, None]) # Protocols.sector_average(angle=-70, dangle=25, show_region=False) # Protocols.linecut_q(chi0= 90+70, dq= .5, gridlines=True, label_filename=True, save_results = [ 'hdf5' ] ) # Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) # Protocols.q_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.2, 0.01]) # Protocols.qr_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], zmin=1010., ztrim=[None, 0.01]) # Protocols.qr_image(blur=None, bins_relative=0.8, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.38, 0.002], dezing_fill=True) # Protocols.qr_image(blur=None, colorbar=True, save_data=False, transparent=False, label_filename=True) # Protocols.q_phi_image(bins_relative=0.25, plot_range=[0, 3.0, 0, +90]) protocols = [ #Protocols.HDF5(save_results=['hdf5'])
infiles.sort() #infiles = [infiles[0]] #infiles = [infiles[-1]] # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) protocols = [ Protocols.calibration_check(show=False, AgBH=True, q0=0.015, num_rings=2) ] #protocols = [ Protocols.thumbnails(crop=0.8)] # mini #protocols = [ Protocols.thumbnails(crop=None, resize=1.0, blur=None, file_extension='.png') ] # full-size #protocols = [ Protocols.thumbnails(crop=None, resize=1.0, blur=None, cmap=cmap_vge, ztrim=[0, 0.001], file_extension='.png') ] # custom #protocols = [ Protocols.q_image(q_max=0.14, blur=2.0, bins_relative=0.25, xticks=[-.1, 0, .1], ztrim=[0.01, 0.001])] #protocols = [ Protocols.circular_average(ylog=True, plot_range=[0, 0.2, None, None]) ] #protocols = [ Protocols.circular_average_q2I(plot_range=[0, 0.2, 0, None]) ] #protocols = [ circular_average_q2I_fit(plot_range=[0, 0.2, 0, None]) ] # local protocol
calibration = Calibration() calibration.set_energy(8.8984) # CHX #calibration.set_image_size(512, 512) calibration.set_image_size(619, 487) calibration.set_pixel_size(pixel_size_um=75.0) calibration.set_distance(0.5944) calibration.set_beam_position(150.18, 390.59) mask_dir = './' mask = Mask() mask.load(mask_dir + 'mask.png') load_args = {'calibration': calibration, 'mask': mask} run_args = {'verbosity': 4} process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) protocols = [main_peak()] startreg = time.clock() process.run(infiles, protocols, output_dir=output_dir, force=True) print('Reg time', time.clock() - startreg) startpar = time.clock() Parallel(n_jobs=4, backend='threading')(delayed( process.run )(infiles=[infile], protocols=protocols, output_dir=output_dir, force=True) for infile in infiles)
# Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, 'format': 'tiff', 'full_name': True, # Don't truncate at a decimal point } run_args = { 'verbosity': 3, #'save_results' : ['xml', 'plots', 'txt', 'hdf5'], } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: #protocols = [ Protocols.q_image(q_max=0.14, blur=2.0, bins_relative=0.25, xticks=[-.1, 0, .1], ztrim=[0.01, 0.001])] #protocols = [ Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) ] q0, dq0, qp = 0.0136, 0.005, 0.05 protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4, ztrim=[0.05, 0.005], ) , #Protocols.circular_average(ylog=True, plot_range=[0, 0.12, None, None]) , Protocols.q_image(plot_range=[-qp, +qp, 0, 2 * qp], plot_buffers=[0.28, 0.07, 0.25, 0.05]), Protocols.linecut_qr_fit(qz=0.033, dq=0.005, show_region=False, q0=q0, plot_range=[0, qp / 2, 0, None],
infiles = glob.glob(os.path.join(source_dir, pattern + '.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) patterns = [ ['theta', '.+_th(\d+\.\d+)_.+'], ['x_position', '.+_x(-?\d+\.\d+)_.+'], ['y_position', '.+_yy(-?\d+\.\d+)_.+'], ['cost', '.+_Cost(\d+\.\d+)_.+'], ['annealing_temperature', '.+_T(\d+\.\d\d\d)C_.+'], ['annealing_time', '.+_(\d+\.\d)s_T.+'], ['exposure_time', '.+_(\d+\.\d+)c_\d+_saxs.+'], ['sequence_ID', '.+_(\d+)_saxs.+'], ] protocols = [ #Protocols.thumbnails(name='thumbnails2', crop=None, resize=1.0, blur=None, cmap=cmap_vge, ztrim=[0.0, 0.01]) #circular_average_q2I_fit(show=False, q0=None, plot_range=[0, 0.025, 0, None], fit_range=[0.010, 0.022], vary=True) ,
infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, 'rotCCW': True, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4, ztrim=[0.05, 0.005], ) , #Protocols.circular_average(ylog=True, plot_range=[0, 0.12, None, None]) , Protocols.thumbnails(crop=None, resize=0.5, blur=None, cmap=cmap_vge_hdr, ztrim=[0.1, 0.002]), ] # Run ########################################
infiles = glob.glob(os.path.join(source_dir, pattern + '.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) thumb2 = Protocols.thumbnails(crop=None, resize=1.0, blur=None, cmap=cmap_vge, ztrim=[0.0, 0.01]) thumb2.name = 'thumbnails2' L0 = 48 # nm q0 = 0.1 * 2 * np.pi / (L0) print(q0) patterns = [ ['theta', '.+_th(\d+\.\d+)_.+'], ['x_position', '.+_x(-?\d+\.\d+)_.+'],
mask_file = glob.glob(os.path.join(source_dir, pattern+'mask.png')) mask = Mask(mask_file[0]) # Analysis to perform ######################################## load_args = { 'calibration' : calibration, 'mask' : mask, } run_args = { 'verbosity' : 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4, ztrim=[0.05, 0.005], zmin=0) , #Protocols.circular_average(ylog=True, plot_range=[0, 5.5, None, None]) , Protocols.q_image(name='q_images_merged', cmap=cmap_vge, plot_range=[-0.1, 3, 0, 3], xticks=[0, 2, 4, 6], yticks=[0, 2, 4], plot_buffers=[0.2, 0.05, 0.15, 0.05], ztrim=[0.3, 0.001]) Protocols.thumbnails(name='thumbnails_merged', crop=None, resize=1, blur=None, cmap=cmap_vge_hdr, ztrim=[0.1, 0.002]) ] # Run ######################################## process.run(infiles, protocols, output_dir=output_dir, force=1) # Loop
#infiles = glob.glob(os.path.join(source_dir, 'AgBH_5m_th0.000_10.00s_20323_saxs.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4, ztrim=[0.05, 0.05], ) , Protocols.circular_average(ylog=True, plot_range=[0, 0.12, None, None]), #Protocols.sector_average(angle=0, dangle=20, ylog=True, plot_range=[0, 0.3, None, None], show_region=True) , #Protocols.linecut_angle(q0=0.094, dq=0.015, show_region=False) , #Protocols.q_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.2, 0.01]) , #Protocols.qr_image(blur=None, bins_relative=0.8, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.38, 0.002], dezing_fill=True) , #Protocols.q_phi_image(bins_relative=0.25, plot_range=[0, 3.0, 0, +90]) , Protocols.thumbnails(crop=None, resize=1.0, blur=None, cmap=cmap_vge, ztrim=[0.0, 0.01]), ]
calibration.set_image_size(2070, 2167) # Eiger 4M calibration.set_pixel_size(pixel_size_um=75.0) calibration.set_distance(4.755) calibration.set_beam_position(838.5, 1833.4) # Approximate mask_dir = '/home/kyager/current/code/SciAnalysis/main/SciAnalysis/XSAnalysis/masks/' mask = Mask() #mask.load(mask_dir+'Eiger4M_all_gaps-mask.png') #mask.load(mask_dir+'CHX_Eiger4M-bad_flatfield_10percent-mask.png') mask.load(mask_dir + 'CHX_Eiger4M-bad_flatfield_05percent-mask.png') mask.load(mask_dir + 'CHX_pipe-2015Oct-mask.png') #mask.load(mask_dir+'CHX_bs_streaks-2015Oct-mask.png') from SciAnalysis.XSAnalysis import Protocols process = Protocols.ProcessorXS(calibration=calibration, mask=mask) protocols = [Protocols.thumbnails(crop=1.3)] #protocols = [ Protocols.circular_average(ylog=True) ] #protocols = [ Protocols.fit_calibration(ylog=True) ] process.run(infiles, protocols, output_dir=output_dir, force=True) if False: root_dir = '/media/extend/CHX/' data_dir = 'LDRD_Meso_correlation/2015_10Oct-ref_patterns/21/' source_dir = root_dir + 'data/' + data_dir output_dir = root_dir + 'analysis/' + data_dir import glob #infiles = glob.glob(source_dir+'AgBH_series_24_master.h5')
infiles = glob.glob(os.path.join(source_dir, pattern+'.tiff')) infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration' : calibration, 'mask' : mask, #'rot180' : False, #'flip' : True, # PSCCD } run_args = { 'verbosity' : 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: #protocols = [ Protocols.circular_average_q2I(plot_range=[0, 0.2, 0, None]) ] #protocols = [ Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) ] #protocols = [ Protocols.q_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.2, 0.01]) ] #protocols = [ Protocols.qr_image(blur=1.0, bins_relative=0.5, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], zmin=1010., ztrim=[None, 0.01]) ] #protocols = [ Protocols.qr_image(blur=None, bins_relative=0.8, plot_range=[-0.1, 3.0, 0, 3.0], _xticks=[0, 1.0, 2.0, 3.0], ztrim=[0.38, 0.002], dezing_fill=True) ] #protocols = [ Protocols.q_phi_image(bins_relative=0.25, plot_range=[0, 3.0, 0, +90]) ] protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=1.369*0.25, dq=0.002, num_rings=10, ztrim=[0.2, 0.01], dpi=300) , Protocols.circular_average(ylog=True, dq = .001, plot_range=[0.0, 1.5, None, None], gridlines=True, save_results = [ 'hdf5' ] ) , #Protocols.thumbnails(crop=None, resize=0.5, cmap=cmap_vge, ztrim=[0.06, 0.001], zmin=1000.0) , # PSCCD #Protocols.linecut_q(chi0= 90+0, dq=.5, ylog=True, gridlines=True, plot_range=[0.0, 1.5, None, None] ) ,
infiles.sort() # Analysis to perform ######################################## load_args = { 'calibration': calibration, 'mask': mask, 'flip': True, } run_args = { 'verbosity': 3, } process = Protocols.ProcessorXS(load_args=load_args, run_args=run_args) # Examples: #protocols = [ Protocols.calibration_check(show=False, AgBH=True, q0=0.010, num_rings=4) ] #protocols = [ Protocols.thumbnails(crop=0.8)] # mini #protocols = [ Protocols.thumbnails(crop=None, resize=1.0, blur=None, file_extension='.png') ] # full-size #protocols = [ Protocols.thumbnails(crop=None, resize=1.0, blur=None, cmap=cmap_vge, ztrim=[0, 0.001], file_extension='.png') ] # custom #protocols = [ Protocols.q_image(q_max=0.14, blur=2.0, bins_relative=0.25, xticks=[-.1, 0, .1], ztrim=[0.01, 0.001])] #protocols = [ Protocols.circular_average(ylog=True, plot_range=[0, 0.2, None, None]) ] #protocols = [ Protocols.circular_average_q2I(plot_range=[0, 0.2, 0, None]) ] #protocols = [ circular_average_q2I_fit(plot_range=[0, 0.2, 0, None]) ] # local protocol #protocols = [ Protocols.linecut_angle(q0=0.01687, dq=0.00455*1.5, show_region=False) ] #protocols = [ linecut_angle_fit(dq=0.00455*1.5) ] protocols = [ #Protocols.calibration_check(show=False, AgBH=True, q0=1.369*0.25, dq=0.002, num_rings=10, ztrim=[0.2, 0.01], dpi=300) ,