Skip to content

Commit

Permalink
Merge updates in master into develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
briantoby committed Jan 23, 2025
2 parents 9bbeb6e + cdf2ad7 commit 778d8ca
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ conda:
formats:
- epub
- pdf

sphinx:
# Path to Sphinx configuration file.
configuration: docs/source/conf.py
2 changes: 1 addition & 1 deletion GSASII/GSASIIfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ def readMasks(filename,masks,ignoreThreshold):
S = File.readline()
continue
[key,val] = S.strip().split(':',1)
if key in ['Points','Rings','Arcs','Polygons','Frames','Thresholds']:
if key in ['Points','Rings','Arcs','Polygons','Frames','Thresholds','Xlines','Ylines']:
if ignoreThreshold and key == 'Thresholds':
S = File.readline()
continue
Expand Down
22 changes: 11 additions & 11 deletions GSASII/GSASIIimgGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def GetImageZ(G2frame,data,newRange=False):
Npix,imagefile,imagetag = G2IO.GetCheckImageFile(G2frame,G2frame.Image)
if imagefile is None: return []
formatName = data.get('formatName','')
sumImg = np.array(G2fil.GetImageData(G2frame,imagefile,True,ImageTag=imagetag,FormatName=formatName),dtype='float32')
sumImg = np.array(G2fil.GetImageData(G2frame,imagefile,True,ImageTag=imagetag,FormatName=formatName),dtype=np.float32)
if sumImg is None:
return []
darkImg = False
Expand All @@ -87,9 +87,9 @@ def GetImageZ(G2frame,data,newRange=False):
dformatName = Ddata.get('formatName','')
Npix,darkfile,imagetag = G2IO.GetCheckImageFile(G2frame,Did)
# darkImage = G2fil.GetImageData(G2frame,darkfile,True,ImageTag=imagetag,FormatName=dformatName)
darkImage = np.array(G2fil.GetImageData(G2frame,darkfile,True,ImageTag=imagetag,FormatName=dformatName),dtype='float32')
if darkImg is not None:
sumImg += np.array(darkImage*darkScale,dtype='float32')
darkImage = np.array(G2fil.GetImageData(G2frame,darkfile,True,ImageTag=imagetag,FormatName=dformatName),dtype=np.float32)
if darkImg is not None:
sumImg += np.array(darkImage*darkScale,dtype=np.float32)
else:
print('Warning: resetting dark image (not found: {})'.format(
darkImg))
Expand All @@ -102,11 +102,11 @@ def GetImageZ(G2frame,data,newRange=False):
Npix,backfile,imagetag = G2IO.GetCheckImageFile(G2frame,Bid)
Bdata = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Bid,'Image Controls'))
bformatName = Bdata.get('formatName','')
backImage = np.array(G2fil.GetImageData(G2frame,backfile,True,ImageTag=imagetag,FormatName=bformatName),dtype='float32')
backImage = np.array(G2fil.GetImageData(G2frame,backfile,True,ImageTag=imagetag,FormatName=bformatName),dtype=np.float32)
if darkImg and backImage is not None:
backImage += np.array(darkImage*darkScale/backScale,dtype='float32')
backImage += np.array(darkImage*darkScale/backScale,dtype=np.float32)
if backImage is not None:
sumImg += np.array(backImage*backScale,dtype='float32')
sumImg += np.array(backImage*backScale,dtype=np.float32)
if 'Gain map' in data:
gainMap = data['Gain map']
if gainMap:
Expand All @@ -122,7 +122,8 @@ def GetImageZ(G2frame,data,newRange=False):
Imin = np.min(sumImg)
if 'range' not in data or newRange:
data['range'] = [(Imin,Imax),[Imin,Imax]]
return np.asarray(np.rint(sumImg),dtype='int32')
#return np.asarray(np.rint(sumImg),dtype=np.int32)
return np.array(np.array(np.rint(sumImg),dtype=int),dtype=np.int32) # double-cast removes warning. Why?

