Changeset 4220


Ignore:
Timestamp:
Dec 21, 2019 6:41:42 AM (22 months ago)
Author:
vondreele
Message:

swap order of binds in ValidatedTextCtrl? - might work better?routines
enhancements to RMCProfile file preparation

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4213 r4220  
    587587        # display the last saved value, if an expression
    588588        self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeaveWindow)
     589        self.Bind(wx.EVT_KILL_FOCUS, self._onLoseFocus)
    589590        self.Bind(wx.EVT_TEXT_ENTER, self._onLoseFocus)
    590         self.Bind(wx.EVT_KILL_FOCUS, self._onLoseFocus)
    591591        # patch for wx 2.9 on Mac
    592592        i,j= wx.__version__.split('.')[0:2]
  • trunk/GSASIIphsGUI.py

    r4210 r4220  
    10891089    def __init__(self,parent,Name,Phase):
    10901090        title = 'RMCProfile setup'
    1091         wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=(500,500),
     1091        wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=(700,500),
    10921092            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    10931093        self.panel = wxscroll.ScrolledPanel(self)         #just a dummy - gets destroyed in Draw!
     
    10961096        self.SuperCell = [1,1,1]
    10971097        self.UseSampBrd = [True,True]
    1098         self.aTypes = self.Phase['General']['AtomTypes']
    1099         self.atSeq = self.aTypes[:]
    1100         self.histogram = ''
    1101         self.files = {'Neutron real space data; G(r): ':['',0.01,'G(R)'],
    1102                       'Neutron reciprocal space data; F(Q): ':['',0.01,'F(Q)'],
    1103                       'Neutron reciprocal space data; S(Q): ':['',0.01,'S(Q)'],
    1104                       'Xray real space data; G(r): ':['',0.01,'G(R)'],
    1105                       'Xray reciprocal space data; F(Q): ':['',0.01,'F(Q)'],}
     1098        Atypes = self.Phase['General']['AtomTypes']
     1099        self.aTypes = dict(zip(Atypes,len(Atypes)*[0.10,]))
     1100        self.atSeq = list(self.aTypes.keys())
     1101        lenA = len(self.atSeq)
     1102        self.Pairs = []
     1103        for pair in [[' %s-%s'%(self.atSeq[i],self.atSeq[j]) for j in range(i,lenA)] for i in range(lenA)]:
     1104            self.Pairs += pair
     1105        self.Pairs = dict(zip(self.Pairs,len(self.Pairs)*[0.0,]))
     1106        self.histogram = ['',1.0]
     1107        self.files = {'Neutron real space data; G(r): ':['',0.05,'G(r)','RMC',],
     1108                      'Neutron reciprocal space data; F(Q): ':['',0.05,'F(Q)','RMC',],
     1109                      'Neutron reciprocal space data; S(Q): ':['',0.05,'S(Q)','RMC',],
     1110                      'Xray real space data; G(r): ':['',0.01,'G(r)','RMC',],
     1111                      'Xray reciprocal space data; F(Q): ':['',0.01,'F(Q)','RMC',],}
    11061112        self.metadata = {'title':'none','owner':'no one','date':str(time.ctime()),'temperature':'300K',
    11071113            'material':'nothing','phase':'vacuum','comment':'none ','source':'nowhere'}
     
    11111117       
    11121118        def OnHisto(event):
    1113             self.histogram = histo.GetStringSelection()
     1119            self.histogram[0] = histo.GetStringSelection()
    11141120           
    11151121        def OnAtSel(event):
     
    11441150            self.Draw()
    11451151           
    1146        
     1152        def OnFileFormat(event):
     1153            Obj = event.GetEventObject()
     1154            fil = Indx[Obj.GetId()]
     1155            self.files[fil][3] = Obj.GetStringSelection()
     1156       
     1157        Indx = {}
    11471158        self.panel.Destroy()
    1148         self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE,size=(500,500))
     1159        self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE,size=(700,500))
    11491160        mainSizer = wx.BoxSizer(wx.VERTICAL)
    11501161        mainSizer.Add(wx.StaticText(self.panel,label=' Setup for: %s'%self.Name),0,WACV)
     
    11561167        mainSizer.Add(superSizer,0,WACV)
    11571168        nTypes = len(self.aTypes)
    1158         atmChoice = wx.BoxSizer(wx.HORIZONTAL)
     1169        atmChoice = wx.FlexGridSizer(nTypes+1,5,5)
    11591170        atmChoice.Add(wx.StaticText(self.panel,label=' Set atom ordering: '),0,WACV)
    1160         Indx = {}
    11611171        for iType in range(nTypes):
    11621172            atChoice = self.atSeq[iType:]
     
    11661176            Indx[atmSel.GetId()] = iType
    11671177            atmChoice.Add(atmSel,0,WACV)
     1178        atmChoice.Add(wx.StaticText(self.panel,label=' Set max shift: '),0,WACV)
     1179        for iType in range(nTypes):
     1180            atId = self.atSeq[iType]
     1181            atmChoice.Add(G2G.ValidatedTxtCtrl(self.panel,self.aTypes,atId,min=0.,max=1.),0,WACV)
    11681182        mainSizer.Add(atmChoice,0,WACV)
     1183        mainSizer.Add(wx.StaticText(self.panel,label=' Set minimum distances for:'),0,WACV)
     1184        pairSizer = wx.FlexGridSizer(len(self.Pairs),5,5)
     1185        for pair in self.Pairs:
     1186            pairSizer.Add(wx.StaticText(self.panel,label=pair),0,WACV)
     1187        for pair in self.Pairs:
     1188            pairSizer.Add(G2G.ValidatedTxtCtrl(self.panel,self.Pairs,pair,min=0.,max=10.,size=(50,25)),0,WACV)
     1189        mainSizer.Add(pairSizer,0,WACV)
    11691190        histograms = self.Phase['Histograms']
    11701191        histNames = list(histograms.keys())
    11711192        mainSizer.Add(wx.StaticText(self.panel,label=' Select one histogram for Bragg processing:'),0,WACV)
    1172         histo = wx.ComboBox(self.panel,choices=histNames,style=wx.CB_DROPDOWN|wx.TE_READONLY)       
     1193        histoSizer = wx.BoxSizer(wx.HORIZONTAL)
     1194        histo = wx.ComboBox(self.panel,choices=histNames,style=wx.CB_DROPDOWN|wx.TE_READONLY)
     1195        histo.SetStringSelection(self.histogram[0])
    11731196        histo.Bind(wx.EVT_COMBOBOX,OnHisto)
    1174         mainSizer.Add(histo,0,WACV)
     1197        histoSizer.Add(histo,0,WACV)
     1198        histoSizer.Add(wx.StaticText(self.panel,label=' Weight '),0,WACV)
     1199        histoSizer.Add(G2G.ValidatedTxtCtrl(self.panel,self.histogram,1,min=0.,max=10000.,size=(50,25)),0,WACV)
     1200       
     1201        mainSizer.Add(histoSizer,0,WACV)
    11751202        samSizer = wx.BoxSizer(wx.HORIZONTAL)
    11761203        samSize = wx.CheckBox(self.panel,label=' Use size broadening?')
     
    11831210        samSizer.Add(strain,0,WACV)
    11841211        mainSizer.Add(samSizer,0,WACV)
    1185         mainSizer.Add(wx.StaticText(self.panel,label=' Select data for processing:'),0,WACV)
    1186         fileSizer = wx.FlexGridSizer(2,5,5)
     1212        title = ' Select data for processing:'
     1213        mainSizer.Add(wx.StaticText(self.panel,label=title),0,WACV)
     1214        fileSizer = wx.FlexGridSizer(5,5,5)
     1215        Formats = ['RMC','GUDRUN','STOG']
    11871216        for fil in self.files:
    11881217            filSel = wx.Button(self.panel,label='Select')
     
    11901219            Indx[filSel.GetId()] = fil
    11911220            fileSizer.Add(filSel,0,WACV)
     1221            if self.files[fil][0]:
     1222                fileSizer.Add(wx.StaticText(self.panel,label=' Format, Weight: '),0,WACV)
     1223                nform = 3
     1224                if 'Xray' in fil: nform = 1
     1225                fileFormat = wx.ComboBox(self.panel,choices=Formats[:nform],style=wx.CB_DROPDOWN|wx.TE_READONLY)
     1226                fileFormat.SetStringSelection(self.files[fil][3])
     1227                Indx[fileFormat.GetId()] = fil
     1228                fileFormat.Bind(wx.EVT_COMBOBOX,OnFileFormat)
     1229                fileSizer.Add(fileFormat,0,WACV)
     1230                fileSizer.Add(G2G.ValidatedTxtCtrl(self.panel,self.files[fil],1),0,WACV)
    11921231            fileSizer.Add(wx.StaticText(self.panel,label=fil+self.files[fil][0]),0,WACV)
     1232            if not self.files[fil][0]:
     1233                fileSizer.Add((5,5),0)
     1234                fileSizer.Add((5,5),0)
     1235                fileSizer.Add((5,5),0)
    11931236        mainSizer.Add(fileSizer,0,WACV)
    11941237        mainSizer.Add(wx.StaticText(self.panel,label=' Enter metadata items:'),0,WACV)
     
    12151258    def GetData(self):
    12161259        'Returns the values from the dialog'
    1217         return self.SuperCell,self.histogram,self.metadata,self.atSeq,self.UseSampBrd,self.files
     1260        return self.SuperCell,self.histogram,self.UseSampBrd,       \
     1261            self.atSeq,self.aTypes,self.Pairs,self.files,self.metadata
    12181262       
    12191263    def OnOK(self,event):
     
    46514695            dlg = SetUpRMCProfileDialog(G2frame,Name=pName,Phase=data)
    46524696            if dlg.ShowModal() == wx.ID_OK:
    4653                 superCell,histoName,meta,atSeq,useSamBrd,files = dlg.GetData()
    4654                 PWId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,histoName)
     4697                superCell,histoName,useSamBrd,atSeq,aTypes,atPairs,files,meta = dlg.GetData()
     4698                PWId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,histoName[0])
    46554699                if PWId:
    46564700                    print(G2pwd.MakeInst(G2frame,pName,data,useSamBrd,PWId)+ ' written')
     
    46624706                    print(G2pwd.MakeBragg(G2frame,pName,data,PWId)+ ' written')
    46634707                    print(G2pwd.MakeRMC6f(G2frame,pName,data,meta,atSeq,superCell,PWId)+ ' written')
    4664                     print(G2pwd.MakeRMCPdat(G2frame,pName,data,meta,atSeq,superCell,files,PWId)+ ' written')
     4708                    print(G2pwd.MakeRMCPdat(G2frame,pName,data,meta,atSeq,aTypes,atPairs,superCell,files,PWId,histoName[1])+ ' written')
    46654709                    print('RMCProfile file build completed')
    46664710                else:
     
    47894833                return
    47904834           
     4835            ifXray = False
     4836            try:
     4837                datFile = open(os.path.join(path,pName+'.dat'),'r')
     4838                datLines = datFile.readlines()
     4839                datFile.close()
     4840                for line in datLines:
     4841                    if 'xray' in line:
     4842                        ifXray = True
     4843            except:
     4844                pass
    47914845            files =  {'_PDF1.csv':[],'_PDFpartials.csv':[],'_SQ1.csv':[],'_XFQ1.csv':[],
    47924846                      '_SQ1partials.csv':[],'_FQ1.csv':[],'_FT_XFQ1.csv':[],
     
    48194873                        Ycalc.append(float(items[2]))
    48204874                    Yobs = np.array([X,Yobs])
    4821                     Ycalc = np.array([X,Ycalc])                       
     4875                    Ycalc = np.array([X,Ycalc])
     4876                    if 'bragg' in label and ifXray:
     4877                        Labels[label][0] = r'$\mathsf{2\theta ,deg}$'
     4878                        Labels[label][1] = 'Intensity'
    48224879                    G2plt.PlotXY(G2frame,[Yobs,Ycalc],labelX=Labels[label][0],
    48234880                        labelY=Labels[label][1],newPlot=True,Title=Labels[label][2]+pName,
  • trunk/GSASIIpwd.py

    r4210 r4220  
    22432243    return fname
    22442244
    2245 def MakeRMCPdat(G2frame,Name,Phase,Meta,Atseq,Supercell,Files,PWId):
    2246     fname = Name+'.testdat'
     2245def MakeRMCPdat(G2frame,Name,Phase,Meta,Atseq,Atypes,atPairs,Supercell,Files,PWId,BraggWt):
     2246    PWDdata = G2frame.GetPWDRdatafromTree(PWId)
     2247    inst = PWDdata['Instrument Parameters'][0]
     2248    refList = PWDdata['Reflection Lists'][Name]['RefList']
     2249    dMin = refList[-1][4]
     2250    gsasType = 'xray2'
     2251    if 'T' in inst['Type'][1]:
     2252        gsasType = 'gsas3'
     2253    elif 'X' in inst['Type'][1]:
     2254        XFF = G2elem.GetFFtable(Atseq)
     2255        Xfl = open(Name+'.xray','w')
     2256        for atm in Atseq:
     2257            fa = XFF[atm]['fa']
     2258            fb = XFF[atm]['fb']
     2259            fc = XFF[atm]['fc']
     2260            Xfl.write('%2s  %8.4f%8.4f%8.4f%8.4f%8.4f%8.4f%8.4f%8.4f%8.4f\n'%(
     2261                    atm.upper(),fa[0],fb[0],fa[1],fb[1],fa[2],fb[2],fa[3],fb[3],fc))
     2262        Xfl.close()
     2263    lenA = len(Atseq)
     2264    Pairs = []
     2265    for pair in [[' %s-%s'%(Atseq[i],Atseq[j]) for j in range(i,lenA)] for i in range(lenA)]:
     2266        Pairs += pair
     2267    pairMin = [atPairs[pair] for pair in Pairs]
     2268    maxMoves = [Atypes[atm] for atm in Atseq]
     2269    fname = Name+'.dat'
    22472270    fl = open(fname,'w')
     2271    fl.write(' %% hand edit the following as needed\n')
    22482272    fl.write('TITLE :: '+Name+'\n')
    22492273    fl.write('MATERIAL :: '+Meta['material']+'\n')
     
    22512275    fl.write('TEMPERATURE :: '+str(Meta['temperature'])+'\n')
    22522276    fl.write('INVESTIGATOR :: '+Meta['owner']+'\n')
    2253     fl.write(' %% edit the following as needed\n')
    2254     fl.write('MINIMUM_DISTANCES ::   4.00  1.37  2.0    Angstrom\n')
    2255     fl.write('MAXIMUM_MOVES ::   0.05  0.10 Angstrom\n')
     2277    minD = ' '.join(['%6.3f'%dist for dist in pairMin])
     2278    fl.write('MINIMUM_DISTANCES ::   %s  Angstrom\n'%minD)
     2279    maxMv = ' '.join(['%6.3f'%mov for mov in maxMoves])
     2280    fl.write('MAXIMUM_MOVES ::   %s Angstrom\n'%maxMv)
    22562281    fl.write('R_SPACING ::  0.0200 Angstrom\n')
    22572282    fl.write('PRINT_PERIOD :: 100\n')
    22582283    fl.write('TIME_LIMIT ::     10.00 MINUTES\n')
    22592284    fl.write('SAVE_PERIOD ::     1.00 MINUTES\n')
     2285    fl.write('\n')
    22602286    fl.write('ATOMS :: '+' '.join(Atseq)+'\n')
     2287    fl.write('\n')
    22612288    fl.write('FLAGS ::\n')
    22622289    fl.write('  > NO_MOVEOUT\n')
    22632290    fl.write('  > NO_SAVE_CONFIGURATIONS\n')
    22642291    fl.write('  > NO_RESOLUTION_CONVOLUTION\n')
     2292    fl.write('\n')
    22652293    fl.write('INPUT_CONFIGURATION_FORMAT ::  rmc6f\n')
    22662294    fl.write('SAVE_CONFIGURATION_FORMAT  ::  rmc6f\n')
    2267    
    2268    
    2269    
    2270    
     2295    for File in Files:
     2296        if Files[File][0]:
     2297            fl.write('\n')
     2298            fl.write('%s ::\n'%File.split(';')[0].upper().replace(' ','_'))
     2299            fl.write('  > FILENAME :: %s\n'%Files[File][0])
     2300            fl.write('  > DATA_TYPE :: %s\n'%Files[File][2])
     2301            fl.write('  > FIT_TYPE :: %s\n'%Files[File][2])
     2302            fl.write('  > START_POINT :: 1\n')
     2303            fl.write('  > END_POINT :: 3000\n')
     2304            fl.write('  > CONSTANT_OFFSET 0.000\n')
     2305            fl.write('  > WEIGHT :: %.4f\n'%Files[File][1])
     2306            if 'reciprocal' in File:
     2307                fl.write('  > CONVOLVE ::\n')
     2308                fl.write('  > NO_FITTED_SCALE\n')
     2309            fl.write('  > NO_FITTED_OFFSET\n')
     2310            if Files[File][3] !='RMC':
     2311                fl.write('  > %s\n'%Files[File][3])
     2312    fl.write('BRAGG ::\n')
     2313    fl.write('  > BRAGG_SHAPE :: %s\n'%gsasType)
     2314    fl.write('  > RECALCUATE\n')
     2315    fl.write('  > DMIN :: %.2f\n'%(dMin-0.02))
     2316    fl.write('  > WEIGHT :: %10.3f\n'%BraggWt)
     2317    fl.write('\n')
     2318    fl.write('END  ::\n')
    22712319    fl.close()
    22722320    return fname
Note: See TracChangeset for help on using the changeset viewer.