Open main menu

Changes

Matplotlib disp spin.out

1,067 bytes added, 14:22, 13 March 2014
== Code ==
<source lang="python">
import sysimport numpy as npimport matplotlib.pyplot as plt # Exit if no *.out fileif len(sys.argv) != 2: print ("helleoYou have to provide a input .out file") sys.exit() infile = sys.argv[1]print("Input file is: %s"%infile) # Get index of filewith open(infile, 'r') as f: for line in f: if line.startswith('# Experiment_name'): fileindex = line.split()[1:] # Remove not allowed lettersfileindex = [w.replace('(', '') for w in fileindex]fileindex = [w.replace(')', '') for w in fileindex]fileindex = [w.replace('.', '') for w in fileindex] # Prepare to define what file exist offdtype="S20"for item in fileindex[1:]: fdtype += ",f8" print("Fileindex is: %s"%fileindex)print("Value types are: %s"%fdtype) data = np.genfromtxt(fname=infile, dtype=fdtype, names=fileindex) xval = data[fileindex[2]]R2eff_meas = data[fileindex[3]]R2eff_meas_err = data[fileindex[5]]R2eff_calc = data[fileindex[4]] calc_not_avail = np.isnan(R2eff_calc[0]) plt.figure()plt.errorbar(xval, R2eff_meas, yerr=R2eff_meas_err, label=fileindex[3], fmt='o')
</source>
python -i testmatplotlib.py disp_theta_13_N.out
</source>
 
== See also ==
[[Category:Matplotlib]]
Trusted, Bureaucrats
1,382

edits