def UpdateImageData(G2frame,data):

Expand Down Expand Up @@ -1789,7 +1790,7 @@ def newReplot(*args,**kwargs):
def onDeleteMask(event):
Obj = event.GetEventObject()
typ = Obj.locationcode.split('+')[0]
num = int(Obj.locationcode.split('+')[1])
num = int(Obj.locationcode.split('+')[1])-1 #off by one?
del(data[typ][num])
wx.CallAfter(UpdateMasks,G2frame,data)
G2plt.PlotExposedImage(G2frame,event=event)
Expand Down Expand Up @@ -2013,7 +2014,6 @@ def OnNewRingMask(event):

def OnNewXlineMask(event):
'Start a new x-line mask'
print('x')
G2frame.MaskKey = 'x'
G2plt.OnStartMask(G2frame)

Expand Down Expand Up @@ -2194,7 +2194,7 @@ def OnDelPixMask(event):
def OnAzimuthPlot(event):
GkTheta = chr(0x03f4)
Obj = event.GetEventObject()
ringId = int(Obj.locationcode.split('+')[1])
ringId = int(Obj.locationcode.split('+')[1])-1
Controls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Image Controls'))
image = GetImageZ(G2frame,Controls)
RingInt = G2img.AzimuthIntegrate(image,Controls,data,ringId)
Expand Down
2 changes: 2 additions & 0 deletions GSASII/GSASIIindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ def IndexPeaks(peaks,HKL):
if peak[2]:
if peak[-1] > 0.:
peak[3] = True
if len(peaks) < 7:
return False,peaks #nothing indexed!
if np.any(peaks[4])*np.any(peaks[5])*np.any(peaks[6]):
return True,peaks
else:
Expand Down
2 changes: 1 addition & 1 deletion GSASII/GSASIImath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4655,7 +4655,7 @@ def peakHess(parms,rX,rY,rZ,rho,res,SGLaue):
res = mapData['GridStep']*2.
incre = np.array(rho.shape,dtype=float)
step = max(1.0,1./res)+1
steps = np.array((3*[step,]),dtype='int32')
steps = np.array((3*[step,]),dtype=np.int32)
except KeyError:
G2fil.G2Print ('**** ERROR - Fourier map not defined')
return peaks,mags
Expand Down
2 changes: 1 addition & 1 deletion GSASII/GSASIIpwdGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -9586,7 +9586,7 @@ def OnNoRing(event):
sqBox.Add((1,1),1,wx.EXPAND,1)
sqBox.Add(wx.StaticText(G2frame.dataWindow,label='Rmin: '),0,WACV)
rmin = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,'Rmin',nDig=(5,1),
typeHint=float,size=wx.Size(50,20))
xmin=0.01,typeHint=float,size=wx.Size(50,20))
sqBox.Add(rmin,0,WACV)
sfgSizer.Add(sqBox,0,wx.EXPAND)

Expand Down
10 changes: 5 additions & 5 deletions GSASII/GSASIIscriptable.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def _getCorrImage(ImageReaderlist,proj,imageRef):
sumImg = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
if sumImg is None:
return []
sumImg = np.array(sumImg,dtype='int32')
sumImg = np.array(sumImg,dtype=np.int32)
darkImg = False
if 'dark image' in Controls:
darkImg,darkScale = Controls['dark image']
Expand All @@ -697,7 +697,7 @@ def _getCorrImage(ImageReaderlist,proj,imageRef):
darkImage = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
if darkImg is None:
raise Exception('Error reading dark image {}'.format(imagefile))
sumImg += np.array(darkImage*darkScale,dtype='int32')
sumImg += np.array(darkImage*darkScale,dtype=np.int32)
if 'background image' in Controls:
backImg,backScale = Controls['background image']
if backImg: #ignores any transmission effect in the background image
Expand All @@ -709,9 +709,9 @@ def _getCorrImage(ImageReaderlist,proj,imageRef):
if backImage is None:
raise Exception('Error reading background image {}'.format(imagefile))
if darkImg:
backImage += np.array(darkImage*darkScale/backScale,dtype='int32')
backImage += np.array(darkImage*darkScale/backScale,dtype=np.int32)
else:
sumImg += np.array(backImage*backScale,dtype='int32')
sumImg += np.array(backImage*backScale,dtype=np.int32)
if 'Gain map' in Controls:
gainMap = Controls['Gain map']
if gainMap:
Expand All @@ -726,7 +726,7 @@ def _getCorrImage(ImageReaderlist,proj,imageRef):
sumImg -= int(Controls.get('Flat Bkg',0))
Imax = np.max(sumImg)
Controls['range'] = [(0,Imax),[0,Imax]]
return np.asarray(sumImg,dtype='int32')
return np.asarray(sumImg,dtype=np.int32)

