Changeset 1126


Ignore:
Timestamp:
Oct 28, 2013 4:06:58 PM (10 years ago)
Author:
toby
Message:

fix radii editing & reflection table access in CIF export

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1124 r1126  
    1919import wx.lib.scrolledpanel as wxscroll
    2020import time
     21import copy
    2122import cPickle
    2223import sys
     
    10221023
    10231024class DisAglDialog(wx.Dialog):
    1024     '''Distance Angle Controls dialog
     1025    '''Distance/Angle Controls input dialog. After
     1026    :meth:`ShowModal` returns, the results are found in
     1027    dict :attr:`self.data`, which is accessed using :meth:`GetData`.
     1028
     1029    :param wx.Frame parent: reference to parent frame (or None)
     1030    :param dict data: a dict containing the current
     1031      search ranges or an empty dict, which causes default values
     1032      to be used.
     1033      Will be used to set element `DisAglCtls` in
     1034      :ref:`Phase Tree Item <Phase_table>`
     1035    :param dict default:  A dict containing the default
     1036      search ranges for each element.
    10251037    '''
    1026     def __default__(self,data,default):
     1038    def __init__(self,parent,data,default):
     1039        wx.Dialog.__init__(self,parent,wx.ID_ANY,
     1040                           'Distance Angle Controls',
     1041            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     1042        self.default = default
     1043        self.panel = wx.Panel(self)         #just a dummy - gets destroyed in Draw!
     1044        self._default(data,self.default)
     1045        self.Draw(self.data)
     1046               
     1047    def _default(self,data,default):
     1048        '''Set starting values for the search values, either from
     1049        the input array or from defaults, if input is null
     1050        '''
    10271051        if data:
    1028             self.data = data
     1052            self.data = copy.deepcopy(data) # don't mess with originals
    10291053        else:
    10301054            self.data = {}
     
    10341058            self.data['BondRadii'] = default['BondRadii'][:]
    10351059            self.data['AngleRadii'] = default['AngleRadii'][:]
    1036        
    1037     def __init__(self,parent,data,default):
    1038         wx.Dialog.__init__(self,parent,-1,'Distance Angle Controls',
    1039             pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
    1040         self.default = default
    1041         self.panel = wx.Panel(self)         #just a dummy - gets destroyed in Draw!
    1042         self.__default__(data,self.default)
    1043         self.Draw(self.data)
    1044                
     1060
    10451061    def Draw(self,data):
     1062        '''Creates the contents of the dialog. Normally called
     1063        by :meth:`__init__`.
     1064        '''
    10461065        self.panel.Destroy()
    10471066        self.panel = wx.Panel(self)
     
    11041123       
    11051124    def GetData(self):
     1125        'Returns the values from the dialog'
    11061126        return self.data
    11071127       
    11081128    def OnOk(self,event):
     1129        'Called when the OK button is pressed'
    11091130        parent = self.GetParent()
    11101131        parent.Raise()
     
    11121133       
    11131134    def OnReset(self,event):
     1135        'Called when the Reset button is pressed'
    11141136        data = {}
    1115         self.__default__(data,self.default)
     1137        self._default(data,self.default)
    11161138        self.Draw(self.data)
    11171139       
  • trunk/GSASIIobj.py

    r1077 r1126  
    177177  \         Pawley dmin      maximum Q (as d-space) to use for Pawley
    178178                             extraction (float)
    179   \         BondRadii        Radius for each atom used to compute
     179  \         BondRadii        Default radius for each atom used to compute
    180180                             interatomic distances (list of floats)
    181   \         AngleRadii       Radius for each atom used to compute
     181  \         AngleRadii       Default radius for each atom used to compute
    182182                             interatomic angles (list of floats)
     183  \         DisAglCtls       Dict with distance/angle search controls,
     184                             which has keys 'Name', 'AtomTypes',
     185                             'BondRadii', 'AngleRadii' which are as above
     186                             except are possibly edited. Also contains
     187                             'Factors', which is a 2 element list with
     188                             a multiplier for bond and angle search range
     189                             [typically (0.85,0.85)].
    183190ranId           \            unique random number Id for phase (int)
    184191pId             \            Phase Id number for current project (int).
  • trunk/exports/G2export_CIF.py

    r1123 r1126  
    700700            cfrac = cx+3
    701701            DisAglData = {}
    702             DisAglCtls = {}
    703702            # create a list of atoms, but skip atoms with zero occupancy
    704703            xyz = []
     
    707706                if self.parmDict.get(fpfx+str(i),atom[cfrac]) == 0.0: continue
    708707                xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3])
    709             if 'DisAglCtls' in generalData:
    710                 DisAglCtls = generalData['DisAglCtls']
    711             else: # should not happen, since DisAglDialog should be called for all
    712                 # phases before getting here
    713                 dlg = G2gd.DisAglDialog(self.G2frame,DisAglCtls,generalData)
     708            if 'DisAglCtls' not in generalData:
     709                # should not happen, since DisAglDialog should be called
     710                # for all phases before getting here
     711                dlg = G2gd.DisAglDialog(
     712                    self.G2frame,
     713                    {},
     714                    generalData)
    714715                if dlg.ShowModal() == wx.ID_OK:
    715                     DisAglCtls = dlg.GetData()
    716                     generalData['DisAglCtls'] = DisAglCtls
     716                    generalData['DisAglCtls'] = dlg.GetData()
    717717                else:
    718718                    dlg.Destroy()
     
    736736                DisAglData['covData'] = self.OverallParms['Covariance']
    737737            try:
    738                 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData)
     738                AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(
     739                    generalData['DisAglCtls'],
     740                    DisAglData)
    739741            except KeyError:        # inside DistAngle for missing atom types in DisAglCtls
    740742                print('**** ERROR - try again but do "Reset" to fill in missing atom types ****')
     
    10231025            for phasenam in histblk['Reflection Lists']:
    10241026                scale = self.Phases[phasenam]['Histograms'][histlbl]['Scale'][0]
    1025                 Icorr = np.array([refl[13] for refl in histblk['Reflection Lists'][phasenam]])[0]
    1026                 FO2 = np.array([refl[8] for refl in histblk['Reflection Lists'][phasenam]])
    1027                 I100 = scale*FO2*Icorr
     1027                refList = np.asarray(histblk['Reflection Lists'][phasenam]['RefList'])
     1028                I100 = scale*refList.T[8]*refList.T[11]
     1029                #Icorr = np.array([refl[13] for refl in histblk['Reflection Lists'][phasenam]])[0]
     1030                #FO2 = np.array([refl[8] for refl in histblk['Reflection Lists'][phasenam]])
     1031                #I100 = scale*FO2*Icorr
    10281032                Imax = max(Imax,max(I100))
    10291033
     
    10491053                scale = self.Phases[phasenam]['Histograms'][histlbl]['Scale'][0]
    10501054                phaseid = self.Phases[phasenam]['pId']
    1051                 refcount += len(histblk['Reflection Lists'][phasenam])
    1052                 for ref in histblk['Reflection Lists'][phasenam]:
     1055                refcount += len(histblk['Reflection Lists'][phasenam]['RefList'])
     1056                for j,ref in enumerate(histblk['Reflection Lists'][phasenam]['RefList']):
    10531057                    if DEBUG:
    10541058                        print('DEBUG: skipping reflection list')
     
    10731077                    s += PutInCol(G2mth.ValEsd(ref[4],-0.009),8)
    10741078                    if Imax > 0:
    1075                         I100 = 100.*scale*ref[8]*ref[13]/Imax
    1076                         s += PutInCol(G2mth.ValEsd(I100,-0.09),6)
     1079                        s += PutInCol(G2mth.ValEsd(100.*I100[j]/Imax,-0.09),6)
    10771080                    WriteCIFitem("  "+s)
    10781081
     
    11711174            dmax = None
    11721175            dmin = None
    1173             refcount = len(histblk['Data'])
    1174             for ref in histblk['Data']:
     1176            refcount = len(histblk['Data']['RefList'])
     1177            for ref in histblk['Data']['RefList']:
    11751178                s = "  "
    11761179                if hklmin is None:
     
    12541257            but = event.GetEventObject()
    12551258            phasedict = but.phasedict
    1256             dlg = G2gd.DisAglDialog(self.G2frame,{},phasedict['General'])
     1259            dlg = G2gd.DisAglDialog(
     1260                self.G2frame,
     1261                phasedict['General']['DisAglCtls'], # edited
     1262                phasedict['General'], # defaults
     1263                )
    12571264            if dlg.ShowModal() == wx.ID_OK:
    12581265                phasedict['General']['DisAglCtls'] = dlg.GetData()
     
    13791386            cfrac = cx+3
    13801387            DisAglData = {}
    1381             DisAglCtls = {}
    13821388            # create a list of atoms, but skip atoms with zero occupancy
    13831389            xyz = []
     
    13861392                if self.parmDict.get(fpfx+str(i),atom[cfrac]) == 0.0: continue
    13871393                xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3])
    1388             if 'DisAglCtls' in generalData:
    1389                 DisAglCtls = generalData['DisAglCtls']
    1390             else: # should not happen, since DisAglDialog should be called for all
    1391                 # phases before getting here
    1392                 dlg = G2gd.DisAglDialog(self.cifdefs,DisAglCtls,generalData)
     1394            if 'DisAglCtls' not in generalData:
     1395                # should not be used, since DisAglDialog should be called
     1396                # for all phases before getting here
     1397                dlg = G2gd.DisAglDialog(
     1398                    self.cifdefs,
     1399                    {},
     1400                    generalData)
    13931401                if dlg.ShowModal() == wx.ID_OK:
    1394                     DisAglCtls = dlg.GetData()
    1395                     generalData['DisAglCtls'] = DisAglCtls
     1402                    generalData['DisAglCtls'] = dlg.GetData()
    13961403                else:
    13971404                    dlg.Destroy()
     
    14271434                DisAglData['covData'] = self.OverallParms['Covariance']
    14281435            try:
    1429                 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData)
     1436                AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(
     1437                    generalData['DisAglCtls'],
     1438                    DisAglData)
    14301439            except KeyError:        # inside DistAngle for missing atom types in DisAglCtls
    14311440                print('**** ERROR - try again but do "Reset" to fill in missing atom types ****')
     
    16091618                    )
    16101619                if not EditInstNames(): return
    1611         # check for a distance-angle range search range for each phase
    16121620        if not self.quickmode:
     1621            # check for a distance-angle range search range for each phase
    16131622            for phasenam in sorted(self.Phases.keys()):
    16141623                #i = self.Phases[phasenam]['pId']
    16151624                phasedict = self.Phases[phasenam] # pointer to current phase info           
    16161625                if 'DisAglCtls' not in phasedict['General']:
    1617                     dlg = G2gd.DisAglDialog(self.G2frame,{},phasedict['General'])
     1626                    dlg = G2gd.DisAglDialog(
     1627                        self.G2frame,
     1628                        {},
     1629                        phasedict['General'])
    16181630                    if dlg.ShowModal() == wx.ID_OK:
    16191631                        phasedict['General']['DisAglCtls'] = dlg.GetData()
Note: See TracChangeset for help on using the changeset viewer.