Loading pysen/revision.py +4 −4 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ PySEN revision module """ import sys __version__ = "0.34-devel" __release__ = "20170518" __date__ = "May 18, 2017" __version__ = "0.40-devel" __release__ = "20170829" __date__ = "Aug 29, 2017" # VERSION = __version__ RELEASE = __release__ Loading @@ -18,7 +18,7 @@ Version: %s Date: %s""" % (VERSION, DATE) # LICENCE = "BSD License Version 2.0" COPYRIGHT = "(C) 2012-2016 Piotr Zolnierczuk, Forschungszentrum Juelich GmbH" COPYRIGHT = "(C) 2012-2017 Piotr Zolnierczuk, Forschungszentrum Juelich GmbH" WEBSITE = "http://www.fz-juelich.de/jcns" EMAIL = "dasneutron@gmail.com" AUTHORS = ["Piotr A. Zolnierczuk (p.zolnierczuk@fz-juelich.de)", ] Loading scripts/plot_transmission.py +27 −15 Original line number Diff line number Diff line Loading @@ -21,20 +21,23 @@ def run(filenames, args, spectrum_only=False): plt.subplot(2,1,1) dlam = args.dlam lw = 3 for filename in filenames: lw = 2 for i, filename in enumerate(filenames): data = read_transmission(filename) pcharge = data['proton_charge'] counts = np.asarray(data["detector array"])/float(pcharge) counts = np.asarray(data["detector array"]) ecounts = np.sqrt(counts) lmax = data['wavelength']/ANGSTROM sample = data['sample'] wlen = np.linspace(lmax-dlam, lmax, len(counts)) #wlen = 0.5*(wlen[1:]+wlen[:-1]) wlen = wlen[args.tmin:args.tmax] cnts = counts[args.tmin:args.tmax] plt.step(wlen, cnts, where='mid', label = sample, lw=lw) tcounts[sample] = (wlen, cnts) lw = 1 cnts = counts[args.tmin:args.tmax]/float(pcharge) ecnts = ecounts[args.tmin:args.tmax]/float(pcharge) p = plt.step(wlen, cnts, where='mid', label = sample, lw=lw) color = p[0].get_color() plt.errorbar(wlen, cnts, yerr=ecnts, fmt='.', color=color, ms=0.01, lw=0.5) tcounts[(i,sample)] = (wlen, cnts, ecnts) lw = 1.0 plt.title(data['proposal']) plt.ylabel('Counts/PCharge') plt.grid(True) Loading @@ -44,16 +47,25 @@ def run(filenames, args, spectrum_only=False): return plt.subplot(2,1,2) _,(w0,c0) = tcounts.popitem(last=False) for s,(w,c) in list(tcounts.items()): _,(w0,c0,e0) = tcounts.popitem(last=False) for (_,s),(w,c,e) in list(tcounts.items()): if args.echodet: tfac = c0/c else: tfac = c/c0 tavg = np.average(tfac) print("%s: %g" % (s, np.average(tfac))) plt.step(w, tfac, where='mid', label = "%s T=%.3f" % (s,tavg)) efac = tfac * np.sqrt((e0/c0)**2 + (e/c)**2) tavg = np.average(tfac, weights=1.0/efac) etavg = np.sqrt(np.average((tavg-tfac)**2, weights=1.0/efac)) print("%-20.20s %.4g +/- %.4g" % (s, tavg, etavg)) p = plt.step(w, tfac, where='mid', label = "%s T=%.3f" % (s,tavg)) color=p[0].get_color() plt.errorbar(w, tfac, yerr=efac, fmt='.', color=color, ms=0.01, lw=1.0) plt.axhline(tavg, color=color, ls='--', lw=0.5) #plt.ylim(ymin=0.95, ymax=1.05) plt.xlabel(r'Neutron Wavelength [$\AA$]') if args.echodet: plt.ylabel('T0/Tsam') else: plt.ylabel('Tsam/T0') plt.grid(True) plt.legend() Loading Loading
pysen/revision.py +4 −4 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ PySEN revision module """ import sys __version__ = "0.34-devel" __release__ = "20170518" __date__ = "May 18, 2017" __version__ = "0.40-devel" __release__ = "20170829" __date__ = "Aug 29, 2017" # VERSION = __version__ RELEASE = __release__ Loading @@ -18,7 +18,7 @@ Version: %s Date: %s""" % (VERSION, DATE) # LICENCE = "BSD License Version 2.0" COPYRIGHT = "(C) 2012-2016 Piotr Zolnierczuk, Forschungszentrum Juelich GmbH" COPYRIGHT = "(C) 2012-2017 Piotr Zolnierczuk, Forschungszentrum Juelich GmbH" WEBSITE = "http://www.fz-juelich.de/jcns" EMAIL = "dasneutron@gmail.com" AUTHORS = ["Piotr A. Zolnierczuk (p.zolnierczuk@fz-juelich.de)", ] Loading
scripts/plot_transmission.py +27 −15 Original line number Diff line number Diff line Loading @@ -21,20 +21,23 @@ def run(filenames, args, spectrum_only=False): plt.subplot(2,1,1) dlam = args.dlam lw = 3 for filename in filenames: lw = 2 for i, filename in enumerate(filenames): data = read_transmission(filename) pcharge = data['proton_charge'] counts = np.asarray(data["detector array"])/float(pcharge) counts = np.asarray(data["detector array"]) ecounts = np.sqrt(counts) lmax = data['wavelength']/ANGSTROM sample = data['sample'] wlen = np.linspace(lmax-dlam, lmax, len(counts)) #wlen = 0.5*(wlen[1:]+wlen[:-1]) wlen = wlen[args.tmin:args.tmax] cnts = counts[args.tmin:args.tmax] plt.step(wlen, cnts, where='mid', label = sample, lw=lw) tcounts[sample] = (wlen, cnts) lw = 1 cnts = counts[args.tmin:args.tmax]/float(pcharge) ecnts = ecounts[args.tmin:args.tmax]/float(pcharge) p = plt.step(wlen, cnts, where='mid', label = sample, lw=lw) color = p[0].get_color() plt.errorbar(wlen, cnts, yerr=ecnts, fmt='.', color=color, ms=0.01, lw=0.5) tcounts[(i,sample)] = (wlen, cnts, ecnts) lw = 1.0 plt.title(data['proposal']) plt.ylabel('Counts/PCharge') plt.grid(True) Loading @@ -44,16 +47,25 @@ def run(filenames, args, spectrum_only=False): return plt.subplot(2,1,2) _,(w0,c0) = tcounts.popitem(last=False) for s,(w,c) in list(tcounts.items()): _,(w0,c0,e0) = tcounts.popitem(last=False) for (_,s),(w,c,e) in list(tcounts.items()): if args.echodet: tfac = c0/c else: tfac = c/c0 tavg = np.average(tfac) print("%s: %g" % (s, np.average(tfac))) plt.step(w, tfac, where='mid', label = "%s T=%.3f" % (s,tavg)) efac = tfac * np.sqrt((e0/c0)**2 + (e/c)**2) tavg = np.average(tfac, weights=1.0/efac) etavg = np.sqrt(np.average((tavg-tfac)**2, weights=1.0/efac)) print("%-20.20s %.4g +/- %.4g" % (s, tavg, etavg)) p = plt.step(w, tfac, where='mid', label = "%s T=%.3f" % (s,tavg)) color=p[0].get_color() plt.errorbar(w, tfac, yerr=efac, fmt='.', color=color, ms=0.01, lw=1.0) plt.axhline(tavg, color=color, ls='--', lw=0.5) #plt.ylim(ymin=0.95, ymax=1.05) plt.xlabel(r'Neutron Wavelength [$\AA$]') if args.echodet: plt.ylabel('T0/Tsam') else: plt.ylabel('Tsam/T0') plt.grid(True) plt.legend() Loading