Skip to content

Commit 604ee59

Browse files
committed
fix problems in G2DDataGUI
1 parent d517b2d commit 604ee59

File tree

7 files changed

+55
-38
lines changed

7 files changed

+55
-38
lines changed

GSASII/GSASIIElem.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,8 @@ def SetupGeneral(data, dirname):
920920
F000X += generalData['NoAtoms'][elem]*generalData['Z']
921921
isotope = generalData['Isotope'][elem]
922922
F000N += generalData['NoAtoms'][elem]*generalData['Isotopes'][elem][isotope]['SL'][0]
923+
if elem.strip() in ['D','T']:
924+
elem = 'H'
923925
F000E += generalData['NoAtoms'][elem]*ScatFac(EFFtables[StripValence(elem)],0.)[0]
924926
generalData['F000X'] = F000X
925927
generalData['F000N'] = F000N

GSASII/GSASIIdataGUI.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8055,13 +8055,13 @@ def OnPlotAll3DHKL(event):
80558055
G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName)
80568056

80578057
def OnPlotFoVsFc(event):
8058-
''' Plots Fo-Fc vs Fc for single crystal data '''
8058+
''' Plots Fo-Fc & 1/ExtC vs Fc for single crystal data '''
80598059
refList = data[1]['RefList']
80608060
XY = np.array([xy[8+Super:10+Super] for xy in refList if xy[3+Super]>0])
8061+
XE = np.array([[np.sqrt(xy[9+Super]),1./xy[11+Super]] for xy in refList if xy[3+Super]>0]).T
80618062
XY = np.sqrt(np.abs(XY)).T
8062-
FcMax = np.max(XY[1])
8063-
G2plt.PlotXY(G2frame,[[XY[1],XY[0]-XY[1]],],XY2=[[[0.,FcMax],[0.,0.]],],labelX='|Fc|',labelY='|Fo|-|Fc|',newPlot=False,
8064-
Title='|Fo|-|Fc| vs |Fc|',lines=False)
8063+
G2plt.PlotXY(G2frame,[[XY[1],XY[0]-XY[1]],],XY2=[XE,],labelX='|Fc|',labelY='|Fo|-|Fc|, 1/ExtC',newPlot=False,
8064+
Title='|Fo|-|Fc| vs |Fc|',lines=False,points2=True,names=['|Fo|-|Fc|',],names2=['1/ExtC',])
80658065

80668066
def OnMergeHKL(event):
80678067
'''Merge HKLF data sets to unique set according to Laue symmetry'''

GSASII/GSASIIddataGUI.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,12 @@ def ExtVal(Ekey,valSizer,fmt,lim):
630630
Ekey = ['Eg',]
631631
else:
632632
Ekey = ['Eg','Es']
633-
extSizer.Add(ExtVal(Ekey,val2Sizer,'g',[0.,1.]),0)
633+
extSizer.Add(ExtVal(Ekey,val2Sizer,'g',[0.,100.]),0)
634634
extSizer.Add(wx.StaticText(DData,label=' Small F dynamical scattering correction:'))
635635
val3Sizer =wx.BoxSizer(wx.HORIZONTAL)
636-
Ekey = ['Ma','Mb']
637-
extSizer.Add(ExtVal(Ekey,val3Sizer,'f',[-100.,100.]),0,)
636+
if 'Primary' in UseList[G2frame.hist]['Extinction'][1]:
637+
Ekey = ['Ma','Mb',]
638+
extSizer.Add(ExtVal(Ekey,val3Sizer,'f',[-1.,10.]),0,)
638639
else: #PWDR
639640
extSizer = wx.BoxSizer(wx.HORIZONTAL)
640641
extRef = wx.CheckBox(DData,wx.ID_ANY,label=' Extinction: ')
@@ -918,23 +919,25 @@ def OnFixVals(event):
918919
#patch
919920
if 'Use' not in UseList[G2frame.hist]:
920921
UseList[G2frame.hist]['Use'] = True
921-
if 'LeBail' not in UseList[G2frame.hist]:
922-
UseList[G2frame.hist]['LeBail'] = False
923922
if 'Babinet' not in UseList[G2frame.hist]:
924923
UseList[G2frame.hist]['Babinet'] = {'BabA':[0.0,False],'BabU':[0.0,False]}
925924
if 'Fix FXU' not in UseList[G2frame.hist]:
926925
UseList[G2frame.hist]['Fix FXU'] = ' '
927926
if 'FixedSeqVars' not in UseList[G2frame.hist]:
928927
UseList[G2frame.hist]['FixedSeqVars'] = []
929-
if 'Flack' not in UseList[G2frame.hist]:
930-
UseList[G2frame.hist]['Flack'] = [0.0,False]
931-
if 'Twins' not in UseList[G2frame.hist]:
932-
UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
933-
if 'Layer Disp' not in UseList[G2frame.hist]:
934-
UseList[G2frame.hist]['Layer Disp'] = [0.0,False]
935-
if 'Ma' not in UseList[G2frame.hist]['Extinction'][2]:
936-
UseList[G2frame.hist]['Extinction'][2].update({'Ma':[1.0,False]})
937-
UseList[G2frame.hist]['Extinction'][2].update({'Mb':[0.0,False]})
928+
if 'HKLF' in UseList[G2frame.hist]['Histogram']:
929+
if 'Flack' not in UseList[G2frame.hist]:
930+
UseList[G2frame.hist]['Flack'] = [0.0,False]
931+
if 'Twins' not in UseList[G2frame.hist]:
932+
UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
933+
if 'Ma' not in UseList[G2frame.hist]['Extinction'][2]:
934+
UseList[G2frame.hist]['Extinction'][2].update({'Ma':[1.0,False]})
935+
UseList[G2frame.hist]['Extinction'][2].update({'Mb':[0.0,False]})
936+
elif 'PWDR' in UseList[G2frame.hist]['Histogram']:
937+
if 'LeBail' not in UseList[G2frame.hist]:
938+
UseList[G2frame.hist]['LeBail'] = False
939+
if 'Layer Disp' not in UseList[G2frame.hist]:
940+
UseList[G2frame.hist]['Layer Disp'] = [0.0,False]
938941
#end patch
939942
ifkeV = 'E' in UseList[G2frame.hist].get('Type','')
940943
offMsg = ''

