Changeset 1147


Ignore:
Timestamp:
Nov 22, 2013 4:24:29 PM (8 years ago)
Author:
toby
Message:

Complete initial ISODISPLACE implementation; mod. phase initialization; change atom pointer init.; rework parameter display window

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1145 r1147  
    182182        item = parent.Append(help='View least squares parameters',
    183183            id=wx.ID_ANY, kind=wx.ITEM_NORMAL,text='&View LS parms')
    184         self.Bind(wx.EVT_MENU, self.OnViewLSParms, id=item.GetId())
     184        self.Bind(wx.EVT_MENU, self.ShowLSParms, id=item.GetId())
    185185       
    186186        item = parent.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL,
     
    195195       
    196196        item = parent.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL,
    197             text='Sequental refine')
     197            text='Sequential refine')
    198198        if len(self.SeqRefine): # extend state for new menus to match main (on mac)
    199199            state = self.SeqRefine[0].IsEnabled()
     
    262262            if fp: fp.close()
    263263
    264     def OnImportGeneric(self,reader,readerlist,label,multiple=False):
     264    def OnImportGeneric(self,reader,readerlist,label,multiple=False,usedRanIdList=[]):
    265265        '''Used to import Phases, powder dataset or single
    266266        crystal datasets (structure factor tables) using reader objects
    267         subclassed from GSASIIIO.ImportPhase, GSASIIIO.ImportStructFactor
    268         or GSASIIIO.ImportPowderData. If a reader is specified, only
     267        subclassed from :class:`GSASIIIO.ImportPhase`, :class:`GSASIIIO.ImportStructFactor`
     268        or :class:`GSASIIIO.ImportPowderData`. If a reader is specified, only
    269269        that will be attempted, but if no reader is specified, every one
    270270        that is potentially compatible (by file extension) will
     
    287287        :param bool multiple: True if multiple files can be selected
    288288          in the file dialog. False is default. At present True is used
    289           only for reading of powder data.
    290          
     289          only for reading of powder data.
     290
     291        :param list usedRanIdList: an optional list of random Ids that
     292          have been used and should not be reused
     293
    291294        :returns: a list of reader objects (rd_list) that were able
    292295          to read the specified file(s). This list may be empty.
     
    425428                            flag = rd.Reader(filename,fp,self,
    426429                                             buffer=rdbuffer,
    427                                              blocknum=block)
     430                                             blocknum=block,
     431                                             usedRanIdList=usedRanIdList,
     432                                             )
    428433                            if flag:
    429434                                rd_list.append(copy.deepcopy(rd)) # success
     
    483488        # look up which format was requested
    484489        reqrdr = self.ImportMenuId.get(event.GetId())
     490        # make a list of used phase ranId's
     491        phaseRIdList = []
     492        sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases')
     493        if sub:
     494            item, cookie = self.PatternTree.GetFirstChild(sub)
     495            while item:
     496                phaseName = self.PatternTree.GetItemText(item)
     497                ranId = self.PatternTree.GetItemPyData(item).get('ranId')
     498                if ranId: phaseRIdList.append(ranId)
     499                item, cookie = self.PatternTree.GetNextChild(sub, cookie)
    485500        rdlist = self.OnImportGeneric(reqrdr,
    486501                                  self.ImportPhaseReaderlist,
    487                                   'phase')
     502                                  'phase',usedRanIdList=phaseRIdList)
    488503        if len(rdlist) == 0: return
    489504        # for now rdlist is only expected to have one element
     
    509524            self.PatternTree.Expand(self.root) # make sure phases are seen
    510525            self.PatternTree.Expand(sub)
    511             self.PatternTree.Expand(psub)
     526            self.PatternTree.Expand(psub)
     527            if rd.Constraints:
     528                sub = G2gd.GetPatternTreeItemId(self,self.root,'Constraints') # was created in CheckNotebook if needed
     529                Constraints = self.PatternTree.GetItemPyData(sub)               
     530                # TODO: make sure that NEWVAR names are unique here?
     531                for i in rd.Constraints:
     532                    if type(i) is dict:
     533                        #for j in i: print j,' --> ',i[j]
     534                        if '_Explain' not in Constraints: Constraints['_Explain'] = {}
     535                        Constraints['_Explain'].update(i)
     536                        continue
     537                    Constraints['Phase'].append(i)
    512538        return # success
    513539       
     
    13151341        self._Add_ImportMenu_powder(Import)
    13161342        self._Add_ImportMenu_Sfact(Import)
     1343        #======================================================================
     1344        # Code to help develop/debug an importer, much is hard-coded below
     1345        # but module is reloaded before each use, allowing faster testing
     1346        # def DebugImport(event):
     1347        #     print 'start reload'
     1348        #     import G2phase_ISO as dev
     1349        #     reload(dev)
     1350        #     rd = dev.ISODISTORTPhaseReader()
     1351        #     self.ImportMenuId[event.GetId()] = rd
     1352        #     self.OnImportPhase(event)
     1353            # or ----------------------------------------------------------------------
     1354            #self.OnImportGeneric(rd,[],'test of ISODISTORTPhaseReader')
     1355            # special debug code
     1356            # or ----------------------------------------------------------------------
     1357            # filename = '/Users/toby/projects/branton/subgroup_cif.txt'
     1358            # fp = open(filename,'Ur')
     1359            # if not rd.ContentsValidator(fp):
     1360            #     print 'not validated'
     1361            #     # make a list of used phase ranId's
     1362            # phaseRIdList = []
     1363            # sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases')
     1364            # if sub:
     1365            #     item, cookie = self.PatternTree.GetFirstChild(sub)
     1366            #     while item:
     1367            #         phaseName = self.PatternTree.GetItemText(item)
     1368            #         ranId = self.PatternTree.GetItemPyData(item).get('ranId')
     1369            #         if ranId: phaseRIdList.append(ranId)
     1370            #         item, cookie = self.PatternTree.GetNextChild(sub, cookie)
     1371            # if rd.Reader(filename,fp,usedRanIdList=phaseRIdList):
     1372            #     print 'read OK'
     1373        # item = Import.Append(
     1374        #     wx.ID_ANY,kind=wx.ITEM_NORMAL,
     1375        #     help="debug importer",text="test importer")
     1376        # self.Bind(wx.EVT_MENU, DebugImport, id=item.GetId())
     1377        #======================================================================
    13171378        self.ExportMenu = wx.Menu(title='')
    13181379        menubar.Append(menu=self.ExportMenu, title='Export')
     
    25162577        for phase in phaseData:
    25172578            Phase = phaseData[phase]
     2579            pId = phaseNames.index(phase)
     2580            Phase['pId'] = pId
    25182581            if Phase['Histograms']:
    25192582                if phase not in Phases:
    2520                     pId = phaseNames.index(phase)
    2521                     Phase['pId'] = pId
    25222583                    Phases[phase] = Phase
    25232584                for hist in Phase['Histograms']:
     
    25362597                            print('For phase "'+str(phase)+
    25372598                                  '" unresolved reference to histogram "'+str(hist)+'"')
    2538         G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
     2599        #G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
     2600        G2obj.IndexAllIds(Histograms=Histograms,Phases=phaseData)
    25392601        return Histograms,Phases
    25402602       
    2541     class ViewParmDialog(wx.Dialog):
    2542         '''Window to show all parameters in the refinement.
    2543         Called from :meth:`OnViewLSParms`
    2544         '''
    2545         def __init__(self,parent,title,parmDict):
    2546             wx.Dialog.__init__(self,parent,-1,title,size=(300,430),
    2547                 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
    2548             panel = wx.Panel(self,size=(300,430))
    2549             parmNames = parmDict.keys()
    2550             parmNames.sort()
    2551             parmText = ' p:h:Parameter       refine?              value\n'
    2552             for name in parmNames:
    2553                 parmData = parmDict[name]
    2554                 try:
    2555                     parmText += ' %s \t%12.4g \n'%(name.ljust(19)+'\t'+parmData[1],parmData[0])
    2556                 except TypeError:
    2557                     pass
    2558             parmTable = wx.TextCtrl(panel,-1,parmText,
    2559                 style=wx.TE_MULTILINE|wx.TE_READONLY,size=(290,400))
    2560             mainSizer = wx.BoxSizer(wx.VERTICAL)
    2561             mainSizer.Add(parmTable)
    2562             panel.SetSizer(mainSizer)
    2563                            
    2564     def OnViewLSParms(self,event):
    2565         '''Displays a window showing all parameters in the refinement.
    2566         Called from the Calculate/View LS Parms menu.
     2603    def MakeLSParmDict(self):
     2604        '''Load all parameters used for computation from the tree into a
     2605        dict
     2606
     2607        :returns: (parmDict,varyList) where:
     2608
     2609         * parmDict is a dict with values and refinement flags
     2610           for each parameter and
     2611         * varyList is a list of variables (refined parameters).
    25672612        '''
    25682613        parmDict = {}
     
    25712616            if 'pId' not in Phases[phase]:
    25722617                self.ErrorDialog('View parameter error','You must run least squares at least once')
    2573                 return
     2618                raise Exception,'No pId for phase '+str(phase)
    25742619        rigidbodyDict = self.PatternTree.GetItemPyData(   
    25752620            G2gd.GetPatternTreeItemId(self,self.root,'Rigid bodies'))
     
    25872632            if parm.split(':')[-1] in ['Azimuth','Gonio. radius','Lam1','Lam2',
    25882633                'Omega','Chi','Phi','nDebye','nPeaks']:
    2589                 parmDict[parm] = [parmDict[parm],' ']
     2634                parmDict[parm] = [parmDict[parm],'-']
    25902635            elif parm.split(':')[-2] in ['Ax','Ay','Az','SHmodel','SHord']:
    2591                 parmDict[parm] = [parmDict[parm],' ']
     2636                parmDict[parm] = [parmDict[parm],'-']
    25922637            elif parm in varyList:
    2593                 parmDict[parm] = [parmDict[parm],'True']
     2638                parmDict[parm] = [parmDict[parm],'T']
    25942639            else:
    2595                 parmDict[parm] = [parmDict[parm],'False']
    2596         parmDict[' Num refined'] = [len(varyList),'']
    2597         dlg = self.ViewParmDialog(self,'Parameters for least squares',parmDict)
    2598         try:
    2599             if dlg.ShowModal() == wx.ID_OK:
    2600                 print 'do something with changes?? - No!'
    2601         finally:
    2602             dlg.Destroy()
    2603        
     2640                parmDict[parm] = [parmDict[parm],'F']
     2641        return parmDict,varyList
     2642
     2643    def ShowLSParms(self,event):
     2644        '''Displays a window showing all parameters in the refinement.
     2645        Called from the Calculate/View LS Parms menu.
     2646        '''
     2647        parmDict,varyList = self.MakeLSParmDict()
     2648        dlg = G2gd.ShowLSParms(self,'Least Squares Parameters',parmDict,varyList)
     2649        dlg.ShowModal()
     2650        dlg.Destroy()
     2651       
    26042652    def OnRefine(self,event):
    26052653        '''Perform a refinement.
     
    26742722        Called from the Calculate/Sequential refine menu.
    26752723        '''       
    2676         Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequental results')
     2724        Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results')
    26772725        if not Id:
    2678             Id = self.PatternTree.AppendItem(self.root,text='Sequental results')
     2726            Id = self.PatternTree.AppendItem(self.root,text='Sequential results')
    26792727            self.PatternTree.SetItemPyData(Id,{})           
    26802728        self.OnFileSave(event)
  • trunk/GSASIIIO.py

    r1138 r1147  
    985985   
    986986def SetNewPhase(Name='New Phase',SGData=None,cell=None):
    987     '''Create a new phase with default values for various parameters
     987    '''Create a new phase dict with default values for various parameters
    988988
    989989    :param str Name: Name for new Phase
     
    10031003            'Name':Name,
    10041004            'Type':'nuclear',
     1005            'AtomPtrs':[3,1,7,9],
    10051006            'SGData':SGData,
    10061007            'Cell':[False,]+cell,
     
    11491150    general = Phase['General']
    11501151    general['Type'] = Ptype
     1152    if general['Type'] =='macromolecular':
     1153        general['AtomPtrs'] = [6,4,10,12]
     1154    else:
     1155        general['AtomPtrs'] = [3,1,7,9]   
    11511156    general['SH Texture'] = textureData
    11521157    Phase['Atoms'] = Atoms
     
    12381243    Phase = SetNewPhase(Name=PhaseName,SGData=SGData,cell=cell+[Volume,])
    12391244    Phase['General']['Type'] = 'macromolecular'
     1245    Phase['General']['AtomPtrs'] = [6,4,10,12]
    12401246    Phase['Atoms'] = Atoms
    1241    
    12421247    return Phase
    12431248
     
    14311436######################################################################
    14321437E,SGData = G2spc.SpcGroup('P 1') # data structure for default space group
     1438P1SGData = SGData
    14331439class ImportBaseclass(object):
    14341440    '''Defines a base class for the reading of input files (diffraction
     
    15681574class ImportPhase(ImportBaseclass):
    15691575    '''Defines a base class for the reading of files with coordinates
     1576
     1577    Objects constructed that subclass this (in import/G2phase_*.py) will be used
     1578    in :meth:`GSASII.GSASII.OnImportPhase`
    15701579    '''
    15711580    def __init__(self,formatName,longFormatName=None,extensionlist=[],
     
    15741583        ImportBaseclass.__init__(self,formatName,longFormatName,
    15751584            extensionlist,strictExtension)
    1576         # define a default Phase structure
    1577         self.Phase = SetNewPhase(Name='new phase',SGData=SGData)
     1585        self.Phase = None # a phase must be created with G2IO.SetNewPhase in the Reader
     1586        self.Constraints = None
    15781587
    15791588    def PhaseSelector(self, ChoiceList, ParentFrame=None,
  • trunk/GSASIIconstrGUI.py

    r1141 r1147  
    208208    # patch: convert old-style (str) variables in constraints to G2VarObj objects
    209209    for key,value in data.items():
     210        if key.startswith('_'): continue
    210211        j = 0
    211212        for cons in value:
     
    707708                        varMean = G2obj.fmtVarDescr(var)
    708709                        helptext += "\n" + var + " ("+ varMean + ")"
     710                    if '_Explain' in data:
     711                        if data['_Explain'].get(item[-3]):
     712                            helptext += '\n\n'
     713                            helptext += data['_Explain'][item[-3]]
    709714                    typeString = 'NEWVAR'
    710                     eqString[-1] += ' = New Variable   '
     715                    if item[-3]:
     716                        eqString[-1] += ' = '+item[-3]
     717                    else:
     718                        eqString[-1] += ' = New Variable'
    711719                elif item[-1] == 'c':
    712720                    helptext = "The following variables constrained to equal a constant:"
  • trunk/GSASIIgrid.py

    r1145 r1147  
    7171    wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT,
    7272    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,
    73     wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL
    74 ] = [wx.NewId() for item in range(13)]
     73    wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP,
     74] = [wx.NewId() for item in range(14)]
    7575
    7676[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
     
    15631563            evt.Skip()
    15641564
     1565################################################################################
     1566class ShowLSParms(wx.Dialog):
     1567    '''Create frame to show least-squares parameters
     1568    '''
     1569    def __init__(self,parent,title,parmDict,varyList=None,
     1570                 size=(300,430)):
     1571        wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=size,
     1572                           style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     1573        mainSizer = wx.BoxSizer(wx.VERTICAL)
     1574
     1575        panel = wxscroll.ScrolledPanel(
     1576            self, wx.ID_ANY,
     1577            #size=size,
     1578            style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
     1579        if varyList:
     1580            num = len(varyList)
     1581            mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number of refined variables: '+str(num)))
     1582
     1583        subSizer = wx.FlexGridSizer(rows=len(parmDict)+1,cols=4,hgap=2,vgap=2)
     1584        parmNames = parmDict.keys()
     1585        parmNames.sort()
     1586        #parmText = ' p:h:Parameter       refine?              value\n'
     1587        subSizer.Add((-1,-1))
     1588        subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'Parameter name  '))
     1589        subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'refine?'))
     1590        subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'value'),0,wx.ALIGN_RIGHT)
     1591        for name in parmNames:
     1592            v = G2obj.getVarDescr(name)
     1593            if v is None or v[-1] is None:
     1594                subSizer.Add((-1,-1))
     1595            else:               
     1596                ch = HelpButton(panel,G2obj.fmtVarDescr(name))
     1597                subSizer.Add(ch,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER,1)
     1598            subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(name)))
     1599            subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(parmDict[name][1])))
     1600            try:
     1601                value = G2py3.FormatValue(parmDict[name][0])
     1602            except TypeError:
     1603                value = str(parmDict[name][0])
     1604            subSizer.Add(wx.StaticText(panel,wx.ID_ANY,value),0,wx.ALIGN_RIGHT)
     1605
     1606        # finish up ScrolledPanel
     1607        panel.SetSizer(subSizer)
     1608        panel.SetAutoLayout(1)
     1609        panel.SetupScrolling()
     1610        mainSizer.Add(panel,1, wx.ALL|wx.EXPAND,1)
     1611
     1612        # make OK button
     1613        btnsizer = wx.BoxSizer(wx.HORIZONTAL)
     1614        btn = wx.Button(self, wx.ID_CLOSE,"Close")
     1615        btn.Bind(wx.EVT_BUTTON,self._onClose)
     1616        btnsizer.Add(btn)
     1617        mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
     1618        # Allow window to be enlarged but not made smaller
     1619        self.SetSizer(mainSizer)
     1620        #mainSizer.Fit(self)
     1621        self.SetMinSize(self.GetSize())
     1622
     1623    def _onClose(self,event):
     1624        self.EndModal(wx.ID_CANCEL)
     1625 
    15651626################################################################################
    15661627class downdate(wx.Dialog):
     
    24332494        self.AtomCompute.Append(id=wxID_ATOMSPDISAGL, kind=wx.ITEM_NORMAL,text='Save Distances && Angles',
    24342495            help='Compute distances & angles for selected atoms')
     2496        self.AtomCompute.ISOcalc = self.AtomCompute.Append(
     2497            id=wxID_ISODISP, kind=wx.ITEM_NORMAL,
     2498            text='Compute ISODISPLACE mode values',
     2499            help='Compute values of ISODISPLACE modes from atom parameters')
    24352500        self.PostfillDataMenu()
    24362501                 
  • trunk/GSASIIobj.py

    r1145 r1147  
    1313=========================
    1414
    15 This module defines and/or documents the data structures used in GSAS-II.
    16 
     15This module defines and/or documents the data structures used in GSAS-II, as well
     16as provides misc. support routines.
    1717
    1818Constraints Tree Item
     
    7777 * <fixedval> is the fixed value for a `constant equation` (``constype=c``)
    7878   constraint or is None. For a `New variable` (``constype=f``) constraint,
    79    a variable name can be specified as a str (but this is not yet used).
     79   a variable name can be specified as a str (used for externally
     80   generated constraints)
    8081 * <varyflag> is True or False for `New variable` (``constype=f``) constraints
    8182   or is None. This will be implemented in the future to indicate if these variables
     
    700701'''
    701702
     703def MakeUniqueLabel(lbl,labellist):
     704    '''Make sure that every a label is unique against a list by adding
     705    digits at the end until it is not found in list.
     706
     707    :param str lbl: the input label
     708    :param list labellist: the labels that have already been encountered
     709    :returns: lbl if not found in labellist or lbl with ``_1-9` (or
     710      ``_10-99``, etc.) appended at the end
     711    '''
     712    lbl = lbl.strip()
     713    if not lbl: # deal with a blank label
     714        lbl = '_1'
     715    if lbl not in labellist:
     716        labellist.append(lbl)
     717        return lbl
     718    i = 1
     719    prefix = lbl
     720    if '_' in lbl:
     721        prefix = lbl[:lbl.rfind('_')]
     722        suffix = lbl[lbl.rfind('_')+1:]
     723        try:
     724            i = int(suffix)+1
     725        except: # suffix could not be parsed
     726            i = 1
     727            prefix = lbl
     728    while prefix+'_'+str(i) in labellist:
     729        i += 1
     730    else:
     731        lbl = prefix+'_'+str(i)
     732        labellist.append(lbl)
     733    return lbl
    702734
    703735PhaseIdLookup = {}
     
    10761108    A :class:`G2VarObj` object can be created with a single parameter:
    10771109   
    1078     :param str varname: a single value can be used to create a :class:`G2VarObj`
    1079       object. The string must be of form "p:h:var" or "p:h:var:a", where
     1110    :param str/tuple varname: a single value can be used to create a :class:`G2VarObj`
     1111      object. If a string, it must be of form "p:h:var" or "p:h:var:a", where
    10801112
    10811113     * p is the phase number (which may be left blank);
     
    10831115     * a is the atom number (which may be left blank in which case the third colon is omitted).
    10841116
    1085     Alternately, a :class:`G2VarObj` object can be created with exactly four positional parameters:
     1117      Alternately a single tuple of form (Phase,Histogram,VarName,AtomID) can be used, where
     1118      Phase, Histogram, and AtomID are None or are ranId values and VarName is a string.     
     1119
     1120    If four positional arguments are supplied, they are:
    10861121
    10871122    :param str/int phasenum: The number for the phase
     
    11001135        self.name = ''
    11011136        self.atom = None
    1102         if len(args) == 1:
     1137        if len(args) == 1 and (type(args[0]) is list or type(args[0]) is tuple) and len(args[0]) == 4:
     1138            self.phase,self.histogram,self.name,self.atom = args[0]
     1139        elif len(args) == 1 and ':' in args[0]:           
    11031140            lst = args[0].split(':')
    11041141            self.phase = PhaseIdLookup.get(lst[0],[None,None])[1]
     
    11521189                s += " (#" + AtomRanIdLookup[ph].get(self.atom,'?') + "); "
    11531190            else:
    1154                 s += " (#? -- no such phase!); "
     1191                s += " (#? -- not found!); "
    11551192        s += 'Variable name="' + str(self.name) + '">'
    11561193        return s+"("+self.varname()+")"
  • trunk/GSASIIphsGUI.py

    r1142 r1147  
    2626import wx.lib.gridmovers as wgmove
    2727import wx.wizard as wz
     28import wx.lib.scrolledpanel as wxscroll
    2829import matplotlib as mpl
    2930import math
     
    4647import GSASIImath as G2mth
    4748import GSASIIpwd as G2pwd
     49import GSASIIpy3 as G2py3
    4850import numpy as np
    4951import numpy.linalg as nl
     
    6365
    6466def SetPhaseWindow(mainFrame,phasePage,mainSizer):
    65         phasePage.SetSizer(mainSizer)
    66         Size = mainSizer.GetMinSize()
    67         Size[0] += 40
    68         Size[1] = max(Size[1],430) + 35
    69         phasePage.SetSize(Size)
    70         phasePage.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1)
    71         mainFrame.setSizePosLeft(Size)
     67    phasePage.SetSizer(mainSizer)
     68    Size = mainSizer.GetMinSize()
     69    Size[0] += 40
     70    Size[1] = max(Size[1],430) + 35
     71    phasePage.SetSize(Size)
     72    phasePage.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1)
     73    mainFrame.setSizePosLeft(Size)
    7274
    7375def UpdatePhaseData(G2frame,Item,data,oldPage):
    7476    '''Create the data display window contents when a phase is clicked on
    75     in the man (data tree) window.
     77    in the main (data tree) window.
    7678    Called only from :meth:`GSASIIgrid.MovePatternTreeToGrid`,
    7779    which in turn is called from :meth:`GSASII.GSASII.OnPatternTreeSelChanged`
     
    108110    G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
    109111    G2frame.dataDisplay.gridList = [] # list of all grids in notebook
     112    # UpdatePhaseData execution continues below
    110113   
    111114    def SetupGeneral():
     
    137140            'dmin':2.0,'Algorithm':'fast','Jump coeff':[0.95,0.5],'boltzmann':1.0,
    138141            'fast parms':[1.0,1.0,1.0],'log slope':0.9,'Cycles':1,'Results':[]}
     142        if 'AtomPtrs' not in generalData:
     143            generalData['AtomPtrs'] = [3,1,7,9]
     144            if generalData['Type'] =='macromolecular':
     145                generalData['AtomPtrs'] = [6,4,10,12]
    139146# end of patches
     147        cx,ct,cs,cia = generalData['AtomPtrs']
    140148        generalData['NoAtoms'] = {}
    141149        generalData['BondRadii'] = []
     
    145153        generalData['Color'] = []
    146154        generalData['Mydir'] = G2frame.dirname
    147         cx,ct,cs,cia = [3,1,7,9]
    148         if generalData['Type'] =='macromolecular':
    149             cx,ct,cs,cia = [6,4,10,12]
    150         generalData['AtomPtrs'] = [cx,ct,cs,cia]
    151155        for atom in atomData:
    152156            atom[ct] = atom[ct].lower().capitalize()              #force to standard form
     
    15741578
    15751579    def OnDistAnglePrt(event):
     1580        'save distances and angles to a file'   
    15761581        fp = file(os.path.abspath(os.path.splitext(G2frame.GSASprojectfile
    15771582                                                   )[0]+'.disagl'),'w')
     
    15801585   
    15811586    def OnDistAngle(event,fp=None):
     1587        'Compute distances and angles'   
    15821588        indx = Atoms.GetSelectedRows()
    15831589        Oxyz = []
     
    16221628                G2frame.ErrorDialog('Distance/Angle calculation','try again but do "Reset" to fill in missing atom types')
    16231629        else:
    1624                 print "select one or more rows of atoms"
    1625                 G2frame.ErrorDialog('Select atom',"select one or more rows of atoms then redo")
     1630            print "select one or more rows of atoms"
     1631            G2frame.ErrorDialog('Select atom',"select one or more rows of atoms then redo")
    16261632                       
     1633    def OnIsoDistortCalc(event):
     1634        '''Compute the ISODISTORT mode values from the current coordinates.
     1635        Called in response to the (Phase/Atoms tab) AtomCompute
     1636        "Compute ISODISPLACE mode values" menu item, which should be enabled
     1637        only when Phase['ISODISTORT'] is defined.
     1638        '''
     1639        if 'ISODISTORT' not in data:
     1640            raise Exception,"Should not happen: 'ISODISTORT' not in data"
     1641        def _onClose(event):
     1642            dlg.EndModal(wx.ID_CANCEL)
     1643
     1644        Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree() # init for constraint
     1645        ISO = data['ISODISTORT']
     1646        parmDict,varyList = G2frame.MakeLSParmDict()
     1647        deltaList = []
     1648        for gv,Ilbl in zip(ISO['G2VarList'],ISO['IsoVarList']):
     1649            dvar = gv.varname()
     1650            var = dvar.replace('::dA','::A')
     1651            albl = Ilbl[:Ilbl.rfind('_')]
     1652            v = Ilbl[Ilbl.rfind('_')+1:]
     1653            pval = ISO['ParentStructure'][albl][['dx','dy','dz'].index(v)]
     1654            cval = parmDict.get(var)[0]
     1655            deltaList.append(cval-pval)
     1656        modeVals = np.inner(ISO['Var2ModeMatrix'],deltaList)
     1657        dlg = wx.Dialog(G2frame,wx.ID_ANY,'ISODISPLACE mode values',#size=(630,400),
     1658                           style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     1659        mainSizer = wx.BoxSizer(wx.VERTICAL)
     1660        mainSizer.Add(wx.StaticText(dlg,wx.ID_ANY,
     1661                                    'ISODISTORT mode computation for cordinates in phase '+
     1662                                    str(data['General'].get('Name'))))
     1663        aSizer = wx.BoxSizer(wx.HORIZONTAL)
     1664        panel1 = wxscroll.ScrolledPanel(
     1665            dlg, wx.ID_ANY,#size=(100,200),
     1666            style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
     1667        subSizer1 = wx.FlexGridSizer(rows=1,cols=2,hgap=5,vgap=2)
     1668        panel2 = wxscroll.ScrolledPanel(
     1669            dlg, wx.ID_ANY,#size=(100,200),
     1670            style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
     1671        subSizer2 = wx.FlexGridSizer(rows=1,cols=2,hgap=5,vgap=2)
     1672        subSizer1.Add(wx.StaticText(panel1,wx.ID_ANY,'Parameter name'))
     1673        subSizer1.Add(wx.StaticText(panel1,wx.ID_ANY,'value '),0,wx.ALIGN_RIGHT)
     1674        subSizer2.Add(wx.StaticText(panel2,wx.ID_ANY,' Mode name  '))
     1675        subSizer2.Add(wx.StaticText(panel2,wx.ID_ANY,'value '),0,wx.ALIGN_RIGHT)
     1676       
     1677        for lbl,xyz,var,val in zip(ISO['IsoVarList'],deltaList,ISO['IsoModeList'],modeVals):
     1678            subSizer1.Add(wx.StaticText(panel1,wx.ID_ANY,str(lbl)))
     1679            try:
     1680                value = G2py3.FormatValue(xyz)
     1681            except TypeError:
     1682                value = str(xyz)           
     1683            subSizer1.Add(wx.StaticText(panel1,wx.ID_ANY,value),0,wx.ALIGN_RIGHT)
     1684            #subSizer.Add((10,-1))
     1685            subSizer2.Add(wx.StaticText(panel2,wx.ID_ANY,str(var)))
     1686            try:
     1687                value = G2py3.FormatValue(val)
     1688            except TypeError:
     1689                value = str(val)           
     1690            subSizer2.Add(wx.StaticText(panel2,wx.ID_ANY,value),0,wx.ALIGN_RIGHT)
     1691        # finish up ScrolledPanel
     1692        panel1.SetSizer(subSizer1)
     1693        panel2.SetSizer(subSizer2)
     1694        panel1.SetAutoLayout(1)
     1695        panel1.SetupScrolling()
     1696        panel2.SetAutoLayout(1)
     1697        panel2.SetupScrolling()
     1698        # Allow window to be enlarged but not made smaller
     1699        dlg.SetSizer(mainSizer)
     1700        w1,l1 = subSizer1.GetSize()
     1701        w2,l2 = subSizer2.GetSize()
     1702        panel1.SetMinSize((w1+10,200))
     1703        panel2.SetMinSize((w2+20,200))
     1704        aSizer.Add(panel1,1, wx.ALL|wx.EXPAND,1)
     1705        aSizer.Add(panel2,2, wx.ALL|wx.EXPAND,1)
     1706        mainSizer.Add(aSizer,1, wx.ALL|wx.EXPAND,1)
     1707
     1708        # make OK button
     1709        btnsizer = wx.BoxSizer(wx.HORIZONTAL)
     1710        btn = wx.Button(dlg, wx.ID_CLOSE)
     1711        btn.Bind(wx.EVT_BUTTON,_onClose)
     1712        btnsizer.Add(btn)
     1713        mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
     1714
     1715        mainSizer.Fit(dlg)
     1716        dlg.SetMinSize(dlg.GetSize())
     1717        dlg.ShowModal()
     1718        dlg.Destroy()
     1719       
     1720       
    16271721    def OnReImport(event):
    16281722        generalData = data['General']
     
    29683062        shModels = ['cylindrical','none','shear - 2/m','rolling - mmm']
    29693063        SamSym = dict(zip(shModels,['0','-1','2/m','mmm']))
    2970         if generalData['doPawley'] and G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequental results'):
     3064        if generalData['doPawley'] and G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential results'):
    29713065            G2frame.dataFrame.RefineTexture.Enable(True)
    29723066        shAngles = ['omega','chi','phi']
     
    50935187            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAngle, id=G2gd.wxID_ATOMSDISAGL)
    50945188            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAnglePrt, id=G2gd.wxID_ATOMSPDISAGL)
     5189            G2frame.dataFrame.Bind(wx.EVT_MENU, OnIsoDistortCalc, id=G2gd.wxID_ISODISP)
    50955190            for id in G2frame.dataFrame.ReImportMenuId:     #loop over submenu items
    50965191                G2frame.dataFrame.Bind(wx.EVT_MENU, OnReImport, id=id)               
     
    51745269        else:
    51755270            G2gd.SetDataMenuBar(G2frame)
     5271
     5272    # UpdatePhaseData execution continues here
    51765273    Pages = []   
    51775274    wx.Frame.Unbind(G2frame.dataFrame,wx.EVT_SIZE) # ignore size events during this routine
     
    52115308    G2frame.dataDisplay.AddPage(G2frame.PawleyRefl,'Pawley reflections')
    52125309    Pages.append('Pawley reflections')
    5213    
     5310    G2frame.dataFrame.AtomCompute.ISOcalc.Enable('ISODISTORT' in data)
    52145311    G2frame.dataDisplay.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, OnPageChanged)
    52155312    SetupGeneral()   
  • trunk/GSASIIpwdGUI.py

    r1143 r1147  
    17921792                G2frame.PatternTree.SetItemPyData(sub, \
    17931793                    G2IO.SetNewPhase(Name=PhaseName,SGData=SGData,cell=cell[1:]))
    1794                 Status.SetStatusText('Change space group if needed')
     1794                Status.SetStatusText('Change space group from '+str(controls[13])+' if needed')
    17951795        finally:
    17961796            dlg.Destroy()
  • trunk/imports/G2phase_CIF.py

    r1123 r1147  
    5353        return True
    5454    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
     55        self.Phase = G2IO.SetNewPhase(Name='new phase',SGData=G2IO.P1SGData) # create a new empty phase dict
    5556        returnstat = False
    5657        cellitems = (
Note: See TracChangeset for help on using the changeset viewer.