Skip to content

Commit b0f8703

Browse files
committed
Merge remote-tracking branch 'origin/main' into kvec_isodistort_zyp
so that it is ready to merge into main as a FF
2 parents b8a0849 + d996e4b commit b0f8703

25 files changed

+280
-170
lines changed

GSASII/GSASIIctrlGUI.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import random as ran
3232
import numpy as np
3333

34-
import matplotlib as mpl
34+
#import matplotlib as mpl
3535
try:
3636
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
3737
except ImportError:
@@ -47,7 +47,7 @@
4747
from . import GSASIIpwd as G2pwd
4848
from . import GSASIIlattice as G2lat
4949
from . import GSASIImath as G2mth
50-
from . import GSASIIstrMain as G2stMn
50+
#from . import GSASIIstrMain as G2stMn
5151
from . import GSASIImiscGUI as G2IO
5252
from .tutorialIndex import tutorialIndex
5353
if sys.version_info[0] >= 3:
@@ -5042,7 +5042,7 @@ def SetContents(self,parent):
50425042
if parent.hisNum != '*' and name.split(':')[1] != parent.hisNum: continue
50435043
if (parent.varName != ' ') and (parent.varName not in name): continue
50445044
self.varList.append(name)
5045-
oldlen = self.GetItemCount()
5045+
#oldlen = self.GetItemCount()
50465046
self.SetItemCount(len(self.varList))
50475047

