def integrate(df_path, tilts, Nz, **kwargs): df = pd.read_pickle(df_path) iBs, iZs = np.arange(5), np.arange(100, Nz, 100) nbs, nzs = iBs.size, iZs.size I, Iint = np.zeros((nts, nbs, nzs)), np.zeros((nbs, Nz)) for it, f in enumerate(df.index): multi = pp.load_multi_obj(name + f) hks, t, Ib = multi.get_beams()[[0, 1, -1]] I[it, :, :] = Ib[iBs, :][:, iZs] Iint[iBs, :] += Ib[iBs, :] hks = [hk[1:-1].split(',') for hk in hks] hk = ['(%d,%d)' % ((int(hk[0]) / 8, int(hk[1]) / 8)) for hk in hks] cs = dsp.getCs('jet', nbs) for iz, iZ in enumerate(iZs): tle = 'z=$%.0f \AA$' % t[iZ] plts = [[tilts[:, 0], I[:, iB, iz], [cs[iB], '-o'], '%s' % hk[iB]] for iB in range(nbs)] dsp.stddisp(plts, labs=[r'$\theta(^{\circ})$', '$I_b$'], title=tle, lw=2, opt='ps', name=fig_path + 'SC_tilt.svg') plts = [[t, Iint[iB, :], [cs[iB], '-'], '%s' % hk[iB]] for iB in range(nbs)] dsp.stddisp(plts, labs=[r'$z(\AA)$', '$I_b$'], lw=2, **kwargs)
def test_001(): lat_params = [1, 2, 1] lat_vec = np.diag(lat_params) pattern = np.array([[6, 0.5, 0.5, 1, 1, 1], [8, 0.75, 0.75, 0.5, 1, 1]]) name = path + 'carbone001.xyz' n = [0, 0, 1] # beam along z u = [1, 0, 0] # rotation axis along x rep, pad = [20, 20, 10], 4 mut.make_xyz(name, pattern, lat_vec, lat_params, n=n, pad=pad, rep=rep, fmt='%.4f', dopt='s') # mut.show_grid(name,'xy') # mut.show_grid(name,'xz') # mut.show_grid(name,'yz') # multi = run(data=name,tail='001',Nhk=31,hk_sym=0,fopt=1,ppopt='wBP') multi = pp.load_multi_obj(path + 'Carbone_SC_001_autoslic.pkl') P = multi.show_patterns(Iopt='Incs', out=False, Nmax=256, caxis=[0, 0.01], imOpt='cv', axPos='V', cmap='gray')
def update_patterns(dfname='df.pkl', ssh='', hostpath=''): df = pp.update_df_info(path + dfname, hostpath=hostpath) for dat in df.index: multi = pp.load_multi_obj(path + dsp.dirname(dfname) + dat) multi.ssh_get(ssh, 'pattern', hostpath=hostpath) multi.save_pattern() return df
def pp_simus(): for i,data in enumerate(files): i_str = data.split('_')[-1].replace('.xyz','') pkl = datpath+'ireloh2_pad2_'+data.replace('.xyz','')+'_autoslic.pkl' multi = pp.load_multi_obj(pkl) multi.outf['patternS'] = multi.outf['patternnpy'].replace('.npy','S.npy') multi.postprocess(ppopt='uwS',ssh_alias='badb') qx,qy,I = np.load(multi._outf('patternS')); print(I.shape)
def plot_S(): df = pd.read_pickle(df_name) for obj_pkl in df.index: #[6:]: val = df.loc[obj_pkl].data.split('_')[0] multi = pp.load_multi_obj(datpath + obj_pkl) dutil.plot_npy(multi._outf('patternS'), log=True, caxis=[-9, -6], title=r'%s' % val, xylims=0.2, name=figpath + val + 'log.png', opt='sc')
def get_figs(dfname='df.pkl'): df = pd.read_pickle(path + dfname) cs = dsp.getCs('Blues', 3) #,dsp.getCs('Reds'),dsp.getCs('Greens') plts = [[], [], []] #pad = int(np.log10(df.index.size))+1 for i, dat in enumerate(df.index): multi = pp.load_multi_obj(path + dsp.dirname(dfname) + dat) multi.pattern( tol=1e-4, Iopt='Insgl', gs=0.25, caxis=[-6.3, 0], Nmax=500, cmap='binary', imOpt='hc', #rings=[0.1,0.2],#,1],, pOpt='Xt', xyTicks=1, xylims=[-3, 3.01, -3, 3.01], #xylims=[-2,2.01,-2,2.01], opt='s', name=path + 'figures/%s_pattern.png' % dat.replace('.pkl', ''))
def run_temsim(load_opt=0, Nz=1): if load_opt: mp_ms = pp.load_multi_obj(datpath + 'Si110_autoslic.pkl') else: mp_ms = ms.Multislice(datpath, mulslice=False, data=Si110, keV=200, slice_thick=dz, NxNy=nxy, repeat=[1, 1, Nz], Nhk=5, v=1, opt='rs', ppopt='w', fopt='f', i_slice=1) # mp_ms.pattern(Iopt='Icns',cmap='gray',imOpt='ch',xylims=[0,12,0,12], # name='docs_fig/Si110_autoslic_pattern.png',axPos='T',setPos=1) # mp_ms.beam_vs_thickness(bOpt='fa',tol=1e-4) return mp_ms
n_TDS=4, T=300, tail='bf2', mulslice=False, keV=200, NxNy=2**10, repeat=[1, 1, 1], slice_thick=1, opt='srw', fopt='f', ssh='badb') # run_simu() pkl = datpath + 'TDS_bf2_autoslic.pkl' multi = pp.load_multi_obj(pkl) multi.postprocess(ppopt='uwS', ssh_alias='badb') # dutil.plot_npy(multi._outf('patternS'),log=True, # caxis=[-9,-6],xylims=0.2, # name=figpath+'TDS_log.png',opt='p') dutil.plot_npy(multi._outf('patternS'), log=False, caxis=[0, 1e-7], xylims=0.2, title='TDS', name=figpath + 'TDS_lin.png', opt='p')
crys = Crystal.from_cif(file) lat_params = crys.lattice_parameters[:3] a1,a2,a3 = lat_params b12 = np.sqrt(1/a1**2+1/a2**2) fs = {'leg':30,'lab':40,'tick':25} if 'E' in opts: #Ewald configuration [010] mut.ewald_sphere(lat_params,lam=cst.eV2mum(12000)*1e4,tmax=60,T=20.,nx=5 ,ny=20,opt='p',name=figpath+'E_MX.png',xylims=[-1,1.01,-0.1,2.01],xyTicks=1,legLoc='upper right',fonts=fs) mut.ewald_sphere(lat_params,lam=cst.keV2lam(200) ,tmax=7 ,T=0.2,nx=20,ny=10,opt='p',name=figpath+'E_ED.png',xylims=[-3,3.01,-0.1,1.01],xyTicks=1,legLoc='upper right',fonts=fs) if 'B' in opts: df = pd.read_pickle(path+'df0.pkl') p1 = pp.load_multi_obj(path+'biotin_m0_autoslic.pkl') p1.datpath = p1.datpath.replace('ronan','tarik') p1.get_beams(bOpt='na') #plot iBs = ['(64,0)','(0,32)','(0,64)','(32,32)','(64,64)'] fig,ax = p1.beam_vs_thickness(iBs=iBs,cm='jet', fonts=fs,opt='ps',name=figpath+'biotin_m0_beams.png') if 'F' in opts: # structure factor lat_vec = crys.reciprocal_vectors pattern = np.array([ np.hstack([a.coords_cartesian,a.atomic_number]) for a in crys.atoms]) hkl,F3d = structure_factor3D(pattern,lat_vec,hkl=None,hklMax=3,sym=0) #excitation error K = 1/cst.keV2lam(200) k = [2/a1,2/a2, b12, 2*b12]
for i in range(-ny + 1, ny)] + ['$q_x=-q_y$', '$q_x=q_y$'] sc = dsp.getCs('Spectral', len(ss)) plts = [[qx[s], qy[s], c, l] for s, l, c in zip(ss, sl, sc)] dsp.stddisp(plts, fig=fig, ax=ax, lw=2) dsp.stddisp([[q[s], I[s], c, l] for s, l, c in zip(ss, sl, sc)], lw=2, xylims=['y', 0, 0.001]) # multi.beam_vs_thickness(iBs=range(10),cm='Spectral',name=figpath+'900_B.svg',opt='sp') # multi.beam_vs_thickness(tol=1e-3,cm='Spectral',name=figpath+'900_B.svg',opt='sp',xylims=['y',0,0.005]) # multi = pp.load_multi_obj('../dat/ireloh/ireloh_t1_autoslic.pkl') multi = pp.load_multi_obj('../dat/ireloh/ireloh_484_autoslic.pkl') # multi = pp.load_multi_obj('../dat/ireloh/ireloh_900_autoslic.pkl') # multi = pp.load_multi_obj('../dat/ireloh/ireloh_t1_autoslic.pkl') # multi = pp.load_multi_obj('../dat/ireloh/ireloh_pptest_autoslic.pkl') # multi.postprocess(ssh_alias='badb',ppopt='uB') # postpp(multi) def plot_transmission_vs_structure_factor(): plts = [] #### Structure factor if 'F' in opts: (qxF, qyF, qzF), Fhkl = multi.get_structure_factor(hkl=None, hklMax=hklM, sym=1,