Changeset 746
- Timestamp:
- Aug 31, 2012 1:56:07 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r740 r746 2036 2036 Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree() 2037 2037 print Histograms.keys() 2038 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,Rest Dict=None,Print=False)2038 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,RestraintDict=None,Print=False) 2039 2039 hapVary,hapDict,controlDict = G2str.GetHistogramPhaseData(Phases,Histograms,Print=False) 2040 2040 histVary,histDict,controlDict = G2str.GetHistogramData(Histograms,Print=False) -
trunk/GSASIIgrid.py
r740 r746 610 610 self.PawleyEdit.Append(id=wxID_PAWLEYUPDATE, kind=wx.ITEM_NORMAL,text='Pawley update', 611 611 help='Update Pawley intensities with abs(Fobs) from reflection list') 612 self.PawleyEdit.Append(id=wxID_PAWLEYDELETE, kind=wx.ITEM_NORMAL,text='Pawley delete',613 help='Delete Pawley reflection list')612 # self.PawleyEdit.Append(id=wxID_PAWLEYDELETE, kind=wx.ITEM_NORMAL,text='Pawley delete', 613 # help='Delete selected Pawley reflection') 614 614 615 615 # Phase / Map peaks tab -
trunk/GSASIIphsGUI.py
r744 r746 406 406 if 'Pawley dmin' not in generalData: 407 407 generalData['Pawley dmin'] = 1.0 408 if 'Pawley neg wt' not in generalData: 409 generalData['Pawley neg wt'] = 0.0 408 410 409 411 # if 'SH Texture' not in generalData: … … 463 465 'AtomPtrs':[] 464 466 'Histogram list':['',] 465 'Pawley dmin':1.0} 467 'Pawley dmin':1.0, 468 'Pawley neg wt':0.0} 466 469 'Atoms':[] 467 470 'Drawing':{} … … 756 759 pawlVal.SetValue("%.3f"%(generalData['Pawley dmin'])) #reset in case of error 757 760 761 def OnPawleyNegWt(event): 762 try: 763 wt = float(pawlNegWt.GetValue()) 764 if 0. <= wt <= 1.: 765 generalData['Pawley neg wt'] = wt 766 except ValueError: 767 pass 768 pawlNegWt.SetValue("%.3g"%(generalData['Pawley neg wt'])) #reset in case of error 769 758 770 pawleySizer = wx.BoxSizer(wx.HORIZONTAL) 759 771 pawleySizer.Add(wx.StaticText(dataDisplay,label=' Pawley controls: '),0,wx.ALIGN_CENTER_VERTICAL) … … 767 779 pawlVal.Bind(wx.EVT_KILL_FOCUS,OnPawleyVal) 768 780 pawleySizer.Add(pawlVal,0,wx.ALIGN_CENTER_VERTICAL) 781 pawleySizer.Add(wx.StaticText(dataDisplay,label=' Pawley neg. wt.: '),0,wx.ALIGN_CENTER_VERTICAL) 782 pawlNegWt = wx.TextCtrl(dataDisplay,value='%.3g'%(generalData['Pawley neg wt']),style=wx.TE_PROCESS_ENTER) 783 pawlNegWt.Bind(wx.EVT_TEXT_ENTER,OnPawleyNegWt) 784 pawlNegWt.Bind(wx.EVT_KILL_FOCUS,OnPawleyNegWt) 785 pawleySizer.Add(pawlNegWt,0,wx.ALIGN_CENTER_VERTICAL) 769 786 return pawleySizer 770 787 … … 789 806 try: 790 807 res = float(cutOff.GetValue()) 791 if 1 .0 <= res <= 100.:808 if 10.0 <= res <= 100.: 792 809 Map['cutOff'] = res 793 810 except ValueError: … … 3875 3892 FillPawleyReflectionsGrid() 3876 3893 3877 def OnPawleyDelete(event): 3878 dlg = wx.MessageDialog(G2frame,'Do you really want to delete Pawley reflections?','Delete',3894 def OnPawleyDelete(event): #doesn't work 3895 dlg = wx.MessageDialog(G2frame,'Do you really want to delete selected Pawley reflections?','Delete', 3879 3896 wx.YES_NO | wx.ICON_QUESTION) 3880 3897 try: 3881 3898 result = dlg.ShowModal() 3899 if result == wx.ID_YES: 3900 Refs = data['Pawley ref'] 3901 Ind = G2frame.PawleyRefl.GetSelectedRows() 3902 Ind.sort() 3903 Ind.reverse() 3904 for ind in Ind: 3905 Refs = np.delete(Refs,ind,0) 3906 data['Pawley ref'] = Refs 3907 FillPawleyReflectionsGrid() 3882 3908 finally: 3883 3909 dlg.Destroy() 3884 if result == wx.ID_YES:3885 data['Pawley ref'] = []3886 FillPawleyReflectionsGrid()3887 3910 3888 3911 ################################################################################ -
trunk/GSASIIstruct.py
r744 r746 1893 1893 ################################################################################ 1894 1894 1895 def penaltyFxn(parmDict,varyList): 1896 pFxn = np.zeros(len(varyList)) 1895 def penaltyFxn(Phases,parmDict,varyList): 1896 pNames = [] 1897 pVals = [] 1898 negWt = {} 1899 for phase in Phases: 1900 negWt[Phases[phase]['pId']] = Phases[phase]['General']['Pawley neg wt'] 1901 for item in varyList: 1902 if 'PWLref' in item and parmDict[item] < 0.: 1903 pId = int(item.split(':')[0]) 1904 pNames.append(item) 1905 pVals.append(-negWt[pId]*parmDict[item]**2) 1906 pVals = np.array(pVals) 1907 return pNames,pVals 1908 1909 def penaltyDeriv(pNames,pVal,Phases,parmDict,varyList): 1910 pDerv = np.zeros((len(varyList),len(pVal))) 1897 1911 for i,item in enumerate(varyList): 1898 if 'PWLref' in item and parmDict[item] < 0.: 1899 pFxn[i] = -parmDict[item]**2 #checked OK 1900 return pFxn/1000. 1901 1902 def penaltyDeriv(parmDict,varyList): 1903 pDerv = np.zeros(len(varyList)) 1904 for i,item in enumerate(varyList): 1905 if 'PWLref' in item and parmDict[item] < 0.: 1906 pDerv[i] += 2.*parmDict[item] 1907 return pDerv/1000. 1912 if item in pNames: 1913 pDerv[i][pNames.index(item)] -= 2.*parmDict[item] 1914 return pDerv 1908 1915 1909 1916 ################################################################################ … … 2652 2659 try: 2653 2660 pInd =pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 2654 parmDict[pInd] = max(parmDict[pInd]/2.,parmDict[pInd])2661 # parmDict[pInd] = max(parmDict[pInd]/2.,parmDict[pInd]) 2655 2662 refl[9] = parmDict[pInd] 2656 2663 except KeyError: … … 2804 2811 # refl[9] = parmDict[pIdx] 2805 2812 dMdpw[iBeg:iFin] = dervDict['int']/refl[9] 2806 if parmDict[pIdx] < 0.:2807 dMdpw[iBeg:iFin] = 2.*dervDict['int']/refl[9]2813 # if parmDict[pIdx] < 0.: 2814 # dMdpw[iBeg:iFin] = 2.*dervDict['int']/refl[9] 2808 2815 if Ka2: 2809 2816 dMdpw[iBeg2:iFin2] += dervDict2['int']/refl[9] 2810 if parmDict[pIdx] < 0.:2811 dMdpw[iBeg2:iFin2] += 2.*dervDict['int']/refl[9]2817 # if parmDict[pIdx] < 0.: 2818 # dMdpw[iBeg2:iFin2] += 2.*dervDict['int']/refl[9] 2812 2819 dMdv[idx] = dMdpw 2813 2820 except: # ValueError: … … 2986 2993 dMdv = dMdvh 2987 2994 2988 # dpdv = penaltyDeriv(parmdict,varylist) 2989 # if np.any(dpdv): 2990 # dMdv = np.concatenate((dMdv.T,np.outer(dpdv,dpdv))).T 2995 pNames,pVals = penaltyFxn(Phases,parmdict,varylist) 2996 if np.sum(pVals): 2997 dpdv = penaltyDeriv(pNames,pVals,Phases,parmdict,varylist) 2998 dMdv = np.concatenate((dMdv.T,dpdv.T)).T 2991 2999 return dMdv 2992 3000 … … 3015 3023 Wt = np.sqrt(W[xB:xF])[np.newaxis,:] 3016 3024 Dy = dy[xB:xF][np.newaxis,:] 3017 print 'Jacobian size: ',dMdvh.shape3018 3025 dMdvh *= Wt 3019 3026 if dlg: … … 3075 3082 else: 3076 3083 continue #skip non-histogram entries 3077 # dpdv = penaltyDeriv(parmdict,varylist) 3078 # if np.any(dpdv): 3079 # pVec = dpdv*penaltyFxn(parmdict,varylist) 3080 # Vec += pVec 3081 # pHess = np.zeros((len(varylist),len(varylist))) 3082 # for i,val in enumerate(dpdv): 3083 # pHess[i][i] = dpdv[i]**2 3084 # Hess += pHess 3084 pNames,pVals = penaltyFxn(Phases,parmdict,varylist) 3085 if np.sum(pVals): 3086 dpdv = penaltyDeriv(pNames,pVals,Phases,parmdict,varylist) 3087 Vec += np.sum(dpdv,axis=1) 3088 Hess += np.inner(dpdv,dpdv) 3085 3089 return Vec,Hess 3086 3090 … … 3191 3195 if not GoOn: 3192 3196 parmdict['saved values'] = values 3197 dlg.Destroy() 3193 3198 raise Exception #Abort!! 3194 # pFunc = penaltyFxn(parmdict,varylist) 3195 # if np.any(pFunc): 3196 # M = np.concatenate((M,pFunc)) 3199 pDict,pVals = penaltyFxn(Phases,parmdict,varylist) 3200 if np.sum(pVals): 3201 print 'Penalty function :',np.sum(pVals) 3202 M = np.concatenate((M,pVals)) 3197 3203 return M 3198 3204
Note: See TracChangeset
for help on using the changeset viewer.