fixed a BAD bug that was setting to zero everything that was < 5% of the max in the images (i.e. the profile was calculated based on the internal copy used for fit instead of the original image)

This commit is contained in:
Marco Cammarata 2016-11-25 18:05:50 +01:00
parent eb1e2b4ce8
commit 1bfbc9f51e
1 changed files with 6 additions and 3 deletions

View File

@ -81,7 +81,7 @@ fit_ret = collections.namedtuple("fit_ret",["init_pars","final_pars",\
"final_transform1","final_transform2","im1","im2","E","p1","p1_sum","p2","p2_sum","fom","ratio","tneeded"] ) "final_transform1","final_transform2","im1","im2","E","p1","p1_sum","p2","p2_sum","fom","ratio","tneeded"] )
def calcFOM(p1,p2,ratio): def calcFOM(p1,p2,ratio):
idx = ( p1>p1.max()/10 ) & (p2>p2.max()/10) idx = ( p1>p1.max()/10 )# & (p2>p2.max()/10)
ratio = ratio[idx] ratio = ratio[idx]
return ratio.std()/ratio.mean() return ratio.std()/ratio.mean()
@ -142,13 +142,13 @@ def plotShot(im1,im2,transf1=None,transf2=None,fig=None,ax=None,res=None,E=defau
if res is None: if res is None:
p1 = np.nansum(im1,axis=0) p1 = np.nansum(im1,axis=0)
p2 = np.nansum(im2,axis=0) p2 = np.nansum(im2,axis=0)
pr = p1/p2 pr = p2/p1
else: else:
p1 = res.p1; p2 = res.p2; pr = res.ratio p1 = res.p1; p2 = res.p2; pr = res.ratio
ax[3].plot(E,p1,lw=3) ax[3].plot(E,p1,lw=3)
ax[4].plot(E,p1,lw=1) ax[4].plot(E,p1,lw=1)
ax[4].plot(E,p2,lw=3) ax[4].plot(E,p2,lw=3)
idx = (p1>p1.max()/10.) & (p2>p2.max()/10) idx = (p1>p1.max()/10.)
ax[5].plot(E[idx],pr[idx]) ax[5].plot(E[idx],pr[idx])
if res is not None: if res is not None:
ax[5].set_title("FOM: %.2f"%res.fom) ax[5].set_title("FOM: %.2f"%res.fom)
@ -427,6 +427,9 @@ def transformIminuit(im1,im2,init_transform=dict(),show=False,verbose=True,zeroT
final_params = imin.fitarg.copy() final_params = imin.fitarg.copy()
t1,t2 = transforms(*imin.args) t1,t2 = transforms(*imin.args)
i1,i2 = model(*imin.args) i1,i2 = model(*imin.args)
i1 = t1.transformImage(im1)
i2 = t2.transformImage(im2)
if show: if show:
plotShot(i1,i2) plotShot(i1,i2)
fig = plt.gcf() fig = plt.gcf()