def _constr_type(var):
'''returns the constraint type based on phase/histogram use
Expand Down
1 change: 0 additions & 1 deletion GSASII/GSASIItestplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
'''
import wx
import wx.aui
import matplotlib as mpl
import matplotlib.figure as mplfig
try:
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
Expand Down
31 changes: 26 additions & 5 deletions GSASII/fprime.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,20 @@ def OnChoice2(event):
else:
self.FFxaxis = 'T'
self.UpDateFPlot(self.Wave,rePlot=False)


def OnChoice3(event):
self.Norm = not self.Norm
self.UpDateFPlot(self.Wave,rePlot=False)

self.choice2 = wx.ComboBox(id=wxID_FPRIMECHOICE2, value=' sin('+Gktheta+')/'+Gklambda,
choices=[' sin('+Gktheta+')/'+Gklambda,' 2'+Gktheta,' Q'],
parent=panel, style=wx.CB_READONLY|wx.CB_DROPDOWN)
choiceSizer.Add(self.choice2,0)
self.choice2.Bind(wx.EVT_COMBOBOX, OnChoice2, id=wxID_FPRIMECHOICE2)
self.choice3 = wx.CheckBox(panel,label='Normalize ff by Z')
self.choice3.Bind(wx.EVT_CHECKBOX,OnChoice3)
choiceSizer.Add((10,10),0)
choiceSizer.Add(self.choice3,0)
mainSizer.Add(choiceSizer,0)
mainSizer.Add((10,10),0)
panel.SetSizer(mainSizer)
Expand All @@ -224,7 +232,8 @@ def __init__(self, parent):
self.Lines = []
self.Elems = []
self.linePicked = None

self.Norm = False

