Skip to content

Commit 0535a4d

Browse files
committed
better catches for hyperbolas in image processing
1 parent 406ee58 commit 0535a4d

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

GSASII/GSASIIimage.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def ellipseCalcD(B,xyd,varyList,parmDict,keyArray=None,progressDlg=None):
234234
fminus = d*tanb*stth/(cosb-stth)
235235
vplus = d*(tanb+(1+tbm)/(1-tbm))*stth/(cosb+stth)
236236
vminus = d*(tanb+(1-tbp)/(1+tbp))*stth/(cosb-stth)
237+
if np.all(vplus+vminus < 0.):
238+
return 0.
237239
R0 = np.sqrt((vplus+vminus)**2-(fplus+fminus)**2)/2. #+minor axis
238240
R1 = (vplus+vminus)/2. #major axis
239241
zdis = (fplus-fminus)/2.
@@ -283,7 +285,6 @@ def CalibPrint(ValSig,chisq,Npts):
283285
print (ptstr)
284286
print (sigstr)
285287

286-
print(rings)
287288
names = ['dist','det-X','det-Y','tilt','phi','dep','wave','sag']
288289
fmt = ['%12.3f','%12.3f','%12.3f','%12.3f','%12.3f','%12.4f','%12.6f','%12.4f']
289290
Fmt = dict(zip(names,fmt))
@@ -481,18 +482,18 @@ def GetEllipse2(tth,dxy,dist,cent,tilt,phi):
481482
tbp = tand((tth+tilt)/2.)
482483
sinb = sind(tilt)
483484
d = dist+dxy
484-
if tth+abs(tilt) < 90.: #ellipse
485-
fplus = d*tanb*stth/(cosb+stth)
486-
fminus = d*tanb*stth/(cosb-stth)
487-
vplus = d*(tanb+(1+tbm)/(1-tbm))*stth/(cosb+stth)
488-
vminus = d*(tanb+(1-tbp)/(1+tbp))*stth/(cosb-stth)
485+
fplus = d*tanb*stth/(cosb+stth)
486+
fminus = d*tanb*stth/(cosb-stth)
487+
vplus = d*(tanb+(1+tbm)/(1-tbm))*stth/(cosb+stth)
488+
vminus = d*(tanb+(1-tbp)/(1+tbp))*stth/(cosb-stth)
489+
if vplus+vminus > 0.: #ellipse
489490
radii[0] = np.sqrt((vplus+vminus)**2-(fplus+fminus)**2)/2. #+minor axis
490491
radii[1] = (vplus+vminus)/2. #major axis
491492
radii[2] = tth #save for ellipse; might be useful
492493
zdis = (fplus-fminus)/2.
493494
else: #hyperbola!
494495
f = d*abs(tanb)*stth/(cosb+stth)
495-
v = d*(abs(tanb)+tand(tth-abs(tilt)))
496+
v = abs(d*(abs(tanb)+tand(tth-abs(tilt))))
496497
delt = d*stth*(1.+stth*cosb)/(abs(sinb)*cosb*(stth+cosb))
497498
eps = (v-f)/(delt-v)
498499
radii[0] = -eps*(delt-f)/np.sqrt(eps**2-1.) #-minor axis
@@ -1733,6 +1734,7 @@ def IntStrSta(Image,StrSta,Controls):
17331734
RXA = np.array(ringxy)
17341735
MRXA = np.array([rxa if (0.<=rxa[0]<=xyLim[0] and 0.<=rxa[1]<=xyLim[1]) else [0.,0.,0.] for rxa in RXA])
17351736
Th,Azm,G = GetTthAzmG(MRXA.T[0],MRXA.T[1],Controls)
1737+
Azm[0] = np.array([azm if azm < 180. else azm-360. for azm in Azm[0]])
17361738
pola = G2pwd.Polarization(Controls['PolaVal'][0],Th,Azm-90.)[0] #get pola not dpola
17371739
ring['ImxyCalc'] = MRXA[:2]
17381740
ringixy = [[int(x*scalex),int(y*scaley)] for y,x in MRXA[:,:2]]

0 commit comments

Comments
 (0)