Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: use maxfev=10000 #94

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/femc_electron/analysis/femc_electron_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def gauss(x, A,mu, sigma):
sigma=np.sqrt(y[slc])+0.5*(y[slc]==0)
p0=(100, p, 3)

coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
#res=np.abs(coeff[2]/coeff[1])
if p==50:
xx=np.linspace(15*p/20,22*p/20, 100)
Expand All @@ -151,7 +151,7 @@ def gauss(x, A,mu, sigma):
plt.errorbar(pvals, 100*np.array(res), 100*np.array(dres), ls='', marker='o')
fnc = lambda E, a, b: np.hypot(a,b/np.sqrt(E))
p0=(.05, .12)
coeff, var_matrix = curve_fit(fnc, pvals, res, p0=p0,sigma=dres)
coeff, var_matrix = curve_fit(fnc, pvals, res, p0=p0, sigma=dres, maxfev=10000)
xx=np.linspace(7, 85, 100)
plt.plot(xx, 100*fnc(xx,*coeff), label=f'fit:{100*coeff[0]:.1f}%$\\oplus\\frac{{{100*coeff[1]:.0f}\\%}}{{\\sqrt{{E}}}}$')
plt.legend()
Expand Down Expand Up @@ -190,7 +190,7 @@ def gauss(x, A,mu, sigma):
p0=(100, p, 3)

try:
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
if abs(coeff[1])>100 or np.sqrt(var_matrix[1][1])>100:
continue
pvals.append(p)
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/femc_photon/analysis/femc_photon_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def gauss(x, A,mu, sigma):
sigma=np.sqrt(y[slc])+0.5*(y[slc]==0)
p0=(100, p, 3)

coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
#res=np.abs(coeff[2]/coeff[1])
if p==50:
xx=np.linspace(15*p/20,22*p/20, 100)
Expand All @@ -150,7 +150,7 @@ def gauss(x, A,mu, sigma):
plt.errorbar(pvals, 100*np.array(res), 100*np.array(dres), ls='', marker='o')
fnc = lambda E, a, b: np.hypot(a,b/np.sqrt(E))
p0=(.05, .12)
coeff, var_matrix = curve_fit(fnc, pvals, res, p0=p0,sigma=dres)
coeff, var_matrix = curve_fit(fnc, pvals, res, p0=p0, sigma=dres, maxfev=10000)
xx=np.linspace(7, 85, 100)
plt.plot(xx, 100*fnc(xx,*coeff), label=f'fit:{100*coeff[0]:.1f}%$\\oplus\\frac{{{100*coeff[1]:.0f}\\%}}{{\\sqrt{{E}}}}$')
plt.legend()
Expand Down Expand Up @@ -188,7 +188,7 @@ def gauss(x, A,mu, sigma):
sigma=np.sqrt(y[slc])+0.5*(y[slc]==0)
p0=(100, p, 3)
try:
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
if abs(coeff[1])>100 or np.sqrt(var_matrix[1][1])>100:
continue
pvals.append(p)
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/femc_pi0/analysis/femc_pi0_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def gauss(x, A,mu, sigma):
sigma=np.sqrt(y[slc])+0.5*(y[slc]==0)
p0=(100, p, 3)

coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
#res=np.abs(coeff[2]/coeff[1])
if p==50:
xx=np.linspace(15*p/20,22*p/20, 100)
Expand All @@ -186,7 +186,7 @@ def gauss(x, A,mu, sigma):
plt.errorbar(pvals, 100*np.array(res), 100*np.array(dres), ls='', marker='o')
fnc = lambda E, a, b: np.hypot(a,b/np.sqrt(E))
p0=(.05, .12)
coeff, var_matrix = curve_fit(fnc, pvals, res, p0=p0,sigma=dres)
coeff, var_matrix = curve_fit(fnc, pvals, res, p0=p0, sigma=dres, maxfev=10000)
xx=np.linspace(15, 85, 100)
plt.plot(xx, 100*fnc(xx,*coeff), label=f'fit:{100*coeff[0]:.1f}%$\\oplus\\frac{{{100*coeff[1]:.0f}\\%}}{{\\sqrt{{E}}}}$')
plt.legend()
Expand Down Expand Up @@ -225,7 +225,7 @@ def gauss(x, A,mu, sigma):
p0=(100, p, 3)