50485048
def OnRowSelected(self, event, row=None):
@@ -6025,7 +6025,7 @@ def copy2clip(event):
60256025
msg += f"\n\n * For {key} use cite:\n"
60266026
msg += GetCite(key,wrap=95,indent=6)
60276027
msg += '\n\nNote that your citations are one of the strongest ways you can say thank you to the\nscientists who make their software available to you.'
6028-
res = ShowScrolledInfo(parent,msg,header='Please Cite',
6028+
ShowScrolledInfo(parent,msg,header='Please Cite',
60296029
buttonlist=[
60306030
('Close', lambda event: event.GetEventObject().GetParent().EndModal(wx.ID_OK)),
60316031
('Copy to clipboard', copy2clip),
@@ -6283,7 +6283,7 @@ def copyURL(event):
62836283
# place HTML title into window title
62846284
dlg.wv.Bind(wx.EVT_UPDATE_UI, lambda event:
62856285
dlg.SetTitle(dlg.wv.GetCurrentTitle()))
6286-
lastWebView = dlg.wv
6286+
#lastWebView = dlg.wv
62876287
sizer.Add(dlg.wv,1,wx.EXPAND)
62886288
# row of buttons & URL label on bottom of window
62896289
bsizer=wx.BoxSizer(wx.HORIZONTAL)
@@ -7349,7 +7349,7 @@ class gitVersionSelector(wx.Dialog):
73497349
from a git repository
73507350
'''
73517351
def __init__(self,parent=None):
7352-
import git
7352+
#import git
73537353
self.g2repo = GSASIIpath.openGitRepo(path2GSAS2)
73547354
self.githistory = GSASIIpath.gitHistory('hash',self.g2repo)
73557355
# patch Feb 2024: don't allow access to versions that are too old
@@ -7492,7 +7492,7 @@ def docCommit(self,commit):
74927492
74937493
:returns: a multi-line string
74947494
'''
7495-
import datetime
7495+
#import datetime
74967496
fmtdate = lambda c:"{:%d-%b-%Y %H:%M}".format(c.committed_datetime)
74977497
commit = self.g2repo.commit(commit) # converts a hash, if supplied
74987498
msg = f'git {commit.hexsha[:10]} from {fmtdate(commit)}'
@@ -9397,6 +9397,15 @@ def askQuestion(parent,question,title):
93979397
dlg.Destroy()
93989398
return ans
93999399

9400+
def haveGUI():
9401+
'''Test if there is a GUI that can be accessed
9402+
:returns: True if a GUI is available
9403+
'''
9404+
try:
9405+
return wx.App.IsMainLoopRunning()
9406+
except:
9407+
return False
9408+
94009409
#===========================================================================
94019410
def gitFetch(G2frame):
94029411
wx.BeginBusyCursor()
@@ -9832,7 +9841,7 @@ def gitSwitchMaster2Main():
98329841
98339842
See web page GSASII.github.io for information on how to install GSAS-II.
98349843
'''
9835-
res = ShowScrolledInfo(G2frame,msg,header='Please Note',
9844+
ShowScrolledInfo(G2frame,msg,header='Please Note',
98369845
height=250)
98379846
return
98389847

@@ -9941,13 +9950,13 @@ def gitSwitchMaster2Main():
99419950
if script and sys.platform.startswith('darwin'):
99429951
print(f'running {script}')
99439952
import subprocess
9944-
out = subprocess.run([sys.executable,script],cwd=GSASIIpath.path2GSAS2)
9953+
subprocess.run([sys.executable,script],cwd=GSASIIpath.path2GSAS2)
99459954
# On windows make a batch file with hard-coded paths to Python and GSAS-II
99469955
elif script and sys.platform.startswith('win'):
99479956
script = os.path.normpath(os.path.join(GSASIIpath.path2GSAS2,'install',s))
99489957
print(f'running {script!r}')
99499958
import subprocess
9950-
out = subprocess.run([sys.executable,script],cwd=GSASIIpath.path2GSAS2)
9959+
subprocess.run([sys.executable,script],cwd=GSASIIpath.path2GSAS2)
99519960
# On linux, make a desktop icon with hard-coded paths to Python and GSAS-II
99529961
elif script:
99539962
sys.argv = [script]

GSASII/GSASIIdataGUI.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def TestOldVersions():
551551
warnmsg = ''
552552
errmsg = ''
553553
for s,m in [('Python',None), ('wx',wx), ('matplotlib', mpl), ('numpy',np),
554-
('scipy',sp), ('OpenGL',ogl)]:
554+
('scipy',sp), ('OpenGL',ogl)]:
555555
if s == 'Python':
556556
pkgver = platform.python_version()
557557
prefix = ''
@@ -7158,8 +7158,8 @@ def _makemenu(): # routine to create menu when first used
71587158
G2G.Define_wxId('wxID_ATOMSEDITADD', 'wxID_ATOMSEDITINSERT', 'wxID_ATOMSEDITDELETE',
71597159
'wxID_ATOMSMODIFY', 'wxID_ATOMSTRANSFORM', 'wxID_ATOMSVIEWADD', 'wxID_ATOMVIEWINSERT',
71607160
'wxID_RELOADDRAWATOMS', 'wxID_ATOMSDISAGL', 'wxID_ATOMMOVE', 'wxID_MAKEMOLECULE',
7161-
'wxID_ATOMSPDISAGL', 'wxID_ISODISP', 'wxID_ADDHATOM', 'wxID_UPDATEHATOM',
7162-
'wxID_ATOMSROTATE', 'wxID_ATOMSDENSITY','wxID_ATOMSBNDANGLHIST',
7161+
'wxID_ATOMSPDISAGL', 'wxID_ISODISP', 'wxID_ADDHATOM', 'wxID_UPDATEHATOM','wxID_ATOMSCLEARHIST',
7162+
'wxID_ATOMSROTATE', 'wxID_ATOMSDENSITY','wxID_ATOMSBNDANGLHIST','wxID_ATOMSSAVEHIST',
71637163
'wxID_ATOMSSETALL', 'wxID_ATOMSSETSEL','wxID_ATOMFRACSPLIT','wxID_COLLECTATOMS',
71647164
'wxID_ATOMSSETVP', 'wxID_ATOMSSETLST')
71657165
self.AtomsMenu = wx.MenuBar()
@@ -7201,6 +7201,8 @@ def _makemenu(): # routine to create menu when first used
72017201
self.AtomCompute.Append(G2G.wxID_ATOMSDISAGL,'Show Distances && Angles','Compute distances & angles for selected atoms')
72027202
self.AtomCompute.Append(G2G.wxID_ATOMSPDISAGL,'Save Distances && Angles','Compute distances & angles for selected atoms')
72037203
self.AtomCompute.Append(G2G.wxID_ATOMSBNDANGLHIST,'Histogram Bonds && Angles','Histogram bonds & angles for selected atoms')
7204+
self.AtomCompute.Append(G2G.wxID_ATOMSSAVEHIST,'Save all B&&A histograms','Save all bond & angle histograms')
7205+
self.AtomCompute.Append(G2G.wxID_ATOMSCLEARHIST,'Clear all B&&A histograms','Clear all bond & angle histograms')
72047206
self.AtomCompute.Append(G2G.wxID_ATOMFRACSPLIT,'Apportion atom frac','2 atom type site fraction apportion')
72057207
self.AtomCompute.Append(G2G.wxID_ATOMSDENSITY,'Density','Compute density for current phase')
72067208
self.AtomCompute.ISOcalc = self.AtomCompute.Append(G2G.wxID_ISODISP,'ISODISTORT mode values',

GSASII/GSASIIimage.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,10 +1239,9 @@ def polymask(data,Poly,Spots=[]):
12391239
ax0 = figure.add_subplot()
12401240
ax0.axis("off")
12411241
figure.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.)
1242-
for poly in Poly:
1243-
px = np.array(poly).T[0]/scalex
1244-
py = np.array(poly).T[1]/scaley
1245-
ax0.fill(px,py,inmask)
1242+
px = np.array(Poly).T[0]/scalex
1243+
py = np.array(Poly).T[1]/scaley
1244+
ax0.fill(px,py,inmask)
12461245
for spot in Spots:
12471246
px = np.array(spot).T[0]/scalex
12481247
py = np.array(spot).T[1]/scaley
@@ -1271,21 +1270,14 @@ def MakeMaskMap(data,masks,iLim,jLim):
12711270
pixelSize = data['pixelSize']
12721271
scalex = pixelSize[0]/1000.
12731272
scaley = pixelSize[1]/1000.
1274-
frame = []
1275-
poly = []
1273+
frame = np.zeros(data['size'],dtype='uint8')
1274+
poly = np.zeros(data['size'],dtype='uint8')
12761275
if iLim[0] == jLim[0] == 0:
12771276
if masks['Frames']:
12781277
frame = np.abs(polymask(data,masks['Frames'])-255) #turn inner to outer mask
12791278
if masks['Polygons'] or masks['Points']:
12801279
poly = polymask(data,masks['Polygons'],masks['Points'])
1281-
if len(frame):
1282-
masks['Pmask'] = frame
1283-
if len(poly):
1284-
masks['Pmask'] = masks['Pmask']+poly
1285-
if len(poly):
1286-
masks['Pmask'] = poly
1287-
else:
1288-
masks['Pmask'] = []
1280+
masks['Pmask'] = frame+poly
12891281
tay,tax = np.mgrid[iLim[0]+0.5:iLim[1]+.5,jLim[0]+.5:jLim[1]+.5] #bin centers not corners
12901282
tax = np.asarray(tax*scalex,dtype=np.float32).flatten()
12911283
tay = np.asarray(tay*scaley,dtype=np.float32).flatten()
@@ -1426,8 +1418,7 @@ def MakeUseMask(data,masks,blkSize=128):
14261418
return useMask
14271419

14281420
def MakeGainMap(image,Ix,Iy,data,mask,blkSize=128):
1429-
Iy /= npcosd(Ix[:-1]) #undo parallax
1430-
Iy *= (1000./data['distance'])**2 #undo r^2 effect
1421+
Iy *= npcosd(Ix[:-1])**2 #undo parallax
14311422
Iy /= np.array(G2pwd.Polarization(data['PolaVal'][0],Ix[:-1],0.)[0]) #undo polarization
14321423
if data['Oblique'][1]:
14331424
Iy *= G2pwd.Oblique(data['Oblique'][0],Ix[:-1]) #undo penetration
@@ -1645,8 +1636,7 @@ def ImageIntegrate(image,data,masks,blkSize=128,returnN=False,useTA=None,useMask
16451636
if 'SASD' not in data['type']:
16461637
H0 *= np.array(G2pwd.Polarization(data['PolaVal'][0],H2[:-1],0.)[0])
16471638
if np.abs(data['det2theta']) < 1.0: #small angle approx only; not appropriate for detectors at large 2-theta
1648-
H0 /= np.abs(npcosd(H2[:-1]-np.abs(data['det2theta']))) #parallax correction
1649-
# H0 *= (data['distance']/1000.)**2 #remove r^2 effect - done earlier
1639+
H0 /= np.abs(npcosd(H2[:-1]-np.abs(data['det2theta'])))**4 #parallax correction (why **4?)
16501640
if 'SASD' in data['type']:
16511641
H0 /= npcosd(H2[:-1]) #one more for small angle scattering data?
16521642
if data['Oblique'][1]:

GSASII/GSASIIimgGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ def CleanupMasks(data):
18541854
and before saving them or after reading them in. This should also probably be done
18551855
before they are used for integration.
18561856
'''
1857-
for key in ['Points','Rings','Arcs','Polygons',]:
1857+
for key in ['Points','Rings','Arcs','Polygons','Frames',]:
18581858
data[key] = data.get(key,[])
18591859
l1 = len(data[key])
18601860
data[key] = [i for i in data[key] if len(i)]

GSASII/GSASIImiscGUI.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,8 @@ def ExportSequentialFullCIF(G2frame,seqData,Controls):
978978
'''Handles access to CIF exporter a bit differently for sequential fits, as this is
979979
not accessed via the usual export menus
980980
'''
981-
from exports import G2export_CIF
981+
from . import exports
982+
from GSASII.exports import G2export_CIF
982983
##################### debug code to reload exporter before each use ####
983984
#import importlib as imp
984985
#imp.reload(G2export_CIF)

GSASII/GSASIIpath.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,22 @@ def HowIsG2Installed():
210210
def getSavedVersionInfo():
211211
'''Get version number information from a file written by install
212212
routines. This is faster than getting the information from git. Also,
213-
when GSAS-II is installed into Python, the files are no longer in
214-
a git repository so querying git is not possible.
213+
when GSAS-II is installed into Python, files are no longer in
214+
a git repository, so querying git is not possible.
215215
216-
The saved_version.py file is written by install/save_versions.py.
217-
The git_verinfo.py file is written by install/tag-version.py or
218-
by install/incr-mini-version.py. If both are present, use the
219-
saved_version.py file preferentially.
216+
The git_verinfo.py file is written by install/incr-version.py or
217+
by install/save_versions.py
218+
The saved_version.py file was previousl written by
219+
install/save_versions.py but this file is no longer in use.
220220
221221
:returns: a reference to the version variables or None if no
222222
version info file is found.
223223
'''
224-
try:
225-
from . import saved_version as gv
226-
return gv
227-
except:
228-
pass
224+
# try:
225+
# from . import saved_version as gv
226+
# return gv
227+
# except:
228+
# pass
229229
try:
230230
from . import git_verinfo as gv
231231
return gv

0 commit comments

Comments
 (0)