Changeset 5164
- Timestamp:
- Jan 28, 2022 8:39:44 AM (20 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpwd.py
r5161 r5164 2062 2062 return True 2063 2063 2064 def getHeaderInfo(FitPgm,dataType): 2065 '''Provide parameter name, label name and formatting information for the 2066 contents of the peak table and where used in DoPeakFit 2067 ''' 2068 names = ['pos','int'] 2069 lnames = ['position','intensity'] 2070 if FitPgm == 'LaueFringe': 2071 names += ['sig','gam','cells'] 2072 lnames += ['sigma','gamma','cells'] 2073 fmt = ["%10.5f","%10.3f","%10.3f","%10.3f","%10.3f"] 2074 elif 'C' in dataType: 2075 names += ['sig','gam'] 2076 lnames += ['sigma','gamma'] 2077 fmt = ["%10.5f","%10.1f","%10.3f","%10.3f"] 2078 elif 'T' in dataType: 2079 names += ['alp','bet','sig','gam'] 2080 lnames += ['alpha','beta','sigma','gamma'] 2081 fmt = ["%10.2f","%10.4f","%8.3f","%8.5f","%10.3f","%10.3f"] 2082 elif 'E' in dataType: 2083 names += ['sig'] 2084 lnames += ['sigma'] 2085 fmt = ["%10.5f","%10.1f","%8.3f"] 2086 else: # 'B' 2087 names += ['alp','bet','sig','gam'] 2088 lnames += ['alpha','beta','sigma','gamma'] 2089 fmt = ["%10.5f","%10.1f","%8.2f","%8.4f","%10.3f","%10.3f"] 2090 return names, fmt, lnames 2091 2064 2092 def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback=None,prevVaryList=[],oneCycle=False,controls=None,wtFactor=1.0,dlg=None,noFit=False): 2065 2093 '''Called to perform a peak fit, refining the selected items in the peak … … 2249 2277 peakVary = [] 2250 2278 peakVals = [] 2251 if 'C' in dataType: 2252 names = ['pos','int','sig','gam'] 2253 elif 'E' in dataType: 2254 names = ['pos','int','sig'] 2255 else: #'T' and 'B' 2256 names = ['pos','int','alp','bet','sig','gam'] 2279 names,_,_ = getHeaderInfo(FitPgm,dataType) 2257 2280 for i,peak in enumerate(Peaks): 2258 2281 for j,name in enumerate(names): … … 2265 2288 2266 2289 def GetPeaksParms(Inst,parmDict,Peaks,varyList): 2267 if 'C' in Inst['Type'][0]: 2268 names = ['pos','int','sig','gam'] 2269 elif 'E' in Inst['Type'][0]: 2270 names = ['pos','int','sig'] 2271 else: #'T' & 'B' 2272 names = ['pos','int','alp','bet','sig','gam'] 2290 names,_,_ = getHeaderInfo(FitPgm,Inst['Type'][0]) 2273 2291 for i,peak in enumerate(Peaks): 2274 2292 pos = parmDict['pos'+str(i)] … … 2304 2322 def PeaksPrint(dataType,parmDict,sigDict,varyList,ptsperFW): 2305 2323 print ('Peak coefficients:') 2306 if 'C' in dataType: 2307 names = ['pos','int','sig','gam'] 2308 elif 'E' in dataType: 2309 names = ['pos','int','sig'] 2310 else: #'T' & 'B' 2311 names = ['pos','int','alp','bet','sig','gam'] 2324 names,fmt,_ = getHeaderInfo(FitPgm,dataType) 2312 2325 head = 13*' ' 2313 2326 for name in names: … … 2318 2331 head += 'bins'.center(8) 2319 2332 print (head) 2320 if 'C' in dataType: 2321 ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f",'gam':"%10.3f"} 2322 elif 'E' in dataType: 2323 ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f"} 2324 elif 'T' in dataType: 2325 ptfmt = {'pos':"%10.2f",'int':"%10.4f",'alp':"%8.3f",'bet':"%8.5f",'sig':"%10.3f",'gam':"%10.3f"} 2326 else: #'B' 2327 ptfmt = {'pos':"%10.5f",'int':"%10.1f",'alp':"%8.2f",'bet':"%8.4f",'sig':"%10.3f",'gam':"%10.3f"} 2333 ptfmt = dict(zip(names,fmt)) 2328 2334 for i,peak in enumerate(Peaks): 2329 2335 ptstr = ':' … … 3470 3476 3471 3477 def calcRmax(ENGINE): 3472 'from Bachir, works for non-o thorhombic'3478 'from Bachir, works for non-orthorhombic cells' 3473 3479 a,b,c = ENGINE.basisVectors 3474 3480 lens = [] … … 3565 3571 else: 3566 3572 print('What is this?') 3567 rundata += ' ENGINE.add_constraints(DistanceConstraint(defaultLowerDistance={}))\n'.format(RMCPdict['min Contact'])3573 minDists = '' 3568 3574 if BondList: 3569 3575 rundata += ''' B_CONSTRAINT = BondConstraint() … … 3576 3582 if d1 == 0: continue 3577 3583 if d2 == 0: 3578 print('Ignoring min distance without maximum') 3579 #rundata += ' ("element","{}","{}",{}),\n'.format( 3580 # e1.strip(),e2.strip(),d1) 3584 minDists += '("element","{}","{}",{}),'.format(e1.strip(),e2.strip(),d1) 3581 3585 else: 3582 3586 rundata += ' ("element","{}","{}",{},{}),\n'.format( 3583 3587 e1.strip(),e2.strip(),d1,d2) 3584 3588 rundata += ' ])\n' 3589 rundata += ' D_CONSTRAINT = DistanceConstraint(defaultLowerDistance={})\n'.format(RMCPdict['min Contact']) 3590 if minDists: 3591 rundata += " D_CONSTRAINT.set_pairs_definition( {'inter':[" + minDists + "]})\n" 3592 rundata += ' ENGINE.add_constraints(D_CONSTRAINT)\n' 3593 3585 3594 if AngleList: 3586 3595 rundata += ''' A_CONSTRAINT = BondsAngleConstraint() -
trunk/GSASIIpwdGUI.py
r5140 r5164 431 431 else: 432 432 hLam = 0 433 sample = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId,'Sample Parameters'))433 # sample = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId,'Sample Parameters')) 434 434 # hGeom = sample.get('Type') 435 435 hstName = G2frame.GPXtree.GetItemText(G2frame.PatternId) … … 440 440 name = G2frame.GPXtree.GetItemText(item) 441 441 if name.startswith(hPrefix) and name != hstName: 442 c Geom,cType,cLam, = '?','?',-1442 cType,cLam, = '?',-1 443 443 subitem, subcookie = G2frame.GPXtree.GetFirstChild(item) 444 444 while subitem: 445 445 subname = G2frame.GPXtree.GetItemText(subitem) 446 446 if subname == 'Sample Parameters': 447 sample = G2frame.GPXtree.GetItemPyData(subitem) 448 # cGeom = sample.get('Type') 447 # sample = G2frame.GPXtree.GetItemPyData(subitem) 448 # cGeom = sample.get('Type') 449 pass 449 450 elif subname == 'Instrument Parameters': 450 451 inst,inst2 = G2frame.GPXtree.GetItemPyData(subitem) … … 948 949 for c in range(reflGrid.GetNumberCols()): 949 950 if reflGrid.GetColLabelValue(c) in ['position','intensity','alpha','beta','sigma','gamma']: 950 if float(reflGrid.GetCellValue(r,c)) < 0.: 951 reflGrid.SetCellBackgroundColour(r,c,wx.RED) 952 else: 953 reflGrid.SetCellBackgroundColour(r,c,wx.WHITE) 954 951 try: 952 if float(reflGrid.GetCellValue(r,c)) < 0.: 953 reflGrid.SetCellBackgroundColour(r,c,wx.RED) 954 else: 955 reflGrid.SetCellBackgroundColour(r,c,wx.WHITE) 956 except: 957 pass 958 955 959 def KeyEditPeakGrid(event): 956 960 '''Respond to pressing a key to act on selection of a row, column or cell … … 1084 1088 'Redraw the peak listings after the mode changes' 1085 1089 wx.CallAfter(UpdatePeakGrid,G2frame,data) 1090 # wx.CallLater(100,RefreshPeakGrid,None) 1086 1091 1087 1092 def RefreshPeakGrid(event): … … 1093 1098 1094 1099 #====================================================================== 1095 # beginning of UpdatePeakGrid init1100 #### beginning of UpdatePeakGrid 1096 1101 #====================================================================== 1097 1102 # data['FitPgm'] = data.get('FitPgm',0) … … 1127 1132 Inst = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Instrument Parameters'))[0] 1128 1133 for i in range(len(data['peaks'])): rowLabels.append(str(i+1)) 1129 # if data.get('FitPgm',0) == 1: 1130 # colLabels = ['position','refine','intensity','refine','cells','refine'] 1131 # Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1132 # wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_BOOL, 1133 # wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1134 # # TODO: note gamma values can still be set as refined 1135 # elif 'C' in Inst['Type'][0]: 1136 if 'C' in Inst['Type'][0]: 1137 colLabels = ['position','refine','intensity','refine','sigma','refine','gamma','refine'] 1138 Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1139 wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, 1140 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1141 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1142 elif 'E' in Inst['Type'][0]: 1143 colLabels = ['position','refine','intensity','refine','sigma','refine'] 1144 Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1145 wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, 1146 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1147 else: 1148 colLabels = ['position','refine','intensity','refine','alpha','refine', 1149 'beta','refine','sigma','refine','gamma','refine'] 1150 if 'T' in Inst['Type'][0]: 1151 Types = [wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, 1152 wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1153 wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1154 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1155 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1156 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1157 else: #'B' 1158 Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1159 wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, 1160 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1161 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1162 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1163 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1134 colLabels = [] 1135 Types = [] 1136 for _,f,l in zip(*G2pwd.getHeaderInfo( 1137 ('LSQ','LaueFringe')[data.get('FitPgm',0)],Inst['Type'][0])): 1138 colLabels.append(l) 1139 colLabels.append('refine') 1140 Types.append(wg.GRID_VALUE_FLOAT + 1141 f.replace('%',':').replace('f','').replace('.',',')) 1142 Types.append(wg.GRID_VALUE_BOOL) 1164 1143 T = [] 1165 1144 for peak in data['peaks']: … … 1172 1151 for key in T: X.append(D[key]) 1173 1152 data['peaks'] = X 1153 # pad peak table, if needed 1154 for j in range(len(data['peaks'])): 1155 for i in range(len(data['peaks'][j]),len(colLabels)): 1156 if colLabels[i] == 'refine': 1157 data['peaks'][j].append(False) 1158 else: 1159 data['peaks'][j].append(1.0) 1174 1160 G2frame.dataWindow.ClearData() 1175 1161 mainSizer = wx.BoxSizer(wx.VERTICAL)
Note: See TracChangeset
for help on using the changeset viewer.