Skip to content

Commit 4c15f5c

Browse files
committed
fix problems in image sum operation
improvements to deformation math
1 parent 51942df commit 4c15f5c

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

GSASII/GSASIIdataGUI.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3609,13 +3609,15 @@ def OnImageSum(self,event):
36093609
DataList = []
36103610
IdList = []
36113611
Names = []
3612+
Items = []
36123613
Comments = ['Sum equals: \n']
36133614
if self.GPXtree.GetCount():
36143615
item, cookie = self.GPXtree.GetFirstChild(self.root)
36153616
while item:
36163617
name = self.GPXtree.GetItemText(item)
36173618
Names.append(name)
36183619
if 'IMG' in name:
3620+
Items.append(item)
36193621
TextList.append(name)
36203622
DataList.append(self.GPXtree.GetImageLoc(item)) #Size,Image,Tag
36213623
IdList.append(item)
@@ -3627,14 +3629,28 @@ def OnImageSum(self,event):
36273629
TextList.append('default_sum_name')
36283630
dlg = self.SumDialog(self,'Sum data',' Enter scale for each image to be summed','IMG',
36293631
TextList,DataList)
3632+
chkItems = ['pixelSize','wavelength','distance','center','size','tilt','rotation']
36303633
try:
36313634
if dlg.ShowModal() == wx.ID_OK:
36323635
imSize = 0
36333636
result,scales = dlg.GetData()
36343637
First = True
36353638
Found = False
3636-
for name,scale in zip(result,scales):
3639+
for item,name,scale in zip(Items,result,scales):
36373640
if scale:
3641+
if not Found:
3642+
Data = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self,item,'Image Controls'))
3643+
chkData = {Id:Data[Id] for Id in chkItems}
3644+
else:
3645+
data = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self,item,'Image Controls'))
3646+
chkdata = {Id:data[Id] for Id in chkItems}
3647+
if str(chkdata) != str(chkData):
3648+
self.ErrorDialog('Image Controls error','Images to be summed must have same Image Controls - see Console for list')
3649+
chkDiff = [[iD,chkData[iD],chkdata[iD]] for iD in chkData if str(chkData[iD]) != str(chkdata[iD])]
3650+
print('Differences: ')
3651+
for diff in chkDiff:
3652+
print('%s: %s %s'%(diff[0],str(diff[1]),str(diff[2])))
3653+
return
36383654
Found = True
36393655
Comments.append("%10.3f %s" % (scale,' * '+name))
36403656
i = TextList.index(name)

GSASII/GSASIIlattice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2896,7 +2896,8 @@ def H2ThPh2(H,Bmat):
28962896
'''
28972897
Hcart = np.inner(H,Bmat)
28982898
R = np.sqrt(np.sum(np.square(Hcart),axis=1))
2899-
Pl = acosd(Hcart[:,2]/R)
2899+
Hcart /= R[:,nxs]
2900+
Pl = acosd(Hcart[:,2])
29002901
Az = atan2d(Hcart[:,1],Hcart[:,0])
29012902
return R,Az,Pl
29022903

GSASII/GSASIIstrMath.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,15 @@ def MakePolar(Orient,QB):
449449
QA = G2mth.invQ(Orient) #rotates about chosen axis
450450
Q = G2mth.prodQQ(QB,QA) #might be switched? QB,QA is order for plotting
451451
M = np.inner(G2mth.Q2Mat(Q),Bmat)
452-
return G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),M)
452+
return G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),M)[1:]
453453

454454
dFFdS = {}
455455
atFlg = []
456-
Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),Bmat)
456+
R,Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),Bmat)
457457
SQR = np.repeat(SQ,HKL.shape[1])
458458
for iAt,Atype in enumerate(Tdata):
459459
if 'Q' in Atype:
460-
Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),Bmat)
460+
R,Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),Bmat)
461461
atFlg.append(1.0)
462462
SHdat = SHCdict[iAt]
463463
symAxis = np.array(SHdat['symAxis'])

0 commit comments

Comments
 (0)