Changeset 4060


Ignore:
Timestamp:
Jul 14, 2019 6:11:34 PM (2 years ago)
Author:
toby
Message:

Work on Index Unit Cell display: narrower, allow dragging limits, add cell incr for spinners; Add run PSEUDOLATTICE; Add checkBox to MultiColumnSelection? (alternate to grid)

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4045 r4060  
    29012901    after reading the selection. If the dialog cannot be shown because a very old
    29022902    version of wxPython is in use, <dlg>.Selection will be None.
     2903
     2904    If checkLbl is provided with a value, then a set of check buttons starts the table
     2905    and <dlg>.Selections has the checked rows.
    29032906   
    29042907    :param wx.Frame parent: the parent frame (or None)
     
    29112914    :param list colWidths: a list of int values specifying the column width for each
    29122915      column in the table (pixels). There must be a value for every column label (colLabels).
     2916    :param str checkLbl: A label for a row of checkboxes added at the beginning of the table
    29132917    :param int height: an optional height (pixels) for the table (defaults to 400)
     2918    :param bool centerCols: if True, items in each column are centered. Default is False
    29142919   
    29152920    Example use::
     
    29252930   
    29262931    '''
    2927     def __init__(self, parent, title, colLabels, choices, colWidths, height=400, *args, **kw):
     2932    def __init__(self, parent, title, colLabels, choices, colWidths, checkLbl="",
     2933                     height=400, centerCols=False, *args, **kw):
    29282934        if len(colLabels) != len(colWidths):
    29292935            raise ValueError('Length of colLabels) != colWidths')
     
    29332939                           style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
    29342940                           size=(sizex,height), **kw)
     2941        self.Selections = len(choices)*[False]
    29352942        try:
    29362943            from wx.lib.wordwrap import wordwrap
     
    29392946            self.Selection = None
    29402947            return
     2948        self.Selection = -1
    29412949        mainSizer = wx.BoxSizer(wx.VERTICAL)
    29422950        self.list = ULC.UltimateListCtrl(self, agwStyle=ULC.ULC_REPORT|ULC.ULC_HAS_VARIABLE_ROW_HEIGHT
    2943                                          |ULC.ULC_HRULES|ULC.ULC_SINGLE_SEL)
     2951                                         |ULC.ULC_HRULES|ULC.ULC_HRULES|ULC.ULC_SINGLE_SEL)
     2952        if centerCols:
     2953            colPosition = ULC.ULC_FORMAT_CENTER
     2954        else:
     2955            colPosition = ULC.ULC_FORMAT_LEFT
     2956           
     2957        if checkLbl:
     2958            self.list.InsertColumn(0, checkLbl, width=8*len(checkLbl), format=colPosition)
     2959            inc = 1
     2960        else:
     2961            inc = 0
    29442962        for i,(lbl,wid) in enumerate(zip(colLabels, colWidths)):
    2945             self.list.InsertColumn(i, lbl, width=wid)
     2963            self.list.InsertColumn(i+inc, lbl, width=wid, format=colPosition)
    29462964        for i,item in enumerate(choices):
    2947             self.list.InsertStringItem(i, item[0])
     2965            if checkLbl:
     2966                def OnCheck(event,row=i):
     2967                    self.Selections[row] = event.EventObject.GetValue()
     2968                c = wx.CheckBox(self.list)
     2969                c.Bind(wx.EVT_CHECKBOX,OnCheck)
     2970                self.list.InsertStringItem(i, "")
     2971                citem = self.list.GetItem(i,0)
     2972                citem.SetWindow(c)
     2973                self.list.SetItem(citem)
     2974                self.list.SetStringItem(i, 1, item[0])
     2975            else:
     2976                self.list.InsertStringItem(i, item[0])
    29482977            for j,item in enumerate(item[1:len(colLabels)]):
    29492978                item = wordwrap(StripIndents(item,True), colWidths[j+1], wx.ClientDC(self))
    2950                 self.list.SetStringItem(i,1+j, item)
     2979                self.list.SetStringItem(i,1+j+inc, item)
    29512980        # make buttons
    29522981        mainSizer.Add(self.list, 1, wx.EXPAND|wx.ALL, 1)
     
    29552984        OKbtn.SetDefault()
    29562985        btnsizer.Add(OKbtn)
    2957         btn = wx.Button(self, wx.ID_CLOSE,"Cancel")
    2958         btnsizer.Add(btn)
     2986        if not checkLbl:
     2987            btn = wx.Button(self, wx.ID_CLOSE,"Cancel")
     2988            btnsizer.Add(btn)
    29592989        mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
    29602990        # bindings for close of window, double-click,...
    2961         OKbtn.Bind(wx.EVT_BUTTON,self._onSelect)
    2962         btn.Bind(wx.EVT_BUTTON,self._onClose)
    29632991        self.Bind(wx.EVT_CLOSE, self._onClose)
    2964         self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._onSelect)
     2992        if not checkLbl:
     2993            OKbtn.Bind(wx.EVT_BUTTON,self._onSelect)
     2994            self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._onSelect)
     2995            btn.Bind(wx.EVT_BUTTON,self._onClose)           
    29652996        self.SetSizer(mainSizer)
    2966         self.Selection = -1
    29672997        self.ShowModal()
    29682998    def _onClose(self,event):
  • trunk/GSASIIdataGUI.py

    r4046 r4060  
    53405340        # PDR / Unit Cells List
    53415341        G2G.Define_wxId('wxID_INDEXPEAKS', 'wxID_REFINECELL', 'wxID_COPYCELL', 'wxID_MAKENEWPHASE',
    5342             'wxID_EXPORTCELLS','wxID_LOADCELL','wxID_IMPORTCELL','wxID_TRANSFORMCELL','wxID_RUNSUB','wxID_RUNSUBMAG')
     5342            'wxID_EXPORTCELLS','wxID_LOADCELL','wxID_IMPORTCELL','wxID_TRANSFORMCELL','wxID_RUNSUB','wxID_RUNSUBMAG','wxID_LATSYM')
    53435343        self.IndexMenu = wx.MenuBar()
    53445344        self.PrefillDataMenu(self.IndexMenu)
     
    53475347        self.IndexPeaks = self.IndexEdit.Append(G2G.wxID_INDEXPEAKS,'Index Cell',
    53485348            'Find cells that index fitted peaks')
     5349        self.IndexEdit.Append(G2G.wxID_LATSYM,'Cell Symmetry Search',
     5350            'Run Bilboa "Lattice Symmetry" to find higher symmetry cells')
    53495351        self.RunSubGroups = self.IndexEdit.Append(G2G.wxID_RUNSUB,'Run SUBGROUPS',
    53505352            'If disabled, do Load Cell first')
     
    53535355        self.CopyCell = self.IndexEdit.Append(G2G.wxID_COPYCELL,'Copy Cell',
    53545356            'Copy selected unit cell from indexing to cell refinement fields')
    5355         self.LoadCell = self.IndexEdit.Append(G2G.wxID_LOADCELL,'Load Cell',
    5356             'Load unit cell from phase')
     5357        self.LoadCell = self.IndexEdit.Append(G2G.wxID_LOADCELL,'Load Cell from phase',
     5358            'Load unit cell from a phase tree entry')
    53575359        self.ImportCell = self.IndexEdit.Append(G2G.wxID_IMPORTCELL,'Import Cell',
    53585360            'Import unit cell from file')
  • trunk/GSASIIplot.py

    r4056 r4060  
    22692269                G2frame.cid = Page.canvas.mpl_connect('motion_notify_event', OnDragLine)
    22702270                pick.set_linestyle('--') # back to dashed
    2271         elif PickId and G2frame.GPXtree.GetItemText(PickId) == 'Limits':
     2271        elif PickId and G2frame.GPXtree.GetItemText(PickId) in ['Limits','Unit Cells List']:
    22722272            if ind.all() != [0]:                                    #picked a data point
    22732273                LimitId = G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Limits')
     
    24642464        Parms,Parms2 = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))
    24652465        xpos = event.xdata
    2466         if G2frame.GPXtree.GetItemText(PickId) in ['Peak List','Limits'] and xpos:
     2466        if G2frame.GPXtree.GetItemText(PickId) in ['Peak List','Limits','Unit Cells List'] and xpos:
    24672467            lines = []
    24682468            for line in G2frame.Lines:
     
    33293329                    clr = 'g'
    33303330                if Page.plotStyle['qPlot']:
    3331                     Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,hkl[-2]),color=clr,dashes=(5,5))
     3331                    Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,hkl[-2]),color=clr,dashes=(1,3),lw=2.5)
    33323332                if Page.plotStyle['dPlot']:
    3333                     Plot.axvline(G2lat.Pos2dsp(Parms,hkl[-2]),color=clr,dashes=(5,5))
     3333                    Plot.axvline(G2lat.Pos2dsp(Parms,hkl[-2]),color=clr,dashes=(1,3),lw=2.5)
    33343334                else:
    3335                     Plot.axvline(hkl[-2],color=clr,dashes=(5,5))
     3335                    Plot.axvline(hkl[-2],color=clr,dashes=(1,3),lw=2.5)
    33363336        elif Page.plotStyle.get('WgtDiagnostic',False):
    33373337            pass # skip reflection markers
  • trunk/GSASIIpwdGUI.py

    r4044 r4060  
    30283028################################################################################
    30293029#####  Unit cells
    3030 ################################################################################           
    3031        
     3030################################################################################
     3031
    30323032def UpdateUnitCellsGrid(G2frame, data):
    30333033    '''respond to selection of PWDR Unit Cells data tree item.
    30343034    '''
     3035    G2frame.ifGetExclude = False
    30353036    UnitCellsId = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List')
    30363037    SPGlist = G2spc.spglist
     
    32283229        ObjId = cellList.index(Obj.GetId())
    32293230        valObj = valDict[Obj.GetId()]
    3230         if ObjId//2 < 3:
    3231             move = Obj.GetValue()*0.01
    3232         else:
    3233             move = Obj.GetValue()*0.1
     3231        inc = float(shiftChoices[shiftSel.GetSelection()][:-1])
     3232        move = Obj.GetValue()  # +1 or -1
     3233#        if ObjId//2 >= 3: # angle movements could be bigger
     3234#            move *= 2
    32343235        Obj.SetValue(0)
    3235         value = float(valObj.GetValue())+move 
     3236        value = float(valObj.GetValue()) * (1. + move*inc/100.)
    32363237        SetCellValue(valObj,ObjId//2,value)
    32373238        OnHklShow(event)
     
    32663267        peaks = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Index Peak List'))
    32673268        controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Unit Cells List'))
     3269        # recompute dmin in case limits were changed
     3270        Inst = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))[0]
     3271        Limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Limits'))[1]
     3272        if 'C' in Inst['Type'][0] or 'PKS' in Inst['Type'][0]:
     3273            wave = G2mth.getWave(Inst)
     3274            dmin = G2lat.Pos2dsp(Inst,Limits[1])
     3275        else:
     3276            dmin = G2lat.Pos2dsp(Inst,Limits[0])
    32683277        cell = controls[6:12]
    32693278        A = G2lat.cell2A(cell)
     
    35863595               
    35873596    def RefreshUnitCellsGrid(event):
     3597        'responds when "use" is pressed in index table; generates/plots reflections'
    35883598        data = G2frame.GPXtree.GetItemPyData(UnitCellsId)
    35893599        cells,dminx = data[2:4]
    35903600        r,c =  event.GetRow(),event.GetCol()
    35913601        if cells:
    3592             if c == 2:
     3602            if event.GetEventObject().GetColLabelValue(c) == 'use':
    35933603                for i in range(len(cells)):
    35943604                    cells[i][-2] = False
     
    36073617                else:
    36083618                    G2plt.PlotPatterns(G2frame)
    3609             elif c == 11:
     3619            elif event.GetEventObject().GetColLabelValue(c) == 'Keep':
    36103620                if UnitCellsTable.GetValue(r,c):
    36113621                    UnitCellsTable.SetValue(r,c,False)
     
    38923902        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
    38933903       
     3904    def OnLatSym(event):
     3905        'Run Bilbao PsuedoLattice cell search'
     3906        # look up a space group matching Bravais lattice (should not matter which one)
     3907        bravaisSPG = {'Fm3m':225,'Im3m':229,'Pm3m':221,'R3-H':146,'P6/mmm':191,
     3908                       'I4/mmm':139,'P4/mmm':123,'Fmmm':69,'Immm':71,
     3909                       'Cmmm':65,'Pmmm':47,'C2/m':12,'P2/m':10,'P1':2}
     3910        pUCid = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List')
     3911        controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(pUCid)
     3912        sgNum = bravaisSPG.get(controls[5],0)
     3913        if sgNum < 1:
     3914            wx.MessageBox('Sorry, only standard cell settings are allowed, please transform axes',caption='Bilbao requires standard settings',style=wx.ICON_EXCLAMATION)
     3915            return
     3916        cell = controls[6:12]
     3917        tolerance = 5.
     3918        dlg = G2G.SingleFloatDialog(G2frame,'Tolerance',
     3919                'Enter angular tolerance for search',5.0,[.1,30.],"%.1f")
     3920        if dlg.ShowModal() == wx.ID_OK:
     3921            tolerance = dlg.GetValue()
     3922            dlg.Destroy()   
     3923        else:
     3924            dlg.Destroy()   
     3925            return
     3926        import SUBGROUPS as kSUB
     3927        wx.BeginBusyCursor()
     3928        wx.MessageBox(''' For use of PSEUDOLATTICE, please cite:
     3929      Bilbao Crystallographic Server I: Databases and crystallographic computing programs,
     3930      M. I. Aroyo, J. M. Perez-Mato, C. Capillas, E. Kroumova, S. Ivantchev, G. Madariaga, A. Kirov & H. Wondratschek
     3931      Z. Krist. 221, 1, 15-27 (2006).
     3932      doi:10.1524/zkri.2006.221.1.15''',
     3933        caption='Bilbao SUBGROUPS',style=wx.ICON_INFORMATION)
     3934        page = kSUB.subBilbaoCheckLattice(sgNum,cell,tolerance)
     3935        wx.EndBusyCursor()
     3936        if not page: return
     3937        while cells: cells.pop() # cells.clear() is much cleaner but not Py2
     3938        for i,(cell,mat) in enumerate(kSUB.parseBilbaoCheckLattice(page)):
     3939            cells.append([])
     3940            cells[-1] += [mat,0,16]
     3941            cells[-1] += cell
     3942            cells[-1] += [G2lat.calc_V(G2lat.cell2A(cell)),False,False]           
     3943        G2frame.GPXtree.SetItemPyData(pUCid,data)
     3944        G2frame.OnFileSave(event)
     3945        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
     3946       
    38943947    def OnRunSubs(event):
    38953948        import SUBGROUPS as kSUB
     
    41024155       
    41034156    G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.IndexMenu)
     4157    G2frame.GetStatusBar().SetStatusText('')
    41044158    G2frame.Bind(wx.EVT_MENU, OnIndexPeaks, id=G2G.wxID_INDEXPEAKS)
    41054159    G2frame.Bind(wx.EVT_MENU, OnRunSubs, id=G2G.wxID_RUNSUB)
    41064160    G2frame.Bind(wx.EVT_MENU, OnRunSubsMag, id=G2G.wxID_RUNSUBMAG)
     4161    G2frame.Bind(wx.EVT_MENU, OnLatSym, id=G2G.wxID_LATSYM)
    41074162    G2frame.Bind(wx.EVT_MENU, CopyUnitCell, id=G2G.wxID_COPYCELL)
    41084163    G2frame.Bind(wx.EVT_MENU, LoadUnitCell, id=G2G.wxID_LOADCELL)
     
    41384193    [[13,14,15],10,zip([" Unit cell: a = "," b = "," c = "," beta = "," Vol = "],
    41394194        [(10,5),(10,5),(10,5),(10,3),"%.3f"],[True,True,True,True,False],[0,1,2,4,0])],
    4140     [[16,17],8,zip([" Unit cell: a = "," b = "," c = "," Vol = "," alpha = "," beta = "," gamma = "],
    4141         [(10,5),(10,5),(10,5),"%.3f",(10,3),(10,3),(10,3)],
    4142         [True,True,True,False,True,True,True],[0,1,2,0,3,4,5])]]
     4195    [[16,17],8,zip([" Unit cell: a = "," b = "," c = "," alpha = "," beta = "," gamma = "," Vol = "],
     4196        [(10,5),(10,5),(10,5),(10,3),(10,3),(10,3),"%.3f"],
     4197        [True,True,True,True,True,True,False],[0,1,2,3,4,5,0])]]
    41434198   
    41444199    G2frame.dataWindow.IndexPeaks.Enable(False)
     
    41834238        0,WACV)
    41844239    mainSizer.Add((5,5),0)
    4185     littleSizer = wx.FlexGridSizer(0,7,5,5)
     4240    littleSizer = wx.FlexGridSizer(0,5,5,5)
    41864241    bravList = []
    41874242    bravs = zip(bravais,bravaisNames)
     
    41934248        littleSizer.Add(bravCk,0,WACV)
    41944249    mainSizer.Add(littleSizer,0)
    4195     mainSizer.Add((5,5),0)
     4250    mainSizer.Add((-1,10),0)
    41964251   
    4197     mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=' Cell Test & Refinement: '),0,WACV)
     4252    littleSizer = wx.BoxSizer(wx.HORIZONTAL)
     4253    littleSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=' Cell Test && Refinement: '),0,WACV)
     4254    littleSizer.Add((5,5),0)
     4255    if 'X' in Inst['Type'][0]:
     4256        hklShow = wx.Button(G2frame.dataWindow,label="Show hkl positions")
     4257        hklShow.Bind(wx.EVT_BUTTON,OnHklShow)
     4258        littleSizer.Add(hklShow,0,WACV)   
     4259    mainSizer.Add(littleSizer,0)
     4260   
    41984261    mainSizer.Add((5,5),0)
    41994262    littleSizer = wx.BoxSizer(wx.HORIZONTAL)
    4200     littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Bravais lattice "),0,WACV)
    4201     bravSel = wx.Choice(G2frame.dataWindow,choices=bravaisSymb)
     4263    littleSizer.Add(wx.StaticText(G2frame.dataWindow,label="Bravais\nlattice",style=wx.ALIGN_CENTER),0,WACV,5)
     4264    bravSel = wx.Choice(G2frame.dataWindow,choices=bravaisSymb,size=(75,-1))
    42024265    bravSel.SetSelection(bravaisSymb.index(controls[5]))
    42034266    bravSel.Bind(wx.EVT_CHOICE,OnBravSel)
    42044267    littleSizer.Add(bravSel,0,WACV)
    4205     littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Space group "),0,WACV)
    4206     spcSel = wx.Choice(G2frame.dataWindow,choices=SPGlist[controls[5]])
     4268    littleSizer.Add(wx.StaticText(G2frame.dataWindow,label="Space\ngroup",style=wx.ALIGN_CENTER),0,WACV,5)
     4269    spcSel = wx.Choice(G2frame.dataWindow,choices=SPGlist[controls[5]],size=(75,-1))
    42074270    spcSel.SetSelection(SPGlist[controls[5]].index(controls[13]))
    42084271    spcSel.Bind(wx.EVT_CHOICE,OnSpcSel)
     
    42124275    else:
    42134276        littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Zero offset"),0,WACV)
    4214         zero = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,1,nDig=(10,4),typeHint=float,min=-5.,max=5.)
     4277        zero = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,1,nDig=(10,4),typeHint=float,
     4278                                    min=-5.,max=5.,size=(50,-1))
    42154279        littleSizer.Add(zero,0,WACV)
    42164280        zeroVar = wx.CheckBox(G2frame.dataWindow,label="Refine?")
     
    42224286    SSopt.Bind(wx.EVT_CHECKBOX,OnSSopt)
    42234287    littleSizer.Add(SSopt,0,WACV)
    4224     if 'X' in Inst['Type'][0]:
    4225         hklShow = wx.Button(G2frame.dataWindow,label="Show hkl positions")
    4226         hklShow.Bind(wx.EVT_BUTTON,OnHklShow)
    4227         littleSizer.Add(hklShow,0,WACV)
    4228     elif 'N' in Inst['Type'][0]:
     4288    if 'N' in Inst['Type'][0]:
    42294289        MagSel = wx.CheckBox(G2frame.dataWindow,label="Magnetic?")
    42304290        MagSel.SetValue('MagSpGrp' in SGData)
     
    42784338    valDict = {}
    42794339    Info = {}
    4280     littleSizer = wx.FlexGridSizer(0,useGUI[1],5,5)
     4340    littleSizer = wx.FlexGridSizer(0,min(6,useGUI[1]),5,5)
    42814341    for txt,fmt,ifEdit,Id in useGUI[2]:
    4282         littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=txt),0,WACV)
     4342        littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=txt,style=wx.ALIGN_RIGHT),0,WACV|wx.ALIGN_RIGHT)
    42834343        if ifEdit:          #a,b,c,etc.
    42844344            cellVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,6+Id,nDig=fmt,OnLeave=OnCellChange)
     
    42994359            volVal.SetBackgroundColour(VERY_LIGHT_GREY)
    43004360            littleSizer.Add(volVal,0,WACV)
     4361    littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='cell inc',style=wx.ALIGN_RIGHT),0,WACV|wx.ALIGN_RIGHT)
     4362    shiftChoices = [ '0.01%','0.05%','0.1%','0.5%', '1.0%','2.5%','5.0%']
     4363    shiftSel = wx.Choice(G2frame.dataWindow,choices=shiftChoices,size=(75,-1))
     4364    shiftSel.SetSelection(3)
     4365    littleSizer.Add(shiftSel)
     4366       
    43014367    mainSizer.Add(littleSizer,0)
    43024368    if ssopt.get('Use',False):        #super lattice display
     
    43514417    G2frame.dataWindow.currentGrids = []
    43524418    if cells:
    4353         mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label='\n Indexing Result:'),0,WACV)
     4419        mode = 0
     4420        try: # for Cell sym, 1st entry is cell xform matrix
     4421            len(cells[0][0])
     4422            mode = 1
     4423        except:
     4424            pass
     4425        if mode:
     4426            mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label='\n Cell symmetry search:'),0,WACV)
     4427            colLabels = ['use']
     4428            Types = [wg.GRID_VALUE_BOOL]
     4429        else:
     4430            mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label='\n Indexing Result:'),0,WACV)
     4431            colLabels = ['M20','X20','use','Bravais']
     4432            Types = [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_NUMBER,
     4433                         wg.GRID_VALUE_BOOL,wg.GRID_VALUE_STRING]
    43544434        rowLabels = []
    4355         colLabels = ['M20','X20','use','Bravais','a','b','c','alpha','beta','gamma','Volume','Keep']
    4356         Types = [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_NUMBER,wg.GRID_VALUE_BOOL,wg.GRID_VALUE_STRING,]+ \
    4357             3*[wg.GRID_VALUE_FLOAT+':10,5',]+3*[wg.GRID_VALUE_FLOAT+':10,3',]+ \
    4358             [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_BOOL]
     4435        colLabels += ['a','b','c','alpha','beta','gamma','Volume','Keep']
     4436        Types += (3*[wg.GRID_VALUE_FLOAT+':10,5',]+
     4437                  3*[wg.GRID_VALUE_FLOAT+':10,3',]+
     4438                  [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_BOOL])
    43594439        table = []
    43604440        for cell in cells:
    43614441            rowLabels.append('')
    4362             row = cell[0:2]+[cell[-2]]+[bravaisSymb[cell[2]]]+cell[3:10]+[cell[11],]
     4442            if mode:
     4443                row = [cell[-2]]+cell[3:10]+[cell[11],]
     4444            else:
     4445                row = cell[0:2]+[cell[-2]]+[bravaisSymb[cell[2]]]+cell[3:10]+[cell[11],]
    43634446            if cell[-2]:
    43644447                A = G2lat.cell2A(cell[3:9])
  • trunk/SUBGROUPS.py

    r3729 r4060  
    1717from __future__ import division, print_function
    1818import requests
     19import numpy as np
     20import numpy.linalg as nl
    1921import GSASIIspc as G2spc
    2022import GSASIIpath
     
    274276    return result,baseList
    275277
     278def subBilbaoCheckLattice(spgNum,cell,tol=5):
     279    '''submit a unit cell to  Bilbao PseudoLattice
     280    '''
     281    psSite = "http://www.cryst.ehu.es/cgi-bin/cryst/programs/pseudosym/nph-pseudolattice"
     282    cellstr = '+'.join(['{:.5f}'.format(i) for i in cell])
     283    datastr = "sgr={:}&cell={:}&tol={:}&submit=Show".format(
     284        str(int(spgNum)),cellstr,str(int(tol)))
     285    try:
     286        r = requests.post(psSite,data=datastr)
     287    except:     #ConnectionError?
     288        page = ''
     289        print('connection error - not on internet')
     290        return None
     291    if r.status_code == 200:
     292        print('request OK')
     293        page = r.text
     294        page = page.replace('<font style= "text-decoration: overline;">','<font>-')
     295    else:
     296        page = ''
     297        print('request failed. Reason=',r.reason)
     298        return None
     299    r.close()
     300    return page
     301
     302def parseBilbaoCheckLattice(page):
     303    '''find the cell options from the web page returned by Bilbao PseudoLattice
     304    '''
     305    cellopts = [i for i in page.split('<tr>') if '<td><pre>' in i]
     306    found = []
     307    for c in cellopts:
     308        cells = c.split("pre")[1].split('<')[0].replace('>','').split('\n') # list of cells, 1st is approx
     309        try:
     310            acell = [float(i) for i in cells[0].split()]
     311            xmatA = [c.split('[')[i].split(']')[0].split() for i in (1,2,3)]
     312            xmat =  np.array([[eval(i) for i in j] for j in xmatA])
     313            cellmat = nl.inv(xmat).T
     314        except:
     315            print('Error processing cell in',c)
     316            continue
     317        found.append((acell,cellmat))
     318    return found
     319
     320
    276321def test():
    277322    SGData = G2spc.SpcGroup('f d -3 m')[1]
Note: See TracChangeset for help on using the changeset viewer.