def get_ft_2d(res, obs_key, tmn, tmx): if obs_key in ['s']: dat = res[obs_key][tmn:tmx, ::] if obs_key in ['z', 'x', 'y']: dat = ms.get_diag_vecs(res[(obs_key + obs_key)][::])[tmn:tmx, ::] ws, ks, amps, iboard, board = make_ft_2d(dat) return ws, ks, amps, iboard, board
def get_ft_1d(res, obs_key): if obs_key in ['ND', 'CC', 'Y']: dat = res[obs_key][::] if obs_key in ['s']: dat = res[obs_key][::] dat = np.mean(dat, axis=1) if obs_key in ['z', 'x']: dat = ms.get_diag_vecs(res[(obs_key + obs_key)][::]) dat = np.mean(dat, axis=1) freqs, FT, rn = make_ft_1d(dat) return freqs, FT, rn
params_list_list = io.make_params_list_list(fixed_params_dict, var_params_dict) for params_list in params_list_list: for params in params_list: res = h5py.File(io.default_file_name(params, 'data', '.hdf5')) mode = params['mode'] S = params['S'] V = params['V'] T = params['T'] L = params['L'] th = get_th(V) n = 2 sds_frac = 0.6 grid = ms.get_diag_vecs(res['zz'][::]) grid = 0.5 * (1.0 - grid) impact_t = np.argmax(grid[:,L-1]) M1_0, M1_1, M2_0, M2_1, intersection = \ fit_gmix(grid, sds_frac=sds_frac, n=n) im = plt.imshow(grid, origin='lower', aspect=1, interpolation='none') #plt.errorbar(M1_0, range(T+1), xerr=M2_0, c='k', lw=1.5) plt.errorbar(M1_1, range(T+1), xerr=M2_1, c='r', lw=1.5) Bs, chi2, Bs_sd = ft.f_fits(ft.flin, [1.0, 0.0], range(4, cross_t), M1_0[4:cross_t], xerr=M2_0[4:cross_t])
def transport_calc(params, tmax_1, span=[0, 61], n=2, tmin=2, sds_frac=0.6, speed_f=ft.flin, speed_Bs_est=[1.0, 0.0], diff_f=ft.flin, diff_Bs_est=[1.0, 0.0], dirr='R-L', g_fignum=1000): transport = {} res = h5py.File(io.default_file_name(params, 'data', '.hdf5')) print(io.default_file_name(params, 'data', '.hdf5')) print([key for key in res.keys()]) exp = ms.get_diag_vecs(res['zz'][::]) Ptj = ((1.0 - exp) / 2.0)[span[0]:span[1]] if dirr == 'L-R': reflect_t = np.argmax(Ptj[:, params['L'] - 1]) if dirr == 'R-L': reflect_t = np.argmax(Ptj[:, 0]) transport['grid'] = Ptj M1_0, M1_1, M2_0, M2_1, intersection = fit_gmix(Ptj, params, n=n, sds_frac=sds_frac, g_fignum=g_fignum) keys = ['Bs', 'chi2', 'dBs'] for moment in [1, 2]: for peak in [0, 1]: moment_name = 'M' + str(moment) + '_' + str(peak) mom = eval(moment_name) tmax = reflect_t if moment == 2: tmin = 1 tmax = np.argmax(M2_0[0:params['L'] - 2]) if moment == 1 and peak == 1: if tmax_1 is None: tmax_1 = tmax transport['tmax_1'] = tmax_1 tmax = tmax_1 if moment == 1 and peak == 0: transport['intersection'] = intersection[tmin:tmax] times = np.array(range(tmin, tmax)) Bs_chi2_dBs = \ list(ft.f_fits(speed_f, speed_Bs_est, times, mom[tmin:tmax])) transport[moment_name] = eval(moment_name) transport['times_' + moment_name] = times for j, key in enumerate(keys): transport_key = '_'.join([moment_name, key]) transport[transport_key] = Bs_chi2_dBs[j] return transport
def plot(params, corrj=None): print('Plotting results...') results = h5py.File(params['fname'], 'r+') # get spin projections along x, y, and z x_grid, y_grid, z_grid = [ measures.get_diag_vecs(results[ab][::]) for ab in ('xx', 'yy', 'zz') ] proj_grids_stats = results['stats'] # get g2 correlators at constant row j if corrj is None: corrj = results['gstats']['corrj'][0] x_g2grid, y_g2grid, z_g2grid = [ measures.get_row_vecs(results[ab][::], j=corrj) for ab in ['gxx', 'gyy', 'gzz'] ] g2grids_stats = results['gstats'] # get mi measure results and place in ordered dict for plotting meas_keys = ['ND', 'CC', 'Y'] meas_list = [results[meas_key][::] for meas_key in meas_keys] Fmeas_list = [{ 'amps': results['F' + meas_key][::], 'RN': results['RN' + meas_key][::] } for meas_key in meas_keys] meas_dict = OrderedDict( (key, data) for key, data in zip(meas_keys, meas_list)) Fmeas_dict = OrderedDict( (key, Fdata) for key, Fdata in zip(meas_keys, Fmeas_list)) # get local and entropies stj = results['s'][::] # get mutual information adjacency matrices mtjk = results['m'][::] # plot spin projections proj_titles = [ r'$\langle \sigma^x_j \rangle$', r'$\langle \sigma^y_j \rangle$', r'$\langle \sigma^z_j \rangle$' ] prob_titles = [ r'$\frac{\sum_j j P_j(x-)}{\sum_j P_j(x-)}$', r'$\frac{\sum_j j P_j(y-)}{\sum_j P_j(y-)}$', r'$\frac{\sum_j j P_j(z-)}{\sum_j P_j(z-)}$' ] plot_grids([x_grid, y_grid, z_grid], fignum=0, titles=proj_titles, suptitle='Spin Projections', xlabels=['site', 'site', 'site'], wspace=.05) plot_grid_time_avg_stats(proj_grids_stats, fignum=1, titles=proj_titles) # this makes three figures #plot_grid_center_stats(proj_grids_stats, fignum=2, titles=prob_titles) # plot two-point correlator w.r.t site corrj g2_titles = [ '$g_2(\sigma^x_{%i},\sigma^x_k;t)$' % corrj, '$g_2(\sigma^y_{%i},\sigma^y_k;t)$' % corrj, '$g_2(\sigma^z_{%i},\sigma^z_k;t)$' % corrj ] plot_grids([x_g2grid, y_g2grid, z_g2grid], fignum=5, titles=g2_titles, suptitle='Two Point Correlator', xlabels=['site', 'site', 'site'], wspace=0.05) plot_grid_time_avg_stats(g2grids_stats, fignum=6, titles=g2_titles) #plot_grid_space_center_stats(g2grids_stats, fignum=7, titles=g2_titles) # plot local and bond entropies entropies = [stj] if 'sbond' in results: stc = results['sbond'][::] entropies.append(stc) if len(entropies) == 2: wspace = 0.088 elif len(entropies) == 1: wspace = -0.23 plot_grids(entropies, titles=[r'$S(j,t)$', r'$S_c(j,t)$'], xlabels=['site', 'cut'], suptitle='von Neumann entropies', wspace=wspace, fignum=10) # plot probabilities of spin down and space/time averages plot_grid_with_avgs(z_grid, fignum=11, suptitle='average probability of measuring 1') # plot mi measures plot_measures(meas_dict, fignum=12) # plot measure Fourier transforms plot_measure_fts(Fmeas_dict, fignum=13) # plot distribution of mutual information over time #plot_edge_strength_contour(mtjk, # bins=60, rng=(0,.1), emax=150, fignum=14) # create the full path to where plots will be saved fname = params['fname'] io.base_name(params['output_dir'], 'plots') path_list = fname.split('/') sub_dir_ind = path_list.index('data') path_list[sub_dir_ind] = 'plots' path_ext_list = '/'.join(path_list).split('.') path_ext_list[-1] = '.pdf' out_fname = ''.join(path_ext_list) # save all figures to one pdf io.multipage(out_fname) results.close() plt.close('all') return out_fname