- Timestamp:
- Jul 11, 2017 4:29:11 PM (6 years ago)
- Location:
- branch/2frame
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/2frame/GSASIIdataGUI.py
r2920 r2927 465 465 help='Exit from GSAS-II', id=wx.ID_ANY, 466 466 kind=wx.ITEM_NORMAL,text='&Exit') 467 self.Bind(wx.EVT_MENU, self. OnFileExit, id=item.GetId())467 self.Bind(wx.EVT_MENU, self.ExitMain, id=item.GetId()) 468 468 469 469 def _Add_DataMenuItems(self,parent): … … 2817 2817 wx.Frame.__init__(self, name='GSASII', parent=parent, 2818 2818 size=wx.Size(700, 450),style=wx.DEFAULT_FRAME_STYLE, title='GSAS-II main window') 2819 # BHT DEBUG2820 #size=wx.Size(400, 450),style=wx.DEFAULT_FRAME_STYLE, title='GSAS-II main window')2821 clientSize = wx.ClientDisplayRect()2822 Size = self.GetSize()2823 xPos = clientSize[2]-Size[0]2824 self.SetPosition(wx.Point(xPos,clientSize[1]))2825 2819 self._init_Imports() 2826 2820 #initialize Menu item objects (these contain lists of menu items that are enabled or disabled) … … 2835 2829 self.ExportCIF = [] 2836 2830 # 2837 # Main menu now done in DataWindow._initMenus for consistency2838 #self.GSASIIMenu = wx.MenuBar()2839 #self.dataMenuBars = [self.GSASIIMenu] # list of all menus (added to in PrefillDataMenu)2840 #self.FillMainMenu(self.GSASIIMenu)2841 #self.SetMenuBar(self.GSASIIMenu)2842 2831 self.MacroStatusList = [] # logging 2843 2832 self.Status = self.CreateStatusBar() … … 2863 2852 self.GPXtree = G2G.G2TreeCtrl(id=G2G.wxID_GPXTREE, 2864 2853 parent=self.treePanel, size=self.treePanel.GetClientSize(),style=wx.TR_DEFAULT_STYLE ) 2865 # self.treeTitle = wx.StaticText(self.treePanel, wx.ID_ANY, "GSAS-II project: ",2866 # )2867 # self.treeTitle.SetBackgroundColour(wx.Colour(230,230,150)) # add some yellow to the title2868 # treeSizer.Add(self.treeTitle,0,wx.EXPAND|wx.ALL,0)2869 2854 treeSizer.Add(self.GPXtree,1,wx.EXPAND|wx.ALL,0) 2870 2855 self.GPXtree.Bind(wx.EVT_TREE_SEL_CHANGED,self.OnDataTreeSelChanged) … … 2885 2870 2886 2871 self.dataWindow.SetupScrolling() 2887 2888 plotFrame = wx.Frame(None,-1,'GSASII Plots',size=wx.Size(700,600), \2872 2873 self.plotFrame = wx.Frame(None,-1,'GSASII Plots',size=wx.Size(700,600), \ 2889 2874 style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX) 2890 self.G2plotNB = G2plt.G2PlotNoteBook(plotFrame,G2frame=self) 2891 plotFrame.Show() 2875 self.G2plotNB = G2plt.G2PlotNoteBook(self.plotFrame,G2frame=self) 2876 self.plotFrame.Show() 2877 2878 main_pos = eval(GSASIIpath.GetConfigValue('Main_Pos')) 2879 self.SetPosition(main_pos) 2880 # if not self.IsShownOnScreen(): 2881 # self.Centre() 2882 plot_pos = eval(GSASIIpath.GetConfigValue('Plot_Pos')) 2883 self.plotFrame.SetPosition(plot_pos) 2884 # if not self.plotFrame.IsShownOnScreen(): 2885 # self.plotFrame.Centre() 2892 2886 2893 2887 def __init__(self, parent): … … 2994 2988 print('Ignoring Config Starting_directory value: '+ 2995 2989 GSASIIpath.GetConfigValue('Starting_directory')) 2990 2996 2991 2997 2992 def GetTreeItemsList(self,item): … … 3770 3765 File/Open Project menu button 3771 3766 ''' 3772 result = wx.ID_OK 3773 self.EnablePlot = False 3774 if self.GPXtree.GetChildrenCount(self.root,False): 3767 def SaveOld(): 3775 3768 if self.dataWindow: 3776 self.dataWindow.ClearData() 3769 self.dataWindow.ClearData() 3777 3770 dlg = wx.MessageDialog( 3778 3771 self, … … 3783 3776 result = dlg.ShowModal() 3784 3777 if result == wx.ID_OK: 3778 dlg.Destroy() 3785 3779 self.GPXtree.DeleteChildren(self.root) 3786 3780 self.GSASprojectfile = '' … … 3789 3783 self.G2plotNB.clear() 3790 3784 finally: 3791 dlg.Destroy()3792 if result != wx.ID_OK: return3793 3794 if not filename:3785 pass 3786 return result 3787 3788 def GetGPX(): 3795 3789 if self.LastGPXdir: 3796 3790 pth = self.LastGPXdir … … 3806 3800 finally: 3807 3801 dlg.Destroy() 3802 3803 self.EnablePlot = False 3804 result = wx.ID_OK 3805 if self.GPXtree.GetChildrenCount(self.root,False): 3806 result = SaveOld() 3807 if result != wx.ID_OK: return 3808 3809 if not filename: 3810 GetGPX() 3808 3811 else: 3809 3812 self.GSASprojectfile = os.path.splitext(filename)[0]+'.gpx' … … 3965 3968 def ExitMain(self, event): 3966 3969 '''Called if the main window is closed''' 3970 FramePos = {'Main_Pos':tuple(self.GetPosition()),'Plot_Pos':tuple(self.plotFrame.GetPosition())} 3971 GSASIIpath.SetConfigValue(FramePos) 3972 print FramePos 3973 config = G2G.GetConfigValsDocs() 3974 G2G.SaveConfigVars(config) 3967 3975 if self.G2plotNB: 3968 3976 self.G2plotNB.Destroy() … … 3971 3979 sys.exit() 3972 3980 3973 def OnFileExit(self, event):3974 '''Called in response to the File/Quit menu button'''3975 if self.G2plotNB:3976 self.G2plotNB.Destroy()3977 self.Close()3978 3981 # def OnFileExit(self, event): 3982 # '''Called in response to the File/Quit menu button''' 3983 # if self.G2plotNB: 3984 # self.G2plotNB.Destroy() 3985 # self.Close() 3986 # 3979 3987 def OnExportPeakList(self,event): 3980 3988 nptand = lambda x: np.tan(x*math.pi/180.) -
branch/2frame/GSASIIimgGUI.py
r2917 r2927 1225 1225 mainSizer.Add((5,5),0) 1226 1226 mainSizer.Add(GonioSizer(),0,WACV) 1227 G2frame.dataWindow.SetDataSize() 1227 1228 1228 1229 ################################################################################ … … 1714 1715 littleSizer.Add(frameDelete,0,WACV) 1715 1716 mainSizer.Add(littleSizer,0,) 1716 G2frame. SetDataSize()1717 G2frame.dataWindow.SetDataSize() 1717 1718 if startScroll: # reset scroll to saved position 1718 1719 G2frame.dataWindow.Scroll(0,startScroll) # set to saved scroll position … … 2152 2153 mainSizer.Add((5,10),0) 2153 2154 mainSizer.Add(DzeroSizer()) 2155 G2frame.dataWindow.SetDataSize() 2154 2156 2155 2157 ########################################################################### -
branch/2frame/GSASIImath.py
r2871 r2927 4319 4319 ''' 4320 4320 4321 class RandomDisplacementBounds(object): 4322 """random displacement with bounds""" 4323 def __init__(self, xmin, xmax, stepsize=0.5): 4324 self.xmin = xmin 4325 self.xmax = xmax 4326 self.stepsize = stepsize 4327 4328 def __call__(self, x): 4329 """take a random step but ensure the new position is within the bounds""" 4330 while True: 4331 # this could be done in a much more clever way, but it will work for example purposes 4332 steps = self.xmax-self.xmin 4333 xnew = x + np.random.uniform(-self.stepsize*steps, self.stepsize*steps, np.shape(x)) 4334 if np.all(xnew < self.xmax) and np.all(xnew > self.xmin): 4335 break 4336 return xnew 4337 4321 4338 global tsum 4322 4339 tsum = 0. … … 4513 4530 puts result F^2 in each ref[5] in refList 4514 4531 returns: 4515 delt-F*rcov*delt-F/sum(Fo^2)^2 4516 ''' 4532 delt-F*rcov*delt-F/sum(Fo^2) 4533 ''' 4534 4517 4535 global tsum 4518 4536 t0 = time.time() … … 4535 4553 tsum += (time.time()-t0) 4536 4554 return M/np.sum(refList[4]**2) 4555 4556 def MCSAcallback(x, f, fmin,accept): 4557 return not pgbar.Update(min(100.,fmin*1000), 4558 newmsg='%s%8.4f%s'%('MC/SA Residual:',fmin*1000,'%'))[0] 4559 4537 4560 4538 4561 sq8ln2 = np.sqrt(8*np.log(2)) … … 4669 4692 ifInv = SGData['SGInv'] 4670 4693 # consider replacing anneal with scipy.optimize.basinhopping 4671 results = anneal(mcsaCalc,x0,args=(refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict), 4672 schedule=MCSA['Algorithm'], full_output=True, 4673 T0=MCSA['Annealing'][0], Tf=MCSA['Annealing'][1],dwell=MCSA['Annealing'][2], 4674 boltzmann=MCSA['boltzmann'], learn_rate=0.5, 4675 quench=MCSA['fast parms'][0], m=MCSA['fast parms'][1], n=MCSA['fast parms'][2], 4676 lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',False), 4677 ranRange=MCSA.get('ranRange',0.10),autoRan=MCSA.get('autoRan',False),dlg=pgbar) 4678 mcsaCalc(results[0],refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict) 4694 if MCSA['Algorithm'] == 'Basin Hopping': 4695 import basinhopping as bs 4696 bounds = np.array(zip(lower,upper)) 4697 take_step = RandomDisplacementBounds(np.array(lower), np.array(upper)) 4698 results = bs.basinhopping(mcsaCalc,x0,take_step=take_step,disp=True,T=MCSA['Annealing'][0],stepsize=0.1, 4699 interval=20,niter=MCSA['Annealing'][2],minimizer_kwargs={'method':'L-BFGS-B','bounds':bounds, 4700 'args':(refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict)},callback=MCSAcallback) 4701 mcsaCalc(results['x'],refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict) 4702 Result = [False,False,results['fun'],0.0,]+list(results['x']) 4703 else: 4704 results = anneal(mcsaCalc,x0,args=(refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict), 4705 schedule=MCSA['Algorithm'], full_output=True, 4706 T0=MCSA['Annealing'][0], Tf=MCSA['Annealing'][1],dwell=MCSA['Annealing'][2], 4707 boltzmann=MCSA['boltzmann'], learn_rate=0.5, 4708 quench=MCSA['fast parms'][0], m=MCSA['fast parms'][1], n=MCSA['fast parms'][2], 4709 lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',False), 4710 ranRange=MCSA.get('ranRange',10.)/100.,autoRan=MCSA.get('autoRan',False),dlg=pgbar) 4711 mcsaCalc(results[0],refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict) 4712 Result = [False,False,results[1],results[2],]+list(results[0]) 4679 4713 # for ref in refs.T: 4680 4714 # print ' %4d %4d %4d %10.3f %10.3f %10.3f'%(int(ref[0]),int(ref[1]),int(ref[2]),ref[4],ref[5],ref[6]) 4681 4715 # print np.sqrt((np.sum(refs[6]**2)/np.sum(refs[4]**2))) 4682 Result = [False,False,results[1],results[2],]+list(results[0])4683 4716 Result.append(varyList) 4684 4717 return Result,tsum -
branch/2frame/GSASIIobj.py
r2911 r2927 1406 1406 'AUiso':'Atomic isotropic displacement parameter', 1407 1407 'AU([123][123])':'Atomic anisotropic displacement parameter U\\1', 1408 'Afrac': 'Atomic occupancyparameter',1408 'Afrac': 'Atomic site fraction parameter', 1409 1409 'Amul': 'Atomic site multiplicity value', 1410 1410 'AM([xyz])$' : 'Atomic magnetic moment parameter, \\1', -
branch/2frame/GSASIIpath.py
r2924 r2927 47 47 if var in configDict: 48 48 del configDict[var] 49 if parmdict[var][1] is None: continue 50 if parmdict[var][1] == '': continue 51 if parmdict[var][0] == parmdict[var][1]: continue 52 configDict[var] = parmdict[var][1] 49 if isinstance(parmdict[var],tuple): 50 configDict[var] = parmdict[var] 51 else: 52 if parmdict[var][1] is None: continue 53 if parmdict[var][1] == '': continue 54 if parmdict[var][0] == parmdict[var][1]: continue 55 configDict[var] = parmdict[var][1] 53 56 54 57 # routines for looking a version numbers in files -
branch/2frame/GSASIIphsGUI.py
r2917 r2927 1731 1731 text[3] = ' The magnetic lattice point group is '+SGData['MagPtGp'] 1732 1732 SGMagSpinBox(General,msg,text,table,OprNames,SpnFlp).Show() 1733 1734 def OnDminVal(event): 1735 event.Skip() 1736 try: 1737 val = float(dminVal.GetValue()) 1738 if val > 0.7: 1739 generalData['MagDmin'] = val 1740 except ValueError: 1741 pass 1742 dminVal.SetValue("%.4f"%(generalData['MagDmin'])) 1743 1733 1744 1734 SGData = generalData['SGData'] 1745 1735 Indx = {} … … 1772 1762 dminSizer = wx.BoxSizer(wx.HORIZONTAL) 1773 1763 dminSizer.Add(wx.StaticText(General,label=' Magnetic reflection d-min: '),0,WACV) 1774 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 1775 dminVal = wx.TextCtrl(General,value='%.4f'%(generalData['MagDmin']),style=wx.TE_PROCESS_ENTER) 1776 dminVal.Bind(wx.EVT_TEXT_ENTER,OnDminVal) 1777 dminVal.Bind(wx.EVT_KILL_FOCUS,OnDminVal) 1764 dminVal = G2G.ValidatedTxtCtrl(General,generalData,'MagDmin',nDig=(10,4),min=0.7) 1778 1765 dminSizer.Add(dminVal,0,WACV) 1779 1766 magSizer.Add(dminSizer,0,WACV) … … 1824 1811 wx.MessageBox(Text,caption=msg,style=Style) 1825 1812 wx.CallAfter(UpdateGeneral) 1826 1827 def OnVec(event): 1828 event.Skip() 1829 Obj = event.GetEventObject() 1830 ind = Indx[Obj.GetId()] 1831 val = Obj.GetValue() 1832 try: 1833 val = min(2.0,max(-1.0,float(val))) 1834 except ValueError: 1835 val = generalData['SuperVec'][0][ind] 1836 generalData['SuperVec'][0][ind] = val 1837 Obj.SetValue('%.4f'%(generalData['SuperVec'][0][ind])) 1838 1813 1839 1814 def OnVecRef(event): 1840 1815 generalData['SuperVec'][1] = Ref.GetValue() … … 1871 1846 for i,[val,show] in enumerate(zip(generalData['SuperVec'][0],ifShow)): 1872 1847 if show: 1873 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 1874 modVal = wx.TextCtrl(General,value=('%.4f'%(val)), 1875 size=wx.Size(50,20),style=wx.TE_PROCESS_ENTER) 1876 modVal.Bind(wx.EVT_TEXT_ENTER,OnVec) 1877 modVal.Bind(wx.EVT_KILL_FOCUS,OnVec) 1848 modVal = G2G.ValidatedTxtCtrl(General,generalData['SuperVec'][0],i,nDig=(10,4),min=-1.,max=2.) 1878 1849 vecSizer.Add(modVal,0,WACV) 1879 1850 Indx[modVal.GetId()] = i … … 1915 1886 wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL)) 1916 1887 1917 def OnResVal(event):1918 event.Skip()1919 try:1920 res = float(mapRes.GetValue())1921 if 0.25 <= res <= 20.:1922 Map['Resolution'] = res1923 except ValueError:1924 pass1925 mapRes.SetValue("%.2f"%(Map['Resolution'])) #reset in case of error1926 1927 1888 def OnCutOff(event): 1928 1889 event.Skip() … … 1961 1922 line2Sizer = wx.BoxSizer(wx.HORIZONTAL) 1962 1923 line2Sizer.Add(wx.StaticText(General,label=' Resolution: '),0,WACV) 1963 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 1964 mapRes = wx.TextCtrl(General,value='%.2f'%(Map['Resolution']),style=wx.TE_PROCESS_ENTER) 1965 mapRes.Bind(wx.EVT_TEXT_ENTER,OnResVal) 1966 mapRes.Bind(wx.EVT_KILL_FOCUS,OnResVal) 1924 mapRes = G2G.ValidatedTxtCtrl(General,Map,'Resolution',nDig=(10,2),min=0.25,max=20.) 1967 1925 line2Sizer.Add(mapRes,0,WACV) 1968 1926 line2Sizer.Add(wx.StaticText(General,label=' Peak cutoff %: '),0,WACV) … … 2000 1958 normElem.SetLabel(Flip['Norm element']) 2001 1959 PE.Destroy() 2002 2003 def OnResVal(event): 2004 event.Skip() 2005 try: 2006 res = float(flipRes.GetValue()) 2007 if 0.25 <= res <= 20.: 2008 Flip['Resolution'] = res 2009 except ValueError: 2010 pass 2011 flipRes.SetValue("%.2f"%(Flip['Resolution'])) #reset in case of error 2012 2013 def OnkFactor(event): 2014 event.Skip() 2015 try: 2016 res = float(kFactor.GetValue()) 2017 if 0.1 <= res <= 1.2: 2018 Flip['k-factor'] = res 2019 except ValueError: 2020 pass 2021 kFactor.SetValue("%.3f"%(Flip['k-factor'])) #reset in case of error 2022 2023 def OnkMax(event): 2024 event.Skip() 2025 try: 2026 res = float(kMax.GetValue()) 2027 if res >= 10.: 2028 Flip['k-Max'] = res 2029 except ValueError: 2030 pass 2031 kMax.SetValue("%.1f"%(Flip['k-Max'])) #reset in case of error 2032 1960 2033 1961 def OnTestHKL(event): 2034 1962 event.Skip() … … 2062 1990 line2Sizer = wx.BoxSizer(wx.HORIZONTAL) 2063 1991 line2Sizer.Add(wx.StaticText(General,label=' Resolution: '),0,WACV) 2064 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2065 flipRes = wx.TextCtrl(General,value='%.2f'%(Flip['Resolution']),style=wx.TE_PROCESS_ENTER) 2066 flipRes.Bind(wx.EVT_TEXT_ENTER,OnResVal) 2067 flipRes.Bind(wx.EVT_KILL_FOCUS,OnResVal) 1992 flipRes = G2G.ValidatedTxtCtrl(General,Flip,'Resolution',nDig=(10,2),min=0.25,max=2.) 2068 1993 line2Sizer.Add(flipRes,0,WACV) 2069 1994 line2Sizer.Add(wx.StaticText(General,label=' k-Factor (0.1-1.2): '),0,WACV) 2070 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2071 kFactor = wx.TextCtrl(General,value='%.3f'%(Flip['k-factor']),style=wx.TE_PROCESS_ENTER) 2072 kFactor.Bind(wx.EVT_TEXT_ENTER,OnkFactor) 2073 kFactor.Bind(wx.EVT_KILL_FOCUS,OnkFactor) 1995 kFactor = G2G.ValidatedTxtCtrl(General,Flip,'k-factor',nDig=(10,3),min=0.1,max=1.2) 2074 1996 line2Sizer.Add(kFactor,0,WACV) 2075 1997 line2Sizer.Add(wx.StaticText(General,label=' k-Max (>=10.0): '),0,WACV) 2076 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2077 kMax = wx.TextCtrl(General,value='%.1f'%(Flip['k-Max']),style=wx.TE_PROCESS_ENTER) 2078 kMax.Bind(wx.EVT_TEXT_ENTER,OnkMax) 2079 kMax.Bind(wx.EVT_KILL_FOCUS,OnkMax) 1998 kMax = G2G.ValidatedTxtCtrl(General,Flip,'k-Max',nDig=(10,1),min=10.) 2080 1999 line2Sizer.Add(kMax,0,WACV) 2081 2000 flipSizer.Add(line2Sizer,0,WACV) … … 2099 2018 MCSAdata['Data source'] = refList.GetValue() 2100 2019 2101 def OnDmin(event):2102 event.Skip()2103 try:2104 val = float(dmin.GetValue())2105 if 1.0 <= val < 5.0:2106 MCSAdata['dmin'] = val2107 except ValueError:2108 pass2109 dmin.SetValue("%.3f"%(MCSAdata['dmin'])) #reset in case of error2110 MCSAdata['newDmin'] = True2111 2112 2020 def OnCycles(event): 2113 2021 MCSAdata['Cycles'] = int(cycles.GetValue()) … … 2117 2025 wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL)) 2118 2026 2119 def OnSlope(event):2120 event.Skip()2121 try:2122 val = float(slope.GetValue())2123 if .25 <= val < 1.0:2124 MCSAdata['log slope'] = val2125 except ValueError:2126 pass2127 slope.SetValue("%.3f"%(MCSAdata['log slope'])) #reset in case of error2128 2129 def OnAjump(event):2130 event.Skip()2131 Obj = event.GetEventObject()2132 name,ind = Indx[Obj.GetId()]2133 try:2134 val = float(Obj.GetValue())2135 if .0 <= val <= 1.0:2136 MCSAdata[name][ind] = val2137 except ValueError:2138 pass2139 Obj.SetValue("%.3f"%(MCSAdata[name][ind]))2140 2141 2027 def OnRanStart(event): 2142 2028 MCSAdata['ranStart'] = ranStart.GetValue() … … 2145 2031 # MCSAdata['autoRan'] = autoRan.GetValue() 2146 2032 2147 def OnRanRange(event):2148 event.Skip()2149 try:2150 val = float(ranRange.GetValue())/1002151 if 0.01 <= val <= 0.99:2152 MCSAdata['ranRange'] = val2153 except ValueError:2154 pass2155 ranRange.SetValue('%.1f'%(MCSAdata['ranRange']*100.))2156 2157 2033 def OnAnneal(event): 2158 2034 event.Skip() … … 2190 2066 lineSizer.Add(refList,0,WACV) 2191 2067 lineSizer.Add(wx.StaticText(General,label=' d-min: '),0,WACV) 2192 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2193 dmin = wx.TextCtrl(General,-1,value='%.3f'%(MCSAdata['dmin']),style=wx.TE_PROCESS_ENTER) 2194 dmin.Bind(wx.EVT_TEXT_ENTER,OnDmin) 2195 dmin.Bind(wx.EVT_KILL_FOCUS,OnDmin) 2068 dmin = G2G.ValidatedTxtCtrl(General,MCSAdata,'dmin',nDig=(10,3),min=1.,max=5.) 2196 2069 lineSizer.Add(dmin,0,WACV) 2197 2070 mcsaSizer.Add(lineSizer) … … 2209 2082 ranStart.SetValue(MCSAdata.get('ranStart',False)) 2210 2083 line2Sizer.Add(ranStart,0,WACV) 2211 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2212 ranRange = wx.TextCtrl(General,-1,value='%.1f'%(MCSAdata.get('ranRange',0.10)*100),style=wx.TE_PROCESS_ENTER) 2213 ranRange.Bind(wx.EVT_TEXT_ENTER,OnRanRange) 2214 ranRange.Bind(wx.EVT_KILL_FOCUS,OnRanRange) 2084 MCSAdata['ranRange'] = MCSAdata.get('ranRange',10.) #patch for old gpx files 2085 ranRange = G2G.ValidatedTxtCtrl(General,MCSAdata,'ranRange',nDig=(10,1),min=1.,max=99.) 2215 2086 line2Sizer.Add(ranRange,0,WACV) 2216 2087 line2Sizer.Add(wx.StaticText(General,label='% of ranges. '),0,WACV) … … 2222 2093 mcsaSizer.Add((5,5),) 2223 2094 line3Sizer = wx.BoxSizer(wx.HORIZONTAL) 2224 Achoice = ['log','fast' ] #these work2095 Achoice = ['log','fast','Basin Hopping'] #these work 2225 2096 # Achoice = ['log','fast','cauchy','boltzmann'] 2226 2097 line3Sizer.Add(wx.StaticText(General,label=' MC/SA schedule: '),0,WACV) … … 2239 2110 for i,name in enumerate(Names): 2240 2111 line3Sizer.Add(wx.StaticText(General,label=name),0,WACV) 2241 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2242 Ajump = wx.TextCtrl(General,-1,value='%.3f'%(MCSAdata[parms][i]),style=wx.TE_PROCESS_ENTER) 2243 Ajump.Bind(wx.EVT_TEXT_ENTER,OnAjump) 2244 Ajump.Bind(wx.EVT_KILL_FOCUS,OnAjump) 2245 Indx[Ajump.GetId()] = [parms,i] 2112 Ajump = G2G.ValidatedTxtCtrl(General,MCSAdata[parms],i,nDig=(10,2),min=0.,max=1.) 2246 2113 line3Sizer.Add(Ajump,0,WACV) 2247 2114 elif 'log' in MCSAdata['Algorithm']: 2248 2115 line3Sizer.Add(wx.StaticText(General,label=' slope: '),0,WACV) 2249 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 2250 slope = wx.TextCtrl(General,-1,value='%.3f'%(MCSAdata['log slope']),style=wx.TE_PROCESS_ENTER) 2251 slope.Bind(wx.EVT_TEXT_ENTER,OnSlope) 2252 slope.Bind(wx.EVT_KILL_FOCUS,OnSlope) 2116 slope = G2G.ValidatedTxtCtrl(General,MCSAdata,'log slope',nDig=(10,3),min=0.25,max=1.0) 2253 2117 line3Sizer.Add(slope,0,WACV) 2118 elif 'Basin Hopping' in MCSAdata['Algorithm']: 2119 pass #TODO basinhopping controls here 2254 2120 mcsaSizer.Add(line3Sizer) 2255 2121 mcsaSizer.Add((5,5),) … … 3766 3632 wx.CallAfter(UpdateLayerData) 3767 3633 3768 def OnToler(event): #used when Laue = unknown3769 event.Skip()3770 try:3771 val = float(toler.GetValue())3772 except ValueError:3773 val = Layers['Toler']3774 Layers['Toler'] = val3775 toler.SetValue('%.3f'%(Layers['Toler']))3776 3777 3634 def OnSadpPlot(event): 3778 3635 sadpPlot.SetValue(False) … … 3868 3725 def WidthSizer(): 3869 3726 3870 def OnWidthChange(event):3871 event.Skip()3872 Obj = event.GetEventObject()3873 id = Indx[Obj]3874 try:3875 Layers['Width'][0][id] = max(0.005,min(1.0,float(Obj.GetValue())))3876 except ValueError:3877 pass3878 Obj.SetValue('%.3f'%(Layers['Width'][0][id]))3879 3880 3727 def OnRefWidth(event): 3881 3728 id = Indx[event.GetEventObject()] … … 3883 3730 3884 3731 Labels = ['a','b'] 3885 widths = Layers['Width'][0]3886 3732 flags = Layers['Width'][1] 3887 3733 widthSizer = wx.BoxSizer(wx.HORIZONTAL) 3888 3734 for i in range(2): 3889 3735 widthSizer.Add(wx.StaticText(layerData,label=u' layer width(%s) (<= 1\xb5m): '%(Labels[i])),0,WACV) 3890 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 3891 widthVal = wx.TextCtrl(layerData,value='%.3f'%(widths[i]),style=wx.TE_PROCESS_ENTER) 3892 widthVal.Bind(wx.EVT_TEXT_ENTER,OnWidthChange) 3893 widthVal.Bind(wx.EVT_KILL_FOCUS,OnWidthChange) 3894 Indx[widthVal] = i 3736 widthVal = G2G.ValidatedTxtCtrl(layerData,Layers['Width'][0],i,nDig=(10,3),min=0.005,max=1.0) 3895 3737 widthSizer.Add(widthVal,0,WACV) 3896 3738 widthRef = wx.CheckBox(layerData,label='Refine?') … … 4274 4116 if Layers['Stacking'][0] == 'recursive': 4275 4117 topLine.Add(wx.StaticText(layerData,label=' number of layers (<1022 or "infinite"): '),0,WACV) 4276 # azmthOff= G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)4118 # numLayers = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 4277 4119 numLayers = wx.TextCtrl(layerData,value=data['Layers']['Stacking'][1],style=wx.TE_PROCESS_ENTER) 4278 4120 numLayers.Bind(wx.EVT_TEXT_ENTER,OnNumLayers) … … 4340 4182 if Layers['Laue'] == 'unknown': 4341 4183 laueSizer.Add(wx.StaticText(layerData,label=' Diffraction symmetry tolerance: '),0,WACV) 4342 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 4343 toler = wx.TextCtrl(layerData,value='%.3f'%(Layers['Toler']),style=wx.TE_PROCESS_ENTER) 4344 toler.Bind(wx.EVT_TEXT_ENTER,OnToler) 4345 toler.Bind(wx.EVT_KILL_FOCUS,OnToler) 4184 toler = G2G.ValidatedTxtCtrl(layerData,Layers,'Toler',nDig=(10,3)) 4346 4185 laueSizer.Add(toler,0,WACV) 4347 4186 topSizer.Add(laueSizer,0,WACV) … … 5709 5548 G2plt.PlotStructure(G2frame,data) 5710 5549 5711 def OnZstep(event):5712 event.Skip()5713 try:5714 step = float(Zstep.GetValue())5715 if not (0.01 <= step <= 1.0):5716 raise ValueError5717 except ValueError:5718 step = drawingData['Zstep']5719 drawingData['Zstep'] = step5720 Zstep.SetValue('%.2fA'%(drawingData['Zstep']))5721 5722 5550 def OnMoveZ(event): 5723 5551 move = MoveZ.GetValue()*drawingData['Zstep'] … … 5788 5616 ZstepSizer = wx.BoxSizer(wx.HORIZONTAL) 5789 5617 ZstepSizer.Add(wx.StaticText(drawOptions,-1,' Z step:'),0,WACV) 5790 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 5791 Zstep = wx.TextCtrl(drawOptions,value='%.2f'%(drawingData['Zstep']), 5792 style=wx.TE_PROCESS_ENTER) 5793 Zstep.Bind(wx.EVT_TEXT_ENTER,OnZstep) 5794 Zstep.Bind(wx.EVT_KILL_FOCUS,OnZstep) 5618 Zstep = G2G.ValidatedTxtCtrl(drawOptions,drawingData,'Zstep',nDig=(10,2),min=0.01,max=1.0) 5795 5619 ZstepSizer.Add(Zstep,0,WACV) 5796 5620 slideSizer.Add(ZstepSizer) … … 6316 6140 wx.CallLater(100,UpdateTexture) 6317 6141 6318 def OnshToler(event):6319 event.Skip()6320 try:6321 value = float(shToler.GetValue())6322 Penalty[1] = value6323 except ValueError:6324 pass6325 shToler.SetValue('%.2f'%(Penalty[1]))6326 6327 6142 A = G2lat.cell2A(generalData['Cell'][1:7]) 6328 6143 hkls = G2lat.GenPfHKLs(10,SGData,A) … … 6335 6150 shPenalty.Add(hklList,0,WACV) 6336 6151 shPenalty.Add(wx.StaticText(Texture,wx.ID_ANY,' Zero MRD tolerance: '),0,WACV) 6337 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 6338 shToler = wx.TextCtrl(Texture,wx.ID_ANY,'%.2f'%(Penalty[1]),style=wx.TE_PROCESS_ENTER) 6339 shToler.Bind(wx.EVT_TEXT_ENTER,OnshToler) 6340 shToler.Bind(wx.EVT_KILL_FOCUS,OnshToler) 6152 shToler = G2G.ValidatedTxtCtrl(Texture,Penalty,1,nDig=(10,2),min=0.001) 6341 6153 shPenalty.Add(shToler,0,WACV) 6342 6154 return shPenalty … … 7873 7685 POData['Coef'][1] = poRef.GetValue() 7874 7686 7875 def OnPOVal(event):7876 event.Skip()7877 try:7878 mdVal = float(poVal.GetValue())7879 if mdVal > 0:7880 POData['Coef'][0] = mdVal7881 except ValueError:7882 pass7883 poVal.SetValue("%.3f"%(POData['Coef'][0]))7884 7885 7687 def OnPORange(event): 7886 7688 event.Skip() … … 7915 7717 poRef.Bind(wx.EVT_CHECKBOX,OnPORef) 7916 7718 poSizer.Add(poRef,0,WACV) 7917 # azmthOff = G2G.ValidatedTxtCtrl(G2frame.phaseDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff) 7918 poVal = wx.TextCtrl(G2frame.MCSA,-1,'%.3f'%(POData['Coef'][0]),style=wx.TE_PROCESS_ENTER) 7919 poVal.Bind(wx.EVT_TEXT_ENTER,OnPOVal) 7920 poVal.Bind(wx.EVT_KILL_FOCUS,OnPOVal) 7719 poVal = G2G.ValidatedTxtCtrl(G2frame.MCSA,POData['Coef'],0,nDig=(10,3),min=0.) 7921 7720 poSizer.Add(poVal,0,WACV) 7922 7721 poSizer.Add(wx.StaticText(G2frame.MCSA,-1,' Range: '),0,WACV) -
branch/2frame/GSASIIstrMath.py
r2895 r2927 3241 3241 if hfx+'Back;0' in varylist: # for now assume that Back;x vars to not appear in constraints 3242 3242 bBpos = varylist.index(hfx+'Back;0') 3243 dMdv[bBpos:bBpos+len(dMdb)] += dMdb 3243 dMdv[bBpos:bBpos+len(dMdb)] += dMdb #TODO crash if bck parms tossed 3244 3244 names = [hfx+'DebyeA',hfx+'DebyeR',hfx+'DebyeU'] 3245 3245 for name in varylist: -
branch/2frame/basinhopping.py
r2895 r2927 350 350 used, for example, to forcefully escape from a local minimum that 351 351 ``basinhopping`` is trapped in. 352 callback : callable, ``callback(x, f, accept)``, optional352 callback : callable, ``callback(x, f, fmin, accept)``, optional 353 353 A callback function which will be called for all minimum found. ``x`` 354 354 and ``f`` are the coordinates and function value of the trial minima, 355 and ``accept`` is whether or not that minima was accepted. This can be356 used, for example, to save the lowest N minima found. Also,355 and ``accept`` is whether or not that minima was accepted. 'fmin' is the lowest f found. 356 This can be used, for example, to save the lowest N minima found. Also, 357 357 ``callback`` can be used to specify a user defined stop criterion by 358 358 optionally returning True to stop the ``basinhopping`` routine. … … 614 614 if isinstance(callback, collections.Callable): 615 615 # should we pass a copy of x? 616 val = callback(bh.xtrial, bh.energy_trial, bh. accept)616 val = callback(bh.xtrial, bh.energy_trial, bh.storage.get_lowest()[1], bh.accept) 617 617 if val is not None: 618 618 if val: -
branch/2frame/config_example.py
r2863 r2927 133 133 ''' 134 134 135 Main_Pos = (100,100) 136 '''Main window location - will be updated & saved when user moves 137 it. If position is outside screen then it will be repositioned to default 138 ''' 139 Plot_Pos = (200,200) 140 '''Plot window location - will be updated & saved when user moves it 141 these widows. If position is outside screen then it will be repositioned to default 142 ''' 143 135 144 Tick_length = 8.0 136 145 '''Specifies the length of phase tick marks in pixels. Default is 8.'''
Note: See TracChangeset
for help on using the changeset viewer.