Z = float(f[2:]) if f[:3] == 'it=': it = int(f[3:]) Ef = float(Ef) print 'Z =', Z, 'Ef =', Ef, 'it =', it testname = 'data/sim/denssim-Z=%g-N=500-Nfa=3.6-Ef=%g-it=%d.npz' %(Z,Ef,it+1) if os.path.isfile(testname): sys.exit('THIS IS NOT THE FINAL ITERATION!') Emax = Emax0 Emin = Emin0 Espace0 = np.linspace(Emin,Emax,N0) Espace = np.array(Espace0) dos0 = odedirac.doscalc(Espace0, r, U, mlist) dos = np.array(dos0) ipeak = dos0[itest,:].argmax() while (Emax - Emin)/N0 > threshold: if ipeak > 0: Emin = Espace[ipeak - 1] else: Emin = Espace[0] if ipeak < len(Espace) - 1: Emax = Espace[ipeak + 1] else: Emax = Espace[-1] Espace = np.linspace(Emin,Emax,N0) dos = odedirac.doscalc(Espace, r, U, mlist) ipeak = dos[itest,:].argmax() if abs(Emin-Emin0)<1e-7 or abs(Emax-Emax0)<1e-7:
for i in range(0, len(its)): Epeak = peaks[i] Ef = Efs[i] it = its[i] simdata = np.load( 'data/sim/denssim-Z=%g-N=500-Nfa=3.6-Ef=%g-it=%d.npz' % (Z, Ef, it)) U = simdata['U'] r = simdata['r'] itest = abs(r - rtest).argmin() height = heights[i][itest] normE = np.linspace(0.1, 4.0, 1000) trueE = normE * Epeak normdos = odedirac.doscalc(trueE, r, U, mlist)[itest, :] / height print 'Z =', Z, 'Ef =', Ef bnds = [] bnds.append((0.9, 1.1)) # peak amplitude bnds.append((0.9, 1.1)) # peak position bnds.append((0.1, 1.5)) # peak width bnds.append((0.2, 1.2)) # envelope E scaling bnds.append((0.01, 2.0 * normdos[-1])) # bg height bnds.append((0.5, 5.0)) # bg E scaling bnds = tuple(bnds) start = [[1.0, 1.0, 1.0, 0.5, 1.5 * normdos[-1], 1.5]] fit, params = lfit.peakfit(normE, normdos, 1, bnds, start)
hts = [] hfs = [] for i in range(0, len(its)): Epeak = peaks[i] Ef = Efs[i] it = its[i] simdata = np.load("data/sim/denssim-Z=%g-N=500-Nfa=3.6-Ef=%g-it=%d.npz" % (Z, Ef, it)) U = simdata["U"] r = simdata["r"] itest = abs(r - rtest).argmin() height = heights[i][itest] normE = np.linspace(0.1, 4.0, 1000) trueE = normE * Epeak normdos = odedirac.doscalc(trueE, r, U, mlist)[itest, :] / height print "Z =", Z, "Ef =", Ef bnds = [] bnds.append((0.9, 1.1)) # peak amplitude bnds.append((0.9, 1.1)) # peak position bnds.append((0.1, 1.5)) # peak width bnds.append((0.2, 1.2)) # envelope E scaling bnds.append((0.01, 2.0 * normdos[-1])) # bg height bnds.append((0.5, 5.0)) # bg E scaling bnds = tuple(bnds) start = [[1.0, 1.0, 1.0, 0.5, 1.5 * normdos[-1], 1.5]] fit, params = lfit.peakfit(normE, normdos, 1, bnds, start)