Skip to content

Commit 9db660f

Browse files
committed
Merge remote-tracking branch 'origin/main' into MAXIV-HDF5
to bring up to date for additional work
2 parents c0fc558 + fbc65e0 commit 9db660f

File tree

354 files changed

+75845
-5653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

354 files changed

+75845
-5653
lines changed

.github/workflows/update_help.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: xfer help info from GSAS-II docs repo
2+
# This updates the help file to match the contents of the MDhelp directory
3+
# in the GSAS-II-tutorials repo. It is triggered from the builddocsite.yml
4+
# workflow in the GSAS-II-tutorials repo.
5+
6+
on:
7+
repository_dispatch: # run from Web API
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
pages: write
14+
15+
jobs:
16+
build: # Build web pages
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Checkout
24+
# get the help pages from GSAS-II docs repo
25+
uses: actions/checkout@v4
26+
with:
27+
repository: AdvancedPhotonSource/GSAS-II-tutorials.git
28+
path: _docs
29+
ref: main
30+
31+
- name: Python setup
32+
uses: actions/setup-python@v3
33+
34+
- name: mkdocs setup
35+
run: |
36+
pip install mkdocs mkdocs-material python-markdown-math mkdocs-static-i18n
37+
pip install mkdocs-to-pdf pymdown-extensions
38+
39+
# MD help conversion
40+
- name: convert MDhelp
41+
run: |
42+
pwd
43+
cd _docs/MDhelp
44+
mkdocs build
45+
python findMDanchors.py # create an anchor index
46+
rm -rf ../../GSASII/help/assets/javascripts/
47+
rm -rf ../../GSASII/help/assets/stylesheets/
48+
cp -vr site/* ../../GSASII/help
49+
cd ../../GSASII/help
50+
pwd
51+
ls -lt
52+
53+
- name: git diagnostics
54+
run: |
55+
pwd
56+
git status
57+
git diff
58+
git add GSASII/help
59+
echo "After add"
60+
git status
61+
62+
- name: commit changes
63+
run: |
64+
git add GSASII/help
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
git commit -m"update help files"
68+
69+
- name: push help into repo
70+
run: |
71+
git push

GSASII/GSASIIElem.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def GetFFtable(atomTypes):
8989

9090
def GetEFFtable(atomTypes):
9191
''' returns a dictionary of electron form factor data for atom types found in atomTypes
92-
might not be needed?
9392
9493
:param list atomTypes: list of atom types
9594
:return: FFtable, dictionary of form factor data; key is atom type
@@ -242,6 +241,14 @@ def CheckElement(El):
242241
return True
243242
else:
244243
return False
244+
def StripValence(El):
245+
'Returns element symbol without valence'
246+
if '+' in El:
247+
return El.split('+')[0]
248+
elif '-' in El:
249+
return El.split('-')[0]
250+
else:
251+
return El
245252

246253
def FixValence(El):
247254
'Returns the element symbol, even when a valence is present'
@@ -906,12 +913,17 @@ def SetupGeneral(data, dirname):
906913

907914
F000X = 0.
908915
F000N = 0.
916+
F000E = 0.
917+
ElTypes = [StripValence(elem) for elem in generalData['AtomTypes']]
918+
EFFtables = GetEFFtable(ElTypes) # broken for charged species
909919
for i,elem in enumerate(generalData['AtomTypes']):
910920
F000X += generalData['NoAtoms'][elem]*generalData['Z']
911921
isotope = generalData['Isotope'][elem]
912922
F000N += generalData['NoAtoms'][elem]*generalData['Isotopes'][elem][isotope]['SL'][0]
923+
F000E += generalData['NoAtoms'][elem]*ScatFac(EFFtables[StripValence(elem)],0.)[0]
913924
generalData['F000X'] = F000X
914925
generalData['F000N'] = F000N
926+
generalData['F000E'] = F000E
915927
generalData['Mass'] = G2mth.getMass(generalData)
916928

917929
if badList:

GSASII/GSASIIGUI.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ def MacOpenFiles(self, filenames):
6666
application = wx.App(0) # create the GUI framework
6767
try:
6868
GSASIIpath.SetBinaryPath(True)
69-
except:
70-
print('Unable to run with current installation, please reset or reinstall')
69+
except Exception as msg:
70+
print(
71+
'''Unable to run with current installation due to lack of binary (compiled)
72+
files, please reset or reinstall''')
73+
print('\nError:')
74+
print(msg)
7175
# if GSASIIpath.HowIsG2Installed().startswith('git'):
7276
# print('use this command w/gitstrap')
77+
7378
sys.exit()
7479
# print('Unable to run with current setup, do you want to update to the')
7580
# try:

GSASII/GSASIIconstrGUI.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -266,56 +266,65 @@ class ConstraintDialog(wx.Dialog):
266266
'''
267267
def __init__(self,parent,title,text,data,separator='*',varname="",varyflag=False):
268268
wx.Dialog.__init__(self,parent,-1,'Edit '+title,
269-
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
269+
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
270270
self.data = data[:]
271271
self.newvar = [varname,varyflag]
272-
panel = wx.Panel(self)
273272
mainSizer = wx.BoxSizer(wx.VERTICAL)
274-
topLabl = wx.StaticText(panel,-1,text)
275-
mainSizer.Add((10,10),1)
276-
mainSizer.Add(topLabl,0,wx.LEFT,10)
277-
mainSizer.Add((10,10),1)
273+
self.SetSizer(mainSizer)
274+
topLabl = wx.StaticText(self,-1,text) # top label
275+
# bottom buttons
276+
self.OkBtn = wx.Button(self,wx.ID_OK)
277+
self.OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
278+
self.OkBtn.SetDefault()
279+
cancelBtn = wx.Button(self,wx.ID_CANCEL)
280+
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
281+
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
282+
btnSizer.Add((20,20),1)
283+
btnSizer.Add(self.OkBtn)
284+
btnSizer.Add((20,20),1)
285+
btnSizer.Add(cancelBtn)
286+
btnSizer.Add((20,20),1)
287+
288+
# create scrolled edit contents
289+
size=(600,350) # initial scrolled region size
290+
subpanel = wxscroll.ScrolledPanel(self, wx.ID_ANY,size=size,
291+
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
278292
dataGridSizer = wx.FlexGridSizer(cols=3,hgap=2,vgap=2)
279-
self.OkBtn = wx.Button(panel,wx.ID_OK)
293+
subpanel.SetSizer(dataGridSizer)
280294
for id in range(len(self.data)):
281295
lbl1 = lbl = str(self.data[id][1])
282296
if lbl[-1] != '=': lbl1 = lbl + ' ' + separator + ' '
283-
name = wx.StaticText(panel,wx.ID_ANY,lbl1,style=wx.ALIGN_RIGHT)
284-
scale = G2G.ValidatedTxtCtrl(panel,self.data[id],0,OKcontrol=self.DisableOK)
297+
name = wx.StaticText(subpanel,wx.ID_ANY,lbl1,style=wx.ALIGN_RIGHT)
298+
scale = G2G.ValidatedTxtCtrl(subpanel,self.data[id],0,OKcontrol=self.DisableOK)
285299
dataGridSizer.Add(name,0,wx.LEFT|wx.RIGHT|WACV,5)
286300
dataGridSizer.Add(scale,0,wx.RIGHT,3)
287301
if ':' in lbl:
288302
dataGridSizer.Add(
289-
wx.StaticText(panel,-1,G2obj.fmtVarDescr(lbl)),
303+
wx.StaticText(subpanel,-1,G2obj.fmtVarDescr(lbl)),
290304
0,wx.RIGHT|WACV,3)
291305
else:
292306
dataGridSizer.Add((-1,-1))
293307
if title == 'New Variable':
294-
name = wx.StaticText(panel,wx.ID_ANY,"New variable's\nname (optional)",
308+
name = wx.StaticText(subpanel,wx.ID_ANY,"New variable's\nname (optional)",
295309
style=wx.ALIGN_CENTER)
296-
scale = G2G.ValidatedTxtCtrl(panel,self.newvar,0,notBlank=False)
310+
scale = G2G.ValidatedTxtCtrl(subpanel,self.newvar,0,notBlank=False)
297311
dataGridSizer.Add(name,0,wx.LEFT|wx.RIGHT|WACV,5)
298312
dataGridSizer.Add(scale,0,wx.RIGHT|WACV,3)
299-
self.refine = wx.CheckBox(panel,label='Refine?')
313+
self.refine = wx.CheckBox(subpanel,label='Refine?')
300314
self.refine.SetValue(self.newvar[1]==True)
301315
self.refine.Bind(wx.EVT_CHECKBOX, self.OnCheckBox)
302316
dataGridSizer.Add(self.refine,0,wx.RIGHT|WACV,3)
303-
304-
mainSizer.Add(dataGridSizer,0,wx.EXPAND)
305-
self.OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
306-
self.OkBtn.SetDefault()
307-
cancelBtn = wx.Button(panel,wx.ID_CANCEL)
308-
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
309-
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
310-
btnSizer.Add((20,20),1)
311-
btnSizer.Add(self.OkBtn)
312-
btnSizer.Add((20,20),1)
313-
btnSizer.Add(cancelBtn)
314-
btnSizer.Add((20,20),1)
315-
317+
# layout window
318+
mainSizer.Add((-1,10),0)
319+
mainSizer.Add(topLabl,0,wx.LEFT,10)
320+
mainSizer.Add((-1,10),0)
321+
mainSizer.Add(subpanel,1,wx.EXPAND)
322+
mainSizer.Add((-1,3),0)
316323
mainSizer.Add(btnSizer,0,wx.EXPAND, 10)
317-
panel.SetSizer(mainSizer)
318-
panel.Fit()
324+
mainSizer.Add((-1,3),0)
325+
# finish up ScrolledPanel & then window
326+
subpanel.SetAutoLayout(1)
327+
subpanel.SetupScrolling()
319328
self.Fit()
320329
self.CenterOnParent()
321330

GSASII/GSASIIctrlGUI.py

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4961,7 +4961,7 @@ def AddSpinner(varSizer,label,SelCtrl,binding):
49614961
parmSizer.Add(selectionsSizer,0)
49624962
refChoices = ['All','Refined']
49634963
txt = ('"R" indicates a refined variable\n'+
4964-
'"C" indicates generated from a user entered constraint')
4964+
'"C" value generated from a constraint')
49654965
if fcount:
49664966
refChoices += ['Frozen']
49674967
txt += '\n"F" indicates a variable that is Frozen due to exceeding min/max'
@@ -5900,13 +5900,13 @@ def __init__(self,frame,includeTree=False,morehelpitems=[]):
59005900
helpobj = self.Append(wx.ID_ANY,lbl,'')
59015901
frame.Bind(wx.EVT_MENU, self.OnHelpById, helpobj)
59025902
self.HelpById[helpobj.GetId()] = indx
5903-
# add help lookup(s) in gsasii.html
5903+
# add help lookup(s) in GSAS-II Help
59045904
self.AppendSeparator()
59055905
if includeTree:
59065906
helpobj = self.Append(wx.ID_ANY,'Help on GSAS-II',
5907-
'Access web page with information on GSAS-II')
5907+
'Access web pages with information on GSAS-II')
59085908
frame.Bind(wx.EVT_MENU, self.OnHelpById, id=helpobj.GetId())
5909-
self.HelpById[helpobj.GetId()] = 'Data tree'
5909+
self.HelpById[helpobj.GetId()] = 'HelpIntro'
59105910
helpobj = self.Append(wx.ID_ANY,'Help on current data tree item\tF1',
59115911
'Access web page on selected item in tree')
59125912
frame.Bind(wx.EVT_MENU, self.OnHelpById, id=helpobj.GetId())
@@ -5916,21 +5916,18 @@ def __init__(self,frame,includeTree=False,morehelpitems=[]):
59165916

59175917
def OnHelpById(self,event):
59185918
'''Called when Help on... is pressed in a menu. Brings up a web page
5919-
for documentation. Uses the helpKey value from the dataWindow window
5920-
unless a special help key value has been defined for this menu id in
5921-
self.HelpById
5922-
5923-
Note that self should now (2frame) be child of the main window (G2frame)
5919+
for documentation. Uses the G2frame.dataWindow.helpKey value to select
5920+
what help is shown, unless a special help key value has been defined
5921+
for the calling menu id (via a lookup in self.HelpById[], which is used
5922+
for Tutorials & Overall help).
5923+
Note that G2frame.dataWindow.helpKey SelectDataTreeItem and reflects
5924+
the data tree item that has been selected.
5925+
5926+
Note that self here should be a child of the main window (G2frame)
5927+
where self.frame is G2frame
59245928
'''
5925-
if hasattr(self.frame,'dataWindow'): # Debug code: check this is called from menu in G2frame
5926-
# should always be true in 2 Frame version
5927-
dW = self.frame.dataWindow
5928-
else:
5929-
print('help error: not called from standard menu?')
5930-
print (self)
5931-
return
59325929
try:
5933-
helpKey = dW.helpKey # look up help from helpKey in data window
5930+
helpKey = self.frame.dataWindow.helpKey # look up help from helpKey in data window
59345931
#if GSASIIpath.GetConfigValue('debug'): print 'DBG_dataWindow help: key=',helpKey
59355932
except AttributeError:
59365933
helpKey = ''
@@ -6035,7 +6032,7 @@ def copy2clip(event):
60356032
class HelpButton(wx.Button):
60366033
'''Create a help button that displays help information.
60376034
The text can be displayed in a modal message window or it can be
6038-
a reference to a location in the gsasII.html (etc.) help web page, in which
6035+
a reference to a location in the gsasII help web pages, in which
60396036
case that page is opened in a web browser.
60406037
60416038
TODO: it might be nice if it were non-modal: e.g. it stays around until
@@ -6046,9 +6043,12 @@ class HelpButton(wx.Button):
60466043
:param str msg: the help text to be displayed. Indentation on
60476044
multiline help text is stripped (see :func:`StripIndents`). If wrap
60486045
is set as non-zero, all new lines are
6049-
:param str helpIndex: location of the help information in the gsasII.html
6050-
help file in the form of an anchor string. The URL will be
6051-
constructed from: location + gsasII.html + "#" + helpIndex
6046+
:param str helpIndex: selection for the help information in the GSAS-II
6047+
help files, in the form of an anchor string. That anchor is looked
6048+
up to find the file name and the URL is constructed from:
6049+
6050+
<location> + <filename> + "#" + helpIndex
6051+
60526052
:param int wrap: if specified, the text displayed is reformatted by
60536053
wrapping it to fit in wrap pixels. Default is None which prevents
60546054
wrapping.
@@ -7626,22 +7626,31 @@ class G2LstCtrl(wx.ListCtrl):
76267626
htmlPanel = None
76277627
htmlFrame = None
76287628
htmlFirstUse = True
7629-
#helpLocDict = {} # to be implemented if we ever split gsasii.html over multiple files
7629+
helpLocDict = {}
7630+
'This is an index to the HTML anchors defined in the GSAS-II help files'
76307631
path2GSAS2 = os.path.dirname(os.path.realpath(__file__)) # save location of this file
76317632
def ShowHelp(helpType,frame,helpMode=None):
76327633
'''Called to bring up a web page for documentation.'''
76337634
global htmlFirstUse,htmlPanel,htmlFrame
7635+
if not helpLocDict: # load the anchor index
7636+
indx = os.path.abspath(os.path.join(path2GSAS2,'help','anchorIndex.txt'))
7637+
print('reading file',indx)
7638+
with open(indx,'r') as indexfile:
7639+
for line in indexfile.readlines():
7640+
fil,anchors = line.split(':')
7641+
for a in anchors.split(','):
7642+
#if a in helpLocDict: print(a,'repeated!')
7643+
helpLocDict[a.strip()] = fil
76347644
# no defined link to use, create a default based on key
7635-
if helpType.lower().startswith('pwdr'):
7636-
helplink = 'gsasII-pwdr.html#'+helpType.replace(')','').replace('(','_').replace(' ','_')
7637-
elif helpType.lower().startswith('phase'):
7638-
helplink = 'gsasII-phase.html#'+helpType.replace(')','').replace('(','_').replace(' ','_')
7639-
elif helpType.lower().startswith('hist/phase'):
7640-
helplink = 'gsasII-phase.html#Phase-Data'
7641-
elif helpType:
7642-
helplink = 'gsasII.html#'+helpType.replace(')','').replace('(','_').replace(' ','_')
7643-
else:
7644-
helplink = 'gsasII.html'
7645+
helplink = 'index.html'
7646+
if helpType:
7647+
anchor = helpType.replace(')','').replace('(','_').replace(' ','_')
7648+
if anchor not in helpLocDict:
7649+
print(f'Help lookup problem, anchor {anchor} not found'
7650+
'\nPlease report this to [email protected] along with a'
7651+
'\nscreen image showing where you tried to get help')
7652+
else:
7653+
helplink = f'{helpLocDict[anchor]}#{anchor}'
76457654
# determine if a web browser or the internal viewer should be used for help info
76467655
if helpMode:
76477656
pass

GSASII/GSASIIdataGUI.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ def OnwxInspect(event):
680680
def _Add_DataMenuItems(self,parent):
681681
'''Add items to Data menu
682682
'''
683+
#(7/2025) next duplicated in Import menu; patch: remove this someday
683684
item = parent.Append(wx.ID_ANY,'Read Powder Pattern Peaks...','')
684685
self.Bind(wx.EVT_MENU, self.OnReadPowderPeaks, id=item.GetId())
685686
item = parent.Append(wx.ID_ANY,'Sum or Average powder data','')
@@ -2759,6 +2760,8 @@ def FillMainMenu(self,menubar,addhelp=True):
27592760
self._Add_ImportMenu_smallangle(Import)
27602761
self._Add_ImportMenu_reflectometry(Import)
27612762
self._Add_ImportMenu_PDF(Import)
2763+
item = Import.Append(wx.ID_ANY,'Read Powder Pattern Peaks...','')
2764+
self.Bind(wx.EVT_MENU, self.OnReadPowderPeaks, id=item.GetId())
27622765

27632766
item = Import.Append(wx.ID_ANY,'Column metadata test','Test Column (.par) metadata import')
27642767
self.Bind(wx.EVT_MENU, self.OnColMetaTest, id=item.GetId())
@@ -2860,9 +2863,9 @@ def _init_ctrls(self, parent):
28602863
self.dataWindow = G2DataWindow(self.mainPanel)
28612864
dataSizer = wx.BoxSizer(wx.VERTICAL)
28622865
self.dataWindow.SetSizer(dataSizer)
2863-
self.mainPanel.SplitVertically(self.treePanel,
2864-
self.dataWindow.outer, 400)
2865-
self.Status.SetStatusWidths([200,-1]) # make these match?
2866+
sash = min(max(100,GSASIIpath.GetConfigValue('Split_Loc',250)),500)
2867+
self.mainPanel.SplitVertically(self.treePanel, self.dataWindow.outer, sash)
2868+
self.Status.SetStatusWidths([sash,-1]) # make these match?
28662869

28672870
G2G.wxID_GPXTREE = wx.NewId()
28682871
treeSizer = wx.BoxSizer(wx.VERTICAL)
@@ -4534,7 +4537,8 @@ def ExitMain(self, event):
45344537
'Main_Size':tuple(self.GetSize()),
45354538
'Plot_Pos':tuple(self.plotFrame.GetPosition()),
45364539
'Plot_Size':tuple(self.plotFrame.GetSize())}
4537-
GSASIIpath.SetConfigValue(FrameInfo)
4540+
GSASIIpath.AddConfigValue(FrameInfo)
4541+
GSASIIpath.AddConfigValue({'Split_Loc':self.mainPanel.GetSashPosition()})
45384542
config = G2G.GetConfigValsDocs()
45394543
G2G.SaveConfigVars(config)
45404544
except:
@@ -8560,7 +8564,7 @@ def OnShowShift(event):
85608564
parentID = G2frame.root
85618565
if item == G2frame.root:
85628566
G2frame.dataWindow.ClearData()
8563-
G2frame.helpKey = "Data tree"
8567+
G2frame.dataWindow.helpKey = "Data tree"
85648568
mainSizer = wx.BoxSizer(wx.VERTICAL)
85658569
G2frame.dataWindow.SetSizer(mainSizer)
85668570
mainSizer.Add(wx.StaticText(G2frame.dataWindow, wx.ID_ANY,

0 commit comments

Comments
 (0)