Changeset 3462 for trunk/GSASIIconstrGUI.py
- Timestamp:
- Jul 5, 2018 10:08:10 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r3456 r3462 1190 1190 1191 1191 ################################################################################ 1192 # check scale & phase fractions, create constraint if needed 1193 ################################################################################ 1194 def CheckAllScalePhaseFractions(G2frame): 1195 '''Check if scale factor and all phase fractions are refined without a constraint 1196 for all used histograms, if so, offer the user a chance to create a constraint 1197 on the sum of phase fractions 1198 ''' 1199 histograms, phases = G2frame.GetUsedHistogramsAndPhasesfromTree() 1200 for i,hist in enumerate(histograms): 1201 CheckScalePhaseFractions(G2frame,hist,histograms,phases) 1202 1203 def CheckScalePhaseFractions(G2frame,hist,histograms,phases): 1204 '''Check if scale factor and all phase fractions are refined without a constraint 1205 for histogram hist, if so, offer the user a chance to create a constraint 1206 on the sum of phase fractions 1207 ''' 1208 if G2frame.testSeqRefineMode(): 1209 histStr = '*' 1210 else: 1211 histStr = str(histograms[hist]['hId']) 1212 # is scale factor varied 1213 if not histograms[hist]['Sample Parameters']['Scale'][1]: 1214 return 1215 # are all phase fractions varied in all used histograms 1216 phaseCount = 0 1217 for p in phases: 1218 if phases[p]['Histograms'][hist]['Use'] and not phases[p]['Histograms'][hist]['Scale'][1]: 1219 return 1220 else: 1221 phaseCount += 1 1222 1223 # all phase fractions and scale factor varied, now scan through constraints 1224 sub = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Constraints') 1225 Constraints = G2frame.GPXtree.GetItemPyData(sub) 1226 fracConstr = False 1227 for c in Constraints.get('HAP',[]): 1228 if c[-1] != 'c': continue 1229 if not c[-3]: continue 1230 if len(c[:-3]) != phaseCount: continue 1231 # got a constraint equation with right number of terms, is it on phase fractions for 1232 # the correct histogram? 1233 if all([(i[1].name == 'Scale' and i[1].varname().split(':')[1] == histStr) for i in c[:-3]]): 1234 # got a constraint, this is OK 1235 return 1236 dlg = wx.MessageDialog(G2frame, 1237 'You are refining the scale factor and all phase fractions for histogram #'+ 1238 histStr+'. This will produce an unstable refinement. '+ 1239 'Do you want to constrain the sum of phase fractions?', 1240 'Create constraint?', 1241 wx.OK|wx.CANCEL) 1242 if dlg.ShowModal() != wx.ID_OK: 1243 dlg.Destroy() 1244 return 1245 dlg.Destroy() 1246 1247 constr = [] 1248 for p in phases: 1249 if not phases[p]['Histograms'][hist]['Use']: continue 1250 constr += [[1.0,G2obj.G2VarObj(':'.join((str(phases[p]['pId']),histStr,'Scale')))]] 1251 constr += [1.0,None,'c'] 1252 Constraints['HAP'] += [constr] 1253 1254 ################################################################################ 1192 1255 #### Make nuclear/magnetic phase transition constraints - called by OnTransform in G2phsGUI 1193 1256 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.