try:
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
if abs(coeff[1])>100 or np.sqrt(var_matrix[1][1])>100:
continue
pvals.append(p)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/insert_muon/analysis/muon_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def Landau(x, normalization,location,stdev):
p0=[100, .5, .05]
#print(list(y), list(x))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
print(coeff)
xx=np.linspace(0,.7, 100)
MIP=coeff[1]/1000
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/insert_neutron/analysis/neutron_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def gauss(x, A,mu, sigma):
fnc=gauss
sigma=np.sqrt(y[slc])+(y[slc]==0)
p0=(100, 0, 5)
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
xx=np.linspace(-5,5,100)
plt.plot(xx,fnc(xx,*coeff))
# except:
Expand All @@ -104,7 +104,7 @@ def gauss(x, A,mu, sigma):
#print(bc[slc],y[slc])
sigma=np.sqrt(y[slc])+(y[slc]==0)
try:
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
sigmas.append(np.abs(coeff[2]))
dsigmas.append(np.sqrt(var_matrix[2][2]))
xvals.append(p)
Expand Down Expand Up @@ -151,7 +151,7 @@ def gauss(x, A,mu, sigma):
sigma=np.sqrt(y[slc])+0.5*(y[slc]==0)
p0=(100, np.mean(r), np.std(r))
try:
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
res=np.abs(coeff[2]/coeff[1])

if res<best_res:
Expand Down Expand Up @@ -234,7 +234,7 @@ def gauss(x, A,mu, sigma):
sigma=np.sqrt(y[slc])+0.5*(y[slc]==0)
p0=(100, np.mean(r), np.std(r))
try:
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bcs[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
res=np.abs(coeff[2]/coeff[1])

if res<best_res:
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/zdc_lambda/analysis/lambda_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def gauss(x, A,mu, sigma):
fnc=gauss
p0=[100, 0, 0.05]
coeff, var_matrix = curve_fit(fnc, bc[slc], y[slc], p0=p0,
sigma=np.sqrt(y[slc])+(y[slc]==0))
sigma=np.sqrt(y[slc])+(y[slc]==0), maxfev=10000)
x=np.linspace(-1, 1)
plt.plot(x, gauss(x, *coeff), color='tab:orange')
plt.xlabel("$\\theta^{*\\rm recon}_{\\Lambda}-\\theta^{*\\rm truth}_{\\Lambda}$ [mrad]")
Expand All @@ -214,7 +214,7 @@ def gauss(x, A,mu, sigma):
#print(bc[slc],y[slc])
sigma=np.sqrt(y[slc])+(y[slc]==0)
try:
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
sigmas.append(coeff[2])
dsigmas.append(np.sqrt(var_matrix[2][2]))
xvals.append(p)
Expand Down Expand Up @@ -259,7 +259,7 @@ def gauss(x, A,mu, sigma):
fnc=gauss
p0=[100, 0, 1]
coeff, var_matrix = curve_fit(fnc, bc[slc], y[slc], p0=p0,
sigma=np.sqrt(y[slc])+(y[slc]==0))
sigma=np.sqrt(y[slc])+(y[slc]==0), maxfev=10000)
x=np.linspace(-5, 5)
plt.plot(x, gauss(x, *coeff), color='tab:orange')
print(coeff[2], np.sqrt(var_matrix[2][2]))
Expand All @@ -284,7 +284,7 @@ def gauss(x, A,mu, sigma):
#print(bc[slc],y[slc])
sigma=np.sqrt(y[slc])+(y[slc]==0)
try:
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,sigma=list(sigma))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
sigmas.append(coeff[2])
dsigmas.append(np.sqrt(var_matrix[2][2]))
xvals.append(p)
Expand Down Expand Up @@ -327,7 +327,7 @@ def gauss(x, A,mu, sigma):
fnc=gauss
p0=[100, lambda_mass, 0.04]
coeff, var_matrix = curve_fit(fnc, bc[slc], y[slc], p0=p0,
sigma=np.sqrt(y[slc])+(y[slc]==0))
sigma=np.sqrt(y[slc])+(y[slc]==0), maxfev=10000)
x=np.linspace(0.8, 1.3, 200)
plt.plot(x, gauss(x, *coeff), color='tab:orange')
print(coeff[2], np.sqrt(var_matrix[2][2]))
Expand All @@ -350,7 +350,7 @@ def gauss(x, A,mu, sigma):
p0=[100, lambda_mass, 0.05]
try:
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
x=np.linspace(0.8, 1.3, 200)
sigmas.append(coeff[2])
dsigmas.append(np.sqrt(var_matrix[2][2]))
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/zdc_photon/analysis/zdc_photon_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def gauss(x, A,mu, sigma):
p0=[100, p, 10]
#print(list(y), list(x))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
if p==100:
xx=np.linspace(p*0.75,p*1.25, 100)
plt.plot(xx, fnc(xx,*coeff))
Expand All @@ -78,7 +78,7 @@ def gauss(x, A,mu, sigma):
fnc=lambda E,a: a/np.sqrt(E)
#pvals, resvals, dresvals
coeff, var_matrix = curve_fit(fnc, pvals, resvals, p0=(1,),
sigma=dresvals)
sigma=dresvals, maxfev=10000)

