Changeset 1126
- Timestamp:
- Oct 28, 2013 4:06:58 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r1124 r1126 19 19 import wx.lib.scrolledpanel as wxscroll 20 20 import time 21 import copy 21 22 import cPickle 22 23 import sys … … 1022 1023 1023 1024 class DisAglDialog(wx.Dialog): 1024 '''Distance Angle Controls dialog 1025 '''Distance/Angle Controls input dialog. After 1026 :meth:`ShowModal` returns, the results are found in 1027 dict :attr:`self.data`, which is accessed using :meth:`GetData`. 1028 1029 :param wx.Frame parent: reference to parent frame (or None) 1030 :param dict data: a dict containing the current 1031 search ranges or an empty dict, which causes default values 1032 to be used. 1033 Will be used to set element `DisAglCtls` in 1034 :ref:`Phase Tree Item <Phase_table>` 1035 :param dict default: A dict containing the default 1036 search ranges for each element. 1025 1037 ''' 1026 def __default__(self,data,default): 1038 def __init__(self,parent,data,default): 1039 wx.Dialog.__init__(self,parent,wx.ID_ANY, 1040 'Distance Angle Controls', 1041 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1042 self.default = default 1043 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 1044 self._default(data,self.default) 1045 self.Draw(self.data) 1046 1047 def _default(self,data,default): 1048 '''Set starting values for the search values, either from 1049 the input array or from defaults, if input is null 1050 ''' 1027 1051 if data: 1028 self.data = data1052 self.data = copy.deepcopy(data) # don't mess with originals 1029 1053 else: 1030 1054 self.data = {} … … 1034 1058 self.data['BondRadii'] = default['BondRadii'][:] 1035 1059 self.data['AngleRadii'] = default['AngleRadii'][:] 1036 1037 def __init__(self,parent,data,default): 1038 wx.Dialog.__init__(self,parent,-1,'Distance Angle Controls', 1039 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1040 self.default = default 1041 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 1042 self.__default__(data,self.default) 1043 self.Draw(self.data) 1044 1060 1045 1061 def Draw(self,data): 1062 '''Creates the contents of the dialog. Normally called 1063 by :meth:`__init__`. 1064 ''' 1046 1065 self.panel.Destroy() 1047 1066 self.panel = wx.Panel(self) … … 1104 1123 1105 1124 def GetData(self): 1125 'Returns the values from the dialog' 1106 1126 return self.data 1107 1127 1108 1128 def OnOk(self,event): 1129 'Called when the OK button is pressed' 1109 1130 parent = self.GetParent() 1110 1131 parent.Raise() … … 1112 1133 1113 1134 def OnReset(self,event): 1135 'Called when the Reset button is pressed' 1114 1136 data = {} 1115 self._ _default__(data,self.default)1137 self._default(data,self.default) 1116 1138 self.Draw(self.data) 1117 1139 -
trunk/GSASIIobj.py
r1077 r1126 177 177 \ Pawley dmin maximum Q (as d-space) to use for Pawley 178 178 extraction (float) 179 \ BondRadii Radius for each atom used to compute179 \ BondRadii Default radius for each atom used to compute 180 180 interatomic distances (list of floats) 181 \ AngleRadii Radius for each atom used to compute181 \ AngleRadii Default radius for each atom used to compute 182 182 interatomic angles (list of floats) 183 \ DisAglCtls Dict with distance/angle search controls, 184 which has keys 'Name', 'AtomTypes', 185 'BondRadii', 'AngleRadii' which are as above 186 except are possibly edited. Also contains 187 'Factors', which is a 2 element list with 188 a multiplier for bond and angle search range 189 [typically (0.85,0.85)]. 183 190 ranId \ unique random number Id for phase (int) 184 191 pId \ Phase Id number for current project (int). -
trunk/exports/G2export_CIF.py
r1123 r1126 700 700 cfrac = cx+3 701 701 DisAglData = {} 702 DisAglCtls = {}703 702 # create a list of atoms, but skip atoms with zero occupancy 704 703 xyz = [] … … 707 706 if self.parmDict.get(fpfx+str(i),atom[cfrac]) == 0.0: continue 708 707 xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3]) 709 if 'DisAglCtls' in generalData: 710 DisAglCtls = generalData['DisAglCtls'] 711 else: # should not happen, since DisAglDialog should be called for all 712 # phases before getting here 713 dlg = G2gd.DisAglDialog(self.G2frame,DisAglCtls,generalData) 708 if 'DisAglCtls' not in generalData: 709 # should not happen, since DisAglDialog should be called 710 # for all phases before getting here 711 dlg = G2gd.DisAglDialog( 712 self.G2frame, 713 {}, 714 generalData) 714 715 if dlg.ShowModal() == wx.ID_OK: 715 DisAglCtls = dlg.GetData() 716 generalData['DisAglCtls'] = DisAglCtls 716 generalData['DisAglCtls'] = dlg.GetData() 717 717 else: 718 718 dlg.Destroy() … … 736 736 DisAglData['covData'] = self.OverallParms['Covariance'] 737 737 try: 738 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData) 738 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle( 739 generalData['DisAglCtls'], 740 DisAglData) 739 741 except KeyError: # inside DistAngle for missing atom types in DisAglCtls 740 742 print('**** ERROR - try again but do "Reset" to fill in missing atom types ****') … … 1023 1025 for phasenam in histblk['Reflection Lists']: 1024 1026 scale = self.Phases[phasenam]['Histograms'][histlbl]['Scale'][0] 1025 Icorr = np.array([refl[13] for refl in histblk['Reflection Lists'][phasenam]])[0] 1026 FO2 = np.array([refl[8] for refl in histblk['Reflection Lists'][phasenam]]) 1027 I100 = scale*FO2*Icorr 1027 refList = np.asarray(histblk['Reflection Lists'][phasenam]['RefList']) 1028 I100 = scale*refList.T[8]*refList.T[11] 1029 #Icorr = np.array([refl[13] for refl in histblk['Reflection Lists'][phasenam]])[0] 1030 #FO2 = np.array([refl[8] for refl in histblk['Reflection Lists'][phasenam]]) 1031 #I100 = scale*FO2*Icorr 1028 1032 Imax = max(Imax,max(I100)) 1029 1033 … … 1049 1053 scale = self.Phases[phasenam]['Histograms'][histlbl]['Scale'][0] 1050 1054 phaseid = self.Phases[phasenam]['pId'] 1051 refcount += len(histblk['Reflection Lists'][phasenam] )1052 for ref in histblk['Reflection Lists'][phasenam]:1055 refcount += len(histblk['Reflection Lists'][phasenam]['RefList']) 1056 for j,ref in enumerate(histblk['Reflection Lists'][phasenam]['RefList']): 1053 1057 if DEBUG: 1054 1058 print('DEBUG: skipping reflection list') … … 1073 1077 s += PutInCol(G2mth.ValEsd(ref[4],-0.009),8) 1074 1078 if Imax > 0: 1075 I100 = 100.*scale*ref[8]*ref[13]/Imax 1076 s += PutInCol(G2mth.ValEsd(I100,-0.09),6) 1079 s += PutInCol(G2mth.ValEsd(100.*I100[j]/Imax,-0.09),6) 1077 1080 WriteCIFitem(" "+s) 1078 1081 … … 1171 1174 dmax = None 1172 1175 dmin = None 1173 refcount = len(histblk['Data'] )1174 for ref in histblk['Data'] :1176 refcount = len(histblk['Data']['RefList']) 1177 for ref in histblk['Data']['RefList']: 1175 1178 s = " " 1176 1179 if hklmin is None: … … 1254 1257 but = event.GetEventObject() 1255 1258 phasedict = but.phasedict 1256 dlg = G2gd.DisAglDialog(self.G2frame,{},phasedict['General']) 1259 dlg = G2gd.DisAglDialog( 1260 self.G2frame, 1261 phasedict['General']['DisAglCtls'], # edited 1262 phasedict['General'], # defaults 1263 ) 1257 1264 if dlg.ShowModal() == wx.ID_OK: 1258 1265 phasedict['General']['DisAglCtls'] = dlg.GetData() … … 1379 1386 cfrac = cx+3 1380 1387 DisAglData = {} 1381 DisAglCtls = {}1382 1388 # create a list of atoms, but skip atoms with zero occupancy 1383 1389 xyz = [] … … 1386 1392 if self.parmDict.get(fpfx+str(i),atom[cfrac]) == 0.0: continue 1387 1393 xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3]) 1388 if 'DisAglCtls' in generalData: 1389 DisAglCtls = generalData['DisAglCtls'] 1390 else: # should not happen, since DisAglDialog should be called for all 1391 # phases before getting here 1392 dlg = G2gd.DisAglDialog(self.cifdefs,DisAglCtls,generalData) 1394 if 'DisAglCtls' not in generalData: 1395 # should not be used, since DisAglDialog should be called 1396 # for all phases before getting here 1397 dlg = G2gd.DisAglDialog( 1398 self.cifdefs, 1399 {}, 1400 generalData) 1393 1401 if dlg.ShowModal() == wx.ID_OK: 1394 DisAglCtls = dlg.GetData() 1395 generalData['DisAglCtls'] = DisAglCtls 1402 generalData['DisAglCtls'] = dlg.GetData() 1396 1403 else: 1397 1404 dlg.Destroy() … … 1427 1434 DisAglData['covData'] = self.OverallParms['Covariance'] 1428 1435 try: 1429 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData) 1436 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle( 1437 generalData['DisAglCtls'], 1438 DisAglData) 1430 1439 except KeyError: # inside DistAngle for missing atom types in DisAglCtls 1431 1440 print('**** ERROR - try again but do "Reset" to fill in missing atom types ****') … … 1609 1618 ) 1610 1619 if not EditInstNames(): return 1611 # check for a distance-angle range search range for each phase1612 1620 if not self.quickmode: 1621 # check for a distance-angle range search range for each phase 1613 1622 for phasenam in sorted(self.Phases.keys()): 1614 1623 #i = self.Phases[phasenam]['pId'] 1615 1624 phasedict = self.Phases[phasenam] # pointer to current phase info 1616 1625 if 'DisAglCtls' not in phasedict['General']: 1617 dlg = G2gd.DisAglDialog(self.G2frame,{},phasedict['General']) 1626 dlg = G2gd.DisAglDialog( 1627 self.G2frame, 1628 {}, 1629 phasedict['General']) 1618 1630 if dlg.ShowModal() == wx.ID_OK: 1619 1631 phasedict['General']['DisAglCtls'] = dlg.GetData()
Note: See TracChangeset
for help on using the changeset viewer.