Skip to content

Commit 0fae64b

Browse files
committed
address bugs in ISODISTORT & BCS access
1 parent eb5e7b7 commit 0fae64b

3 files changed

Lines changed: 42 additions & 31 deletions

File tree

GSASII/GSASIIphsGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7083,7 +7083,7 @@ def OnRunISODISTORT(event):
70837083
data['ISODISTORT']['SGselect'] = {'Tric':True,'Mono':True,'Orth':True,'Tetr':True,'Trig':True,'Hexa':True,'Cubi':True}
70847084
data['ISODISTORT']['selection'] = None
70857085
print('ISODISTORT run complete')
7086-
wx.CallAfter(G2phsG2.UpdateISODISTORT,G2frame.data)
7086+
wx.CallAfter(G2phsG2.UpdateISODISTORT,G2frame,data)
70877087
elif data['ISODISTORT']['ISOmethod'] != 4 or radio is None:
70887088
G2G.G2MessageBox(G2frame,'ISODISTORT run failed - see page opened in web browser')
70897089
else:

GSASII/ISODISTORT.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -120,33 +120,40 @@ def GetISODISTORT(Phase):
120120
print('method 3 TBD')
121121
return [],[]
122122
elif ISOdata['ISOmethod'] == 4:
123-
childcif = ISOdata['ChildCIF']
124-
if 'Use this phase' in childcif:
125-
childcif = MakePhaseCif(Phase)
126-
print(' Run ISODISTORT with %s as child cif'%childcif)
127-
ISOchildcif = UploadCIF(childcif)
128-
data['input'] = 'uploadsubgroupcif'
129-
data['filename'] = ISOchildcif
130-
out24 = requests.post(isoformsite,data=data).text
131-
posB = out24.index('OPTION VALUE=')
132-
posF = out24[posB:].index('>')+posB
133-
value = out24[posB+13:posF]
134-
data['input'] = 'distort'
135-
data['origintype'] = 'method4'
136-
data['inputbasis'] = 'list'
137-
data['basisselect'] = value[1:-1]
138-
data['chooseorigin'] = False
139-
data['trynearest'] = True
140-
data['dmax'] = '1'
141-
out25 = requests.post(isoformsite,data=data).text
142-
cifout = GetISOcif(out25,4)
143-
if cifout is None:
144-
return None,None
145-
cifFile = '%s_%s.cif'%(Phase['General']['Name'],'child')
146-
fl = open(cifFile,'wb')
147-
fl.write(cifout.encode("utf-8"))
148-
fl.close()
149-
return [],cifFile
123+
try:
124+
childcif = ISOdata['ChildCIF']
125+
if 'Use this phase' in childcif:
126+
childcif = MakePhaseCif(Phase)
127+
print(' Run ISODISTORT with %s as child cif'%childcif)
128+
ISOchildcif = UploadCIF(childcif)
129+
data['input'] = 'uploadsubgroupcif'
130+
data['filename'] = ISOchildcif
131+
out24 = requests.post(isoformsite,data=data).text
132+
posB = out24.index('OPTION VALUE=')
133+
posF = out24[posB:].index('>')+posB
134+
value = out24[posB+13:posF]
135+
data['input'] = 'distort'
136+
data['origintype'] = 'method4'
137+
data['inputbasis'] = 'list'
138+
data['basisselect'] = value[1:-1]
139+
data['chooseorigin'] = False
140+
data['trynearest'] = True
141+
data['dmax'] = '1'
142+
out25 = requests.post(isoformsite,data=data).text
143+
cifout = GetISOcif(out25,4)
144+
if cifout is None:
145+
return None,None
146+
cifFile = '%s_%s.cif'%(Phase['General']['Name'],'child')
147+
fl = open(cifFile,'wb')
148+
fl.write(cifout.encode("utf-8"))
149+
fl.close()
150+
return [],cifFile
151+
except:
152+
print('Output from ISODISTORT follows')
153+
if '<H1>' in out24: out24 = out24.split('<H1>',1)[1]
154+
print(out24)
155+
print('Scan of output from ISODISTORT failed, see above')
156+
return [],[]
150157

151158
#do the distortion search - result is radio button list of choices
152159

GSASII/SUBGROUPS.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ def BCS_init(threadCallback=None):
4545
if threadCallback == '':
4646
# setup default threading for BCS Post commands
4747
def BCS_sleep():
48-
wx.GetApp().Yield()
49-
wx.MilliSleep(100)
48+
try:
49+
wx.GetApp().Yield()
50+
wx.MilliSleep(100)
51+
except:
52+
import time
53+
time.sleep(0.1)
5054
#print('BCS_sleep')
5155
BCS.initAPI(threadSleep=BCS_sleep)
5256
return
@@ -384,7 +388,7 @@ def GetStdSGset(SGData=None, oprList=[]):
384388
xform = re.split(r'parclose\.png',re.split(r'paropen\.png',page)[1])[0] # pull out section w/Xform matrix
385389
mat = re.split(r'</pre>',re.split('<pre>',xform)[1])[0].split('\n')
386390
offsetV = [eval(m.split()[3]) for m in mat]
387-
xformM = np.array([[float(i) for i in m.split()[:3]] for m in mat])
391+
xformM = np.array([[float(eval(i)) for i in m.split()[:3]] for m in mat])
388392
return sgnum, sgnam, xformM.T, offsetV
389393

390394
# minsup = 'nph-minsup' # coded but not used

0 commit comments

Comments
 (0)