Changeset 4196


Ignore:
Timestamp:
Dec 6, 2019 4:50:36 AM (4 years ago)
Author:
vondreele
Message:

ad fullrmc dialog for set up
comment out & skip W plot update for d-plots & q-plots (they crash for TOF data)
put lower bounds on background single peak coefficients - avoids crash if refine negative
add MakePDB routine for fullrmc setup

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r4195 r4196  
    11731173        parent.Raise()
    11741174        self.EndModal(wx.ID_OK)
     1175       
     1176class SetUpFullrmcDialog(wx.Dialog):
     1177    ''' Get from user the super cell size & selected histogram to make various files
     1178    '''
     1179    def __init__(self,parent,Name,Phase):
     1180        title = 'fullrmc setup'
     1181        wx.Dialog.__init__(self,parent,wx.ID_ANY,title,
     1182            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     1183        self.panel = wxscroll.ScrolledPanel(self)         #just a dummy - gets destroyed in Draw!
     1184        self.Name = Name
     1185        self.Phase = Phase
     1186        self.SuperCell = [1,1,1]
     1187        self.aTypes = self.Phase['General']['AtomTypes']
     1188        self.atSeq = self.aTypes[:]
     1189#        self.histogram = ''
     1190#        self.metadata = {'title':'none','owner':'no one','date':str(time.ctime()),
     1191#                         'material':'nothing','comment':'none ','source':'nowhere'}
     1192        self.Draw()
     1193       
     1194    def Draw(self):
     1195       
     1196#        def OnHisto(event):
     1197#            self.histogram = histo.GetStringSelection()
     1198           
     1199        def OnAtSel(event):
     1200            Obj = event.GetEventObject()
     1201            itype = Indx[Obj.GetId()]
     1202            tid = Obj.GetSelection()
     1203            if itype < nTypes-1:
     1204                if itype == tid:
     1205                    tid += 1
     1206                self.atSeq = G2lat.SwapItems(self.atSeq,itype,tid)
     1207            wx.CallAfter(self.Draw)
     1208       
     1209        self.panel.Destroy()
     1210        self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE)
     1211        mainSizer = wx.BoxSizer(wx.VERTICAL)
     1212        mainSizer.Add(wx.StaticText(self.panel,label=' Setup for: %s'%self.Name),0,WACV)
     1213        superSizer = wx.BoxSizer(wx.HORIZONTAL)
     1214        axes = ['X','Y','Z']
     1215        for i,ax in enumerate(axes):
     1216            superSizer.Add(wx.StaticText(self.panel,label=' %s-axis: '%ax),0,WACV)
     1217            superSizer.Add(G2G.ValidatedTxtCtrl(self.panel,self.SuperCell,i,min=1,max=15,size=(50,25)),0,WACV)
     1218        mainSizer.Add(superSizer,0,WACV)
     1219        nTypes = len(self.aTypes)
     1220        atmChoice = wx.BoxSizer(wx.HORIZONTAL)
     1221        atmChoice.Add(wx.StaticText(self.panel,label=' Set atom ordering: '),0,WACV)
     1222        Indx = {}
     1223        for iType in range(nTypes):
     1224            atChoice = self.atSeq[iType:]
     1225            atmSel = wx.ComboBox(self.panel,choices=atChoice,style=wx.CB_DROPDOWN|wx.TE_READONLY)
     1226            atmSel.SetStringSelection(self.atSeq[iType])
     1227            atmSel.Bind(wx.EVT_COMBOBOX,OnAtSel)
     1228            Indx[atmSel.GetId()] = iType
     1229            atmChoice.Add(atmSel,0,WACV)
     1230        mainSizer.Add(atmChoice,0,WACV)
     1231#        histograms = self.Phase['Histograms']
     1232#        histNames = list(histograms.keys())
     1233#        mainSizer.Add(wx.StaticText(self.panel,label=' Select one histogram for processing:'),0,WACV)
     1234#        histo = wx.ComboBox(self.panel,choices=histNames,style=wx.CB_DROPDOWN|wx.TE_READONLY)       
     1235#        histo.Bind(wx.EVT_COMBOBOX,OnHisto)
     1236#        mainSizer.Add(histo,0,WACV)
     1237#        metalist = ['title','owner','material','comment','source']
     1238#        metaSizer = wx.FlexGridSizer(0,2,5,5)
     1239#        for item in metalist:
     1240#            metaSizer.Add(wx.StaticText(self.panel,label=' Metadata item: '+item+' '),0,WACV)
     1241#            metaSizer.Add(G2G.ValidatedTxtCtrl(self.panel,self.metadata,item),0,WACV)
     1242#        mainSizer.Add(metaSizer,0,WACV)
     1243        mainSizer.Add(wx.StaticText(self.panel,label=' WARNING: this can take time - be patient'),0,WACV)
     1244        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     1245        OKBtn = wx.Button(self.panel,-1,"OK")
     1246        OKBtn.Bind(wx.EVT_BUTTON, self.OnOK)
     1247        btnSizer.Add(OKBtn)           
     1248       
     1249        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
     1250        self.panel.SetSizer(mainSizer)
     1251        size = np.array(self.GetSize())
     1252        self.panel.SetupScrolling()
     1253        self.panel.SetAutoLayout(1)
     1254        size = [size[0]-5,size[1]-20]       #this fiddling is needed for older wx!
     1255        self.panel.SetSize(size)
     1256       
     1257    def GetData(self):
     1258        'Returns the values from the dialog'
     1259        return self.SuperCell,self.atSeq
     1260       
     1261    def OnOK(self,event):
     1262        parent = self.GetParent()
     1263        parent.Raise()
     1264        self.EndModal(wx.ID_OK)
     1265       
    11751266           
    11761267
     
    44574548        pName = generalData['Name'].replace(' ','_')
    44584549        if G2frame.RMCchoice == 'fullrmc':
     4550            dlg = SetUpFullrmcDialog(G2frame,Name=pName,Phase=data)
     4551            if dlg.ShowModal() == wx.ID_OK:
     4552                superCell,atSeq = dlg.GetData()
     4553#                    Progress
     4554                print(G2pwd.MakePDB(G2frame,pName,data,atSeq,superCell)+ ' written')
     4555                print('fullrmc file build completed')
     4556            else:
     4557                pass
     4558            dlg.Destroy()         
    44594559            rundata = '''
    44604560##########################################################################################
     
    45814681            finally:
    45824682                dlg.Destroy()
    4583                
    4584            
    45854683        else:
    45864684            rmcfile = G2fl.find('rmcprofile.exe',GSASIIpath.path2GSAS2)
  • trunk/GSASIIplot.py

    r4185 r4196  
    26662666        else:
    26672667            plotItem = plottingItem
     2668            if Page.plotStyle['dPlot'] or Page.plotStyle['qPlot']:
     2669                print("Skipping plot, can't do this for d-plots or q-plots!")
     2670                return           
    26682671        xye = np.array(ma.getdata(Histograms[plotItem]['Data'])) # strips mask
    26692672        xye0 = Histograms[plotItem]['Data'][0]
    2670         if Page.plotStyle['qPlot']:
    2671             X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye0)
    2672             Ibeg = np.searchsorted(X,2.*np.pi/G2lat.Pos2dsp(Parms,limits[1][0]))
    2673             Ifin = np.searchsorted(X,2.*np.pi/G2lat.Pos2dsp(Parms,limits[1][1]))
    2674         elif Page.plotStyle['dPlot']:
    2675             X = G2lat.Pos2dsp(Parms,xye0)
    2676             Ibeg = np.searchsorted(X,G2lat.Pos2dsp(Parms,limits[1][1]))
    2677             Ifin = np.searchsorted(X,G2lat.Pos2dsp(Parms,limits[1][0]))
    2678         else:
    2679             X = copy.deepcopy(xye0)
    2680             Ibeg = np.searchsorted(X,limits[1][0])
    2681             Ifin = np.searchsorted(X,limits[1][1])
     2673#        if Page.plotStyle['qPlot']:
     2674#            X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye0)
     2675#            Ibeg = np.searchsorted(X,2.*np.pi/G2lat.Pos2dsp(Parms,limits[1][0]))
     2676#            Ifin = np.searchsorted(X,2.*np.pi/G2lat.Pos2dsp(Parms,limits[1][1]))
     2677#        elif Page.plotStyle['dPlot']:
     2678#            X = G2lat.Pos2dsp(Parms,xye0)
     2679#            Ibeg = np.searchsorted(X,G2lat.Pos2dsp(Parms,limits[1][1]))
     2680#            Ifin = np.searchsorted(X,G2lat.Pos2dsp(Parms,limits[1][0]))
     2681#        else:
     2682        X = copy.deepcopy(xye0)
     2683        Ibeg = np.searchsorted(X,limits[1][0])
     2684        Ifin = np.searchsorted(X,limits[1][1])
    26822685        if Page.plotStyle['sqrtPlot']:
    26832686            olderr = np.seterr(invalid='ignore') #get around sqrt(-ve) error
  • trunk/GSASIIpwd.py

    r4195 r4196  
    929929        try:
    930930            pkP = parmDict[pfx+'BkPkpos;'+str(iD)]
    931             pkI = parmDict[pfx+'BkPkint;'+str(iD)]
    932             pkS = parmDict[pfx+'BkPksig;'+str(iD)]
    933             pkG = parmDict[pfx+'BkPkgam;'+str(iD)]
     931            pkI = max(parmDict[pfx+'BkPkint;'+str(iD)],0.1)
     932            pkS = max(parmDict[pfx+'BkPksig;'+str(iD)],1.)
     933            pkG = max(parmDict[pfx+'BkPkgam;'+str(iD)],0.1)
    934934            if 'C' in dataType:
    935935                Wd,fmin,fmax = getWidthsCW(pkP,pkS,pkG,.002)
     
    10621062        try:
    10631063            pkP = parmDict[hfx+'BkPkpos;'+str(iD)]
    1064             pkI = parmDict[hfx+'BkPkint;'+str(iD)]
    1065             pkS = parmDict[hfx+'BkPksig;'+str(iD)]
    1066             pkG = parmDict[hfx+'BkPkgam;'+str(iD)]
     1064            pkI = max(parmDict[hfx+'BkPkint;'+str(iD)],0.1)
     1065            pkS = max(parmDict[hfx+'BkPksig;'+str(iD)],1.0)
     1066            pkG = max(parmDict[hfx+'BkPkgam;'+str(iD)],0.1)
    10671067            if 'C' in dataType:
    10681068                Wd,fmin,fmax = getWidthsCW(pkP,pkS,pkG,.002)
     
    22062206    fl.close()
    22072207    return fname
     2208
     2209def MakePDB(G2frame,Name,Phase,Atseq,Supercell):
     2210    generalData = Phase['General']
     2211    Cell = generalData['Cell'][1:7]
     2212    Trans = np.eye(3)*np.array(Supercell)
     2213    newPhase = copy.deepcopy(Phase)
     2214    newPhase['General']['SGData'] = G2spc.SpcGroup('P 1')[1]
     2215    newPhase['General']['Cell'][1:] = G2lat.TransformCell(Cell,Trans.T)
     2216    newPhase,Atcodes = G2lat.TransformPhase(Phase,newPhase,Trans,np.zeros(3),np.zeros(3),ifMag=False)
     2217    Atoms = newPhase['Atoms']
     2218    Cell = newPhase['General']['Cell'][1:7]
     2219    A,B = G2lat. cell2AB(Cell)
     2220    fname = Name+'.pdb'
     2221    fl = open(fname,'w')
     2222    fl.write('REMARK    this file is generated using GSASII\n')
     2223    fl.write('CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f P 1           1\n'%(
     2224            Cell[0],Cell[1],Cell[2],Cell[3],Cell[4],Cell[5]))
     2225    fl.write('ORIGX1      1.000000  0.000000  0.000000        0.00000\n')
     2226    fl.write('ORIGX2      0.000000  1.000000  0.000000        0.00000\n')
     2227    fl.write('ORIGX3      0.000000  0.000000  1.000000        0.00000\n')
     2228
     2229    Natm = np.core.defchararray.count(np.array(Atcodes),'+')
     2230    Natm = np.count_nonzero(Natm-1)
     2231    nat = 0
     2232    for atm in Atseq:
     2233        for iat,atom in enumerate(Atoms):
     2234            if atom[1] == atm:
     2235                nat += 1
     2236                XYZ = np.inner(A,np.array(atom[3:6])-0.5)    #shift origin to middle & make Cartesian
     2237#ATOM      1 Ni   RMC     1     -22.113 -22.113 -22.113  1.00  0.00          ni                     
     2238                fl.write('ATOM  %5d %-4s RMC%6d%12.3f%8.3f%8.3f  1.00  0.00          %-2s\n'%(       
     2239                        nat,atom[0],nat,XYZ[0],XYZ[1],XYZ[2],atom[1]))
     2240    fl.close()
     2241    return fname
    22082242   
    22092243################################################################################
Note: See TracChangeset for help on using the changeset viewer.