# been supplied. has_theory = False if radius != None and viscosity != None: diffusion_theory = bmc.theoretical(radius, viscosity, temperature) has_theory = True # Open pickle files and compute the weigted means. info_dicts = [] for arg in args: with open(os.path.abspath(arg)) as pkl: info_dicts.append(cPickle.load(pkl)) ave_diffusion = get_diffusion(info_dicts, 'ave') fit_diffusion = get_diffusion(info_dicts, 'fit') ave_diffusion, err_ave_diffusion = bmc.mean_with_err(*ave_diffusion) fit_diffusion, err_fit_diffusion = bmc.mean_with_err(*fit_diffusion) if outfile != None: diffusion = dict() diffusion['diffusion'] = fit_diffusion diffusion['uncertainty'] = err_fit_diffusion print 'Saving diffusion coefficient to', outfile + '.' with open(outfile, 'w') as pkl: cPickle.dump(diffusion, pkl) # Print some results. print if has_theory: print 'Particle radius:', radius, 'm' print 'Viscosity: %g Ps' % viscosity
if len(args) == 0: print 'No input pickles supplied.' usage(1) # Open pickle files and compute the weigted means. info_dicts = [] for arg in args: with open(os.path.abspath(arg)) as pkl: info_dicts.append(cPickle.load(pkl)) # Compute the mean RMS velocity vrms = get_values(info_dicts, 'vel_rms') work = get_values(info_dicts, 'mean_work') work_rate = get_values(info_dicts, 'work_rate') ave_vrms, err_vrms = bmc.mean_with_err(*vrms) ave_work, err_work = bmc.mean_with_err(*work) ave_work_rate, err_work_rate = bmc.mean_with_err(*work_rate) atp_energy = 0.4 * 20.5 / spc.N_A num_myosin = ave_work / atp_energy err_myosin = err_work / atp_energy print 'RMS speed:', ave_vrms, 'm/s' print 'Uncertainty:', err_vrms, 'm/s' print print 'Average work:', ave_work, 'J' print 'Uncertainty:', err_work, 'J' print print 'Average number of myosin motors:', num_myosin print 'Uncertainty:', err_myosin
if radius != None and viscosity != None: diffusion_theory = bmc.theoretical(radius, viscosity, temperature) has_theory = True # Open and read the data file. all_tracks = bmc.read_data(data_file) # Only accept tracks where there is displacement in each step. all_tracks = filter(lambda t: all(t[6][1:]), all_tracks) nparticles = len(all_tracks) # Compute the diffusions. time_step = 0.0330033 # The time step isn't recorded uniformly. all_diffusion = map(get_diffusion_ave(time_step), all_tracks) diff_list = [d[0] for d in all_diffusion] diff_err_list = [d[1] for d in all_diffusion] diffusion, err_diffusion = bmc.mean_with_err(diff_list, diff_err_list) # Create average displacements and fit a curve ave_dispsq = bmc.average_dispsq(all_tracks, 50) num_avg = len(ave_dispsq[0]) time = np.linspace(1, num_avg, num_avg) * time_step popt, pcov = spo.curve_fit(linear, time, ave_dispsq[0], sigma=ave_dispsq[1]) fit_data = popt[0] * time + popt[1] fit_diff = popt[0] / 4.0 fit_err = np.sqrt(pcov[0][0]) / 4.0 axis_bounds = [min(time), max(time)] axis_bounds += [0, max(max(fit_data), max(ave_dispsq[0]))] # Create a dictionary to save to and save it to a pickle. if pkl_file != None: brownian_info = dict()