def OnFPRIMEExitMenu(self, event):
self.parent.G2plotNB.Delete('Fprime')
self.Close()
Expand Down Expand Up @@ -379,7 +388,10 @@ def UpDateFPlot(self,Wave,rePlot=True):
self.ax.legend(loc='best')
self.Page.figure.subplots_adjust(hspace=0.25)
if self.ifWave:
self.bx.set_title('%s%s%6.4f%s'%('Form factors (',r'$\lambda=$',self.Wave,r'$\AA)$'),x=0,ha='left')
if self.Norm:
self.bx.set_title('%s%s%6.4f%s'%('Normalized form factors (',r'$\lambda=$',self.Wave,r'$\AA)$'),x=0,ha='left')
else:
self.bx.set_title('%s%s%6.4f%s'%('Form factors (',r'$\lambda=$',self.Wave,r'$\AA)$'),x=0,ha='left')
else:
self.bx.set_title('%s%6.2f%s'%('Form factors (E =',self.Energy,'keV)'),x=0,ha='left')
if self.FFxaxis == 'S':
Expand All @@ -391,7 +403,10 @@ def UpDateFPlot(self,Wave,rePlot=True):
else:
self.bxlabel = 'Q, '+Angstr+Pwrm1
self.bx.set_xlabel(r'$Q, \AA$',fontsize=14)
self.bx.set_ylabel("f+f ', e-",fontsize=14)
if self.Norm:
self.bx.set_ylabel("(f+f ')/Z",fontsize=14)
else:
self.bx.set_ylabel("f+f ', e-",fontsize=14)
E = self.Energy
DE = E*self.Eres #smear by defined source resolution
StlMax = min(2.0,math.sin(80.0*math.pi/180.)/Wave)
Expand All @@ -400,7 +415,10 @@ def UpDateFPlot(self,Wave,rePlot=True):
for i,Elem in enumerate(self.Elems):
Els = Elem[0]
Els = Els = Els.ljust(2).lower().capitalize()
Ymax = max(Ymax,Elem[1])
if self.Norm:
Ymax = 0.2
else:
Ymax = max(Ymax,Elem[1])
res1 = G2elem.FPcalc(Elem[3],E+DE)
res2 = G2elem.FPcalc(Elem[3],E-DE)
res = (res1[0]+res2[0])/2.0
Expand All @@ -420,6 +438,9 @@ def UpDateFPlot(self,Wave,rePlot=True):
X.append(360.0*math.asin(S*self.Wave)/math.pi)
else:
X.append(4.0*S*math.pi)
if self.Norm:
ff = [f/Elem[1] for f in ff]
ffo = [f/Elem[1] for f in ffo]
Color = colors[i%6]
Xp = np.array(X)
ffop = np.array(ffo)
Expand Down
2 changes: 1 addition & 1 deletion GSASII/imports/G2img_HDF5.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def Reader(self, filename, ParentFrame=None, **kwarg):
fp.close()
return False
nsel = GSASIIpath.GetConfigValue('HDF5selection',getDefault=True)
self.buffer['selectedImages'] = []
self.buffer['selectedImages'] = list(range(len(self.buffer['imagemap'])))
if ParentFrame and len(self.buffer['imagemap']) > nsel and nsel >= 0:
import wx
from .. import GSASIIctrlGUI as G2G
Expand Down
14 changes: 13 additions & 1 deletion GSASII/tutorialIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@

['Magnetic-V', 'Magnetic-V.htm',"Magnetic Structure Analysis-V",
'''Analysis of a complex Type IV antiferromagnet with two propagation vectorse using Bilbao k-SUBGROUPSMAG from TOF neutron powder data'''],

['k_vec_tutorial', 'k_vec_tutorial.html', 'k-vector searching in GSAS-II #1',
'''Search neutron diffraction data of Er2Ge2O7 for a all-zero magnetic k-vector'''],

['k_vec_tutorial_non_zero', 'k_vec_tutorial_non_zero.html', 'k-vector searching in GSAS-II #2',
'''Search neutron diffraction data used in Magnetic Structure Analysis-III for a non-zero magnetic k-vector'''],

#['ExampleDir', 'ExamplePage.html', 'Example Tutorial Title', '''Example descriptive text'''],

['Parametric sequential fitting'], #######################################################
['SeqRefine', 'SequentialTutorial.htm', 'Sequential refinement of multiple datasets',
Expand Down Expand Up @@ -245,6 +253,10 @@
['ClusterAnalysis','Cluster and Outlier Analysis.htm', 'Cluster and Outlier Analysis',
'''This gives an example of using Cluster and Outlier Analysis with PWDR data.'''],

#['ExampleDir', 'ExamplePage.html', 'Example Tutorial Title', '''Exam'ple descriptive text'''],
['FontSize', 'FontSize.html', 'Changing the GSAS-II Font Size',
'''Configuration variables allow GSAS-II to be customized. In this example the configuration variable that changes the font size
used in the GUI is changed.'''],

#['ExampleDir', 'ExamplePage.html', 'Example Tutorial Title', '''Example descriptive text'''],
)

0 comments on commit 778d8ca

Please sign in to comment.