GSASII/GSASIIplot.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ def OnMotion(event):
24402440

24412441
#### PlotXY ##################################################################
24422442
def PlotXY(G2frame,XY,XY2=[],labelX='X',labelY='Y',newPlot=False,
2443-
Title='',lines=False,names=[],names2=[],vertLines=[]):
2443+
Title='',lines=False,points2=False,names=[],names2=[],vertLines=[]):
24442444
'''simple plot of xy data
24452445
24462446
:param wx.Frame G2frame: The main GSAS-II tree "window"
@@ -2451,6 +2451,7 @@ def PlotXY(G2frame,XY,XY2=[],labelX='X',labelY='Y',newPlot=False,
24512451
:param bool newPlot: =True if new plot is to be made
24522452
:param str Title: title for plot
24532453
:param bool lines: = True if lines desired for XY plot; XY2 always plotted as lines
2454+
:param bool points2: = False if XY2 is plotted as points despite lines
24542455
:param list names: legend names for each XY plot as list a of str values
24552456
:param list names2: legend names for each XY2 plot as list a of str values
24562457
:param list vertLines: lists of vertical line x-positions; can be one for each XY
@@ -2526,12 +2527,18 @@ def Draw():
25262527
X,Y = XY2[ixy]
25272528
dX = Page.Offset[0]*(ixy+1)*Xmax/500.
25282529
dY = Page.Offset[1]*(ixy+1)*Ymax/100.
2529-
if len(names2):
2530-
Plot.plot(X+dX,Y+dY,colors[(ixy+1)%NC],picker=False,label=names2[ixy])
2531-
else:
2532-
Plot.plot(X+dX,Y+dY,colors[(ixy+1)%NC],picker=False)
2533-
if len(names):
2534-
Plot.legend(names,loc='best')
2530+
if points2:
2531+
if len(names2):
2532+
Plot.scatter(X,Y,marker='+',color=colors[(ixy+1)%NC],picker=False,label=names2[ixy])
2533+
else:
2534+
Plot.scatter(X,Y,marker='+',color=colors[(ixy+1)%NC],picker=False)
2535+
else:
2536+
if len(names2):
2537+
Plot.plot(X+dX,Y+dY,colors[(ixy+1)%NC],picker=False,label=names2[ixy])
2538+
else:
2539+
Plot.plot(X+dX,Y+dY,colors[(ixy+1)%NC],picker=False)
2540+
if len(names)+len(names2):
2541+
Plot.legend(names+names2,loc='best')
25352542
if not newPlot:
25362543
Page.toolbar.push_current()
25372544
Plot.set_xlim(xylim[0])

GSASII/GSASIIpwdGUI.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@ def Draw():
25052505
################################################################################
25062506

25072507
def UpdateInstrumentGrid(G2frame,data):
2508-
'''respond to selection of PWDR/SASD/REFD Instrument Parameters
2508+
'''respond to selection of PWDR/SASD/REFD/HKLF Instrument Parameters
25092509
data tree item.
25102510
'''
25112511
if 'Bank' not in data: #get it from name; absent for default parms selection
@@ -2692,16 +2692,15 @@ def OnSave(event):
26922692
item: writes current parameters to a .instprm file
26932693
It does not write Bank n: on # line & thus can be used any time w/o clash of bank nos.
26942694
2695-
note: doesn't currently write extedened instrument parameters i.e. pdabc dictionary
2695+
note: doesn't currently write extended instrument parameters i.e. pdabc dictionary
26962696
'''
26972697
pth = G2G.GetExportPath(G2frame)
26982698
dlg = wx.FileDialog(G2frame, 'Set name to save GSAS-II instrument parameters file', pth, '',
26992699
'instrument parameter files (*.instprm)|*.instprm',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
27002700
try:
27012701
if dlg.ShowModal() == wx.ID_OK:
27022702
Sample = G2frame.GPXtree.GetItemPyData(
2703-
G2gd.GetGPXtreeItemId(G2frame, G2frame.PatternId,
2704-
'Sample Parameters'))
2703+
G2gd.GetGPXtreeItemId(G2frame, G2frame.PatternId,'Sample Parameters'))
27052704
filename = dlg.GetPath()
27062705
# make sure extension is .instprm
27072706
filename = os.path.splitext(filename)[0]+'.instprm'
@@ -2841,7 +2840,7 @@ def AfterChange(invalid,value,tc):
28412840
G2plt.PlotPeakWidths(G2frame)
28422841

28432842
def AfterChangeEC(invalid,value,tc):
2844-
'''for SEC data only; converts electrn energy in keV to wavelength
2843+
'''for SEC data only; converts electron energy in keV to wavelength
28452844
'''
28462845
if invalid: return
28472846
if value > 10.:
@@ -2902,13 +2901,15 @@ def OnLamPick(event):
29022901
insVal['Type'] = 'SXC'
29032902
except KeyError:
29042903
if 'synch' in lamType:
2905-
insVal['Lam'] = 1.0 #typical?
2904+
insVal['Lam'] = 1.0 #obvious incorrect default
29062905
data['Type'][0] = 'SXC'
29072906
insVal['Type'] = 'SXC'
29082907
elif 'micro' in lamType:
2909-
insVal['Lam'] = 0.0251 # @200keV
2910-
data['Type'][0] = 'SEC'
2911-
insVal['Type'] = 'SEC' #change to electron diffraction
2908+
insVal['Lam'] = 0.025079 # @200keV
2909+
data['Type'][0] = 'SEC' #change to electron diffraction
2910+
insVal['Type'] = 'SEC' # in 3 places!
2911+
Pattern = G2frame.GPXtree.GetItemPyData(G2frame.PatternId)
2912+
Pattern[0]['Type'] = 'SEC'
29122913
updateData(insVal,insRef)
29132914
wx.CallAfter(UpdateInstrumentGrid,G2frame,data)
29142915

