Skip to content

Commit d6a3049

Browse files
committed
New scripted Origin1->2 shift; debug mode: show traceback on Reader exception; save warnings reader warnings
1 parent 116a076 commit d6a3049

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

GSASII/GSASIIctrlGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8445,7 +8445,7 @@ def ChooseOrigin(G2frame,rd):
84458445
for atom in O2atoms:
84468446
for i in [0,1,2]:
84478447
atom[cx+i] += T[i]
8448-
atom[cs:cs+2] = G2spc.SytSym(atom[cx:cx+3],SGData)[0:2] # update symmetry & mult
8448+
atom[cs:cs+2] = G2spc.SytSym(atom[cx:cx+3],SGData)[0:2] # update symmetry & mult
84498449
#get density & distances
84508450
DisAglData = {}
84518451
DisAglData['SGData'] = rd.Phase['General']['SGData']

GSASII/GSASIIscriptable.py

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,13 @@ def import_generic(filename, readerlist, fmthint=None, bank=None,
500500
repeat = False
501501
block += 1
502502
rd.objname = os.path.basename(filename)
503-
try:
503+
if GSASIIpath.GetConfigValue('debug'):
504504
flag = rd.Reader(filename,buffer=rdbuffer, blocknum=block)
505-
except Exception as msg:
506-
if GSASIIpath.GetConfigValue('debug'):
507-
print('Reader exception',msg)
508-
flag = False
505+
else:
506+
try:
507+
flag = rd.Reader(filename,buffer=rdbuffer, blocknum=block)
508+
except Exception as msg:
509+
flag = False
509510
if flag:
510511
# Omitting image loading special cases
511512
rd.readfilename = filename
@@ -1391,6 +1392,8 @@ def add_phase(self, phasefile=None, phasename=None, histograms=[],
13911392
phaseNameList = [p.name for p in self.phases()]
13921393
phasename = G2obj.MakeUniqueLabel(phasename, phaseNameList)
13931394
phObj['General']['Name'] = phasename
1395+
if phasereader.warnings:
1396+
phObj['warnings'] = phasereader.warnings
13941397

13951398
if 'Phases' not in self.data:
13961399
self.data['Phases'] = { 'data': None }
@@ -5583,6 +5586,50 @@ def addDistRestraint(self, origin, target, bond, factor=1.1, ESD=0.01):
55835586
count += 1
55845587
bondRestData['Bonds'].append(newBond)
55855588
return count
5589+
5590+
def Origin1to2Shift(self):
5591+
'''Applied an Origin 1 to Origin 2 shift to the selected phase
5592+
5593+
A copy of the phase is made where the new phase name has the string
5594+
"_shifted" added to it. The routine returns a reference to the
5595+
new :class:`G2Phase` object for the new phase.
5596+
5597+
If the phase is not one of the space groups that has Origin 1 & Origin 2
5598+
settings, None is return.
5599+
5600+
:returns: returns a newly created phase object or None
5601+
'''
5602+
gpx = self.proj
5603+
SGData = self.data['General']['SGData']
5604+
if SGData['SpGrp'] not in G2spc.spg2origins:
5605+
return
5606+
T = G2spc.spg2origins[SGData['SpGrp']]
5607+
# create a new phase
5608+
phaseNameList = [p.name for p in gpx.phases()]
5609+
phasename = G2obj.MakeUniqueLabel(self.name+'_shifted', phaseNameList)
5610+
gpx.data['Phases'][phasename] = G2obj.SetNewPhase(Name=phasename,
5611+
SGData=SGData)
5612+
nphase = gpx.data['Phases'][phasename]
5613+
for obj in gpx.names: # add new phase to tree
5614+
if obj[0] == 'Phases':
5615+
obj.append(phasename)
5616+
break
5617+
# duplicate phase info
5618+
for key in self.data: # copy all phase info over to new phase
5619+
if key == 'ranId': continue
5620+
nphase[key] = copy.deepcopy(self.data[key])
5621+
nphase['General']['Name'] = phasename # reset
5622+
# apply shift (T)
5623+
O2atoms = nphase['Atoms']
5624+
cx,ct,cs,cia = nphase['General']['AtomPtrs']
5625+
for atom in O2atoms:
5626+
for i in [0,1,2]:
5627+
atom[cx+i] += T[i]
5628+
atom[cs:cs+2] = G2spc.SytSym(atom[cx:cx+3],SGData)[0:2] # update sym
5629+
SetupGeneral(nphase, None)
5630+
gpx.index_ids()
5631+
gpx.update_ids()
5632+
return gpx.phase(phasename)
55865633

55875634
class G2SeqRefRes(G2ObjectWrapper):
55885635
'''Wrapper for a Sequential Refinement Results tree entry, containing the

0 commit comments

Comments
 (0)