xx=np.linspace(15, 275, 100)
plt.plot(xx, fnc(xx, *coeff), label=f'fit: $\\frac{{{coeff[0]*100:.0f}\\%}}{{\\sqrt{{E}}}}$')
Expand Down Expand Up @@ -129,7 +129,7 @@ def gauss(x, A,mu, sigma):
p0=[100, 0, 0.1]
#print(list(y), list(x))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
if p==100:
xx=np.linspace(-0.5,0.5, 100)
plt.plot(xx, fnc(xx,*coeff))
Expand All @@ -143,7 +143,7 @@ def gauss(x, A,mu, sigma):
fnc=lambda E,a, b: np.hypot(a/np.sqrt(E), b)
#pvals, resvals, dresvals
coeff, var_matrix = curve_fit(fnc, pvals, resvals, p0=(1,.1),
sigma=dresvals)
sigma=dresvals, maxfev=10000)

xx=np.linspace(15, 275, 100)

Expand Down
12 changes: 6 additions & 6 deletions benchmarks/zdc_pi0/analysis/zdc_pi0_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def gauss(x, A,mu, sigma):
p0=[100, p, 10]
#print(list(y), list(x))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
if p==100:
xx=np.linspace(p*0.5,p*1.5, 100)
plt.plot(xx, fnc(xx,*coeff))
Expand All @@ -76,7 +76,7 @@ def gauss(x, A,mu, sigma):
fnc=lambda E,a: a/np.sqrt(E)
#pvals, resvals, dresvals
coeff, var_matrix = curve_fit(fnc, pvals, resvals, p0=(1,),
sigma=dresvals)
sigma=dresvals, maxfev=10000)
xx=np.linspace(55, 200, 100)
plt.plot(xx, fnc(xx, *coeff), label=f'fit: $\\frac{{{coeff[0]:.2f}\\%}}{{\\sqrt{{E}}}}$')
plt.legend()
Expand Down Expand Up @@ -133,7 +133,7 @@ def gauss(x, A,mu, sigma):
p0=[100, 0, 0.1]
#print(list(y), list(x))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
if p==100:
xx=np.linspace(-0.5,0.5, 100)
plt.plot(xx, fnc(xx,*coeff))
Expand All @@ -148,7 +148,7 @@ def gauss(x, A,mu, sigma):
fnc=lambda E,a: a/np.sqrt(E)
#pvals, resvals, dresvals
coeff, var_matrix = curve_fit(fnc, pvals, resvals, p0=(1,),
sigma=dresvals)
sigma=dresvals, maxfev=10000)

xx=np.linspace(55, 200, 100)

Expand Down Expand Up @@ -201,7 +201,7 @@ def gauss(x, A,mu, sigma):
p0=[100, .135, 0.2]
#print(list(y), list(x))
coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0,
sigma=list(np.sqrt(y[slc])+(y[slc]==0)))
sigma=list(np.sqrt(y[slc])+(y[slc]==0)), maxfev=10000)
if p==100:
xx=np.linspace(0,0.2)
plt.plot(xx, fnc(xx,*coeff))
Expand All @@ -218,7 +218,7 @@ def gauss(x, A,mu, sigma):
fnc=lambda E,a,b: a+b*E
#pvals, resvals, dresvals
coeff, var_matrix = curve_fit(fnc, pvals, resvals, p0=(1,1),
sigma=dresvals)
sigma=dresvals, maxfev=10000)
xx=np.linspace(55, 200, 100)
#plt.plot(xx, fnc(xx, *coeff), label=f'fit: ${coeff[0]*1000:.1f}+{coeff[1]*1000:.4f}\\times E$ MeV')
plt.plot(xx, fnc(xx, *coeff), label=f'fit: $({coeff[0]*1000:.1f}+{coeff[1]*1000:.4f}\\times [E\,in\,GeV])$ MeV')
Expand Down