GSASII/GSASIIstrMath.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ def SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varyList):
27512751
DScorr = 1.0
27522752
if 'Primary' in calcControls[phfx+'EType']:
27532753
PLZ *= 1.5
2754-
DScorr = parmDict[phfx+'Ma']*np.exp(-np.sqrt(ref[9+im])*parmDict[phfx+'Mb'])+1.0
2754+
DScorr = 1.+parmDict[phfx+'Ma']*ref[4+im]+parmDict[phfx+'Mb']*ref[4+im]**2
27552755
else:
27562756
if 'C' in parmDict[hfx+'Type']:
27572757
PLZ *= calcControls[phfx+'Tbar']
@@ -2788,9 +2788,13 @@ def SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varyList):
27882788

27892789
dervCor = (1.+PF)*PF3 #extinction corr for other derivatives
27902790
if 'Primary' in calcControls[phfx+'EType']:
2791-
extCor *= DScorr
27922791
if phfx+'Ep' in varyList:
2793-
dervDict[phfx+'Ep'] = -ref[7+im]*PLZ*PF3
2792+
dervDict[phfx+'Ep'] = -ref[7+im]*PLZ*PF3*DScorr
2793+
if phfx+'Ma' in varyList:
2794+
dervDict[phfx+'Ma'] = -extCor*ref[4+im]
2795+
if phfx+'Mb' in varyList:
2796+
dervDict[phfx+'Mb'] = -extCor*ref[4+im]**2
2797+
extCor *= DScorr
27942798
if 'II' in calcControls[phfx+'EType'] and phfx+'Es' in varyList:
27952799
dervDict[phfx+'Es'] = -ref[7+im]*PLZ*PF3*(PSIG/parmDict[phfx+'Es'])**3
27962800
if 'I' in calcControls[phfx+'EType'] and phfx+'Eg' in varyList:

GSASII/testDeriv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test2(name,delt,doProfile):
231231
G2stMth.errRefine(self.values,self.HistoPhases,
232232
self.parmDict,{},self.varylist,self.calcControls,
233233
self.pawleyLookup,None)
234-
dMdV = G2stMth.dervRefine(self.values,self.HistoPhases,self.parmDict,
234+
dMdV = G2stMth.dervRefine(self.values,self.HistoPhases,self.parmDict,{},
235235
self.names,self.calcControls,self.pawleyLookup,None)
236236
if doProfile and self.timingOn:
237237
pr.disable()

0 commit comments

Comments
 (0)