Changeset 2183


Ignore:
Timestamp:
Mar 24, 2016 9:58:40 AM (7 years ago)
Author:
vondreele
Message:

fix General - atomic wt. now updated on isotope change
add new Stacking fault option to make sequence of DIFFaX runs varying one variable - under development
fix problem in G2image & G2imageGUI where change in FlatBkg?, Background or Dark didn't change thresholds or image plot limits - these are now set to new image limits.
Some of these used tricky changes to sizer values

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2182 r2183  
    8787] = [wx.NewId() for item in range(2)]
    8888
    89 [ wxID_LOADDIFFAX,wxID_LAYERSIMULATE,
    90 ] = [wx.NewId() for item in range(2)]
     89[ wxID_LOADDIFFAX,wxID_LAYERSIMULATE,wxID_SEQUENCESIMULATE,
     90] = [wx.NewId() for item in range(3)]
    9191
    9292[ wxID_PAWLEYLOAD, wxID_PAWLEYESTIMATE, wxID_PAWLEYUPDATE,
     
    453453        SGTxt = wx.TextCtrl(self.panel,value=self.SpGrp,style=wx.TE_PROCESS_ENTER)
    454454        SGTxt.Bind(wx.EVT_TEXT_ENTER,OnSpaceGroup)
     455        SGTxt.Bind(wx.EVT_KILL_FOCUS,OnSpaceGroup)
    455456        sgSizer.Add(SGTxt,0,WACV)
    456457        mainSizer.Add(sgSizer,0,WACV)
     
    495496    ''' Solicit items needed to prepare DIFFaX control.dif file
    496497    '''
    497     def __init__(self,parent,ctrls):
     498    def __init__(self,parent,ctrls,parms=None):
    498499        wx.Dialog.__init__(self,parent,wx.ID_ANY,'DIFFaX controls',
    499500            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     
    507508        self.mult = '1'
    508509        self.multChoice = [str(2**i) for i in range(10)]
     510        self.Parms = parms
     511        self.Parm = None
     512        if self.Parms != None:
     513            self.Parm = self.Parms[0]
     514        self.parmRange = [0.,1.]
     515        self.parmStep = 2
    509516        self.Draw()
    510517       
     
    513520        def OnCalcType(event):
    514521            self.calcType = calcType.GetValue()
    515             self.Draw()
     522            wx.CallAfter(self.Draw)
    516523           
    517524        def OnPlane(event):
     
    523530        def OnMult(event):
    524531            self.mult = mult.GetValue()
     532           
     533        def OnParmSel(event):
     534            self.Parm = parmsel.GetValue()
     535           
     536        def OnNumStep(event):
     537            self.parmStep = int(numStep.GetValue())
     538           
     539        def OnParmRange(event):
     540            vals = parmrange.GetValue().split()
     541            try:
     542                vals = [float(vals[0]),float(vals[1])]
     543            except ValueError:
     544                vals = self.parmRange
     545            parmrange.SetValue('%.3f %.3f'%(vals[0],vals[1]))
     546            self.parmRange = vals
    525547       
    526548        self.panel.Destroy()
     
    536558        calcSizer.Add(calcType,0,WACV)
    537559        mainSizer.Add(calcSizer)
     560        if self.Parms:
     561            parmSel = wx.BoxSizer(wx.HORIZONTAL)
     562            parmSel.Add(wx.StaticText(self.panel,label=' Select parameter to vary: '),0,WACV)
     563            parmsel = wx.ComboBox(self.panel,value=self.Parm,choices=self.Parms,
     564                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     565            parmsel.Bind(wx.EVT_COMBOBOX,OnParmSel)
     566            parmSel.Add(parmsel,0,WACV)
     567            mainSizer.Add(parmSel)
     568            mainSizer.Add(wx.StaticText(self.panel,label=' Enter parameter range & no. steps: '),0,WACV)
     569            parmRange =  wx.BoxSizer(wx.HORIZONTAL)
     570            numChoice = [str(i+1) for i in range(10)]
     571            parmrange = wx.TextCtrl(self.panel,value='%.3f %.3f'%(self.parmRange[0],self.parmRange[1]),
     572                style=wx.TE_PROCESS_ENTER)
     573            parmrange.Bind(wx.EVT_TEXT_ENTER,OnParmRange)
     574            parmrange.Bind(wx.EVT_KILL_FOCUS,OnParmRange)
     575            parmRange.Add(parmrange,0,WACV)
     576            numStep = wx.ComboBox(self.panel,value=str(self.parmStep),choices=numChoice,
     577                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     578            numStep.Bind(wx.EVT_COMBOBOX,OnNumStep)
     579            parmRange.Add(numStep,0,WACV)
     580            mainSizer.Add(parmRange)           
    538581        if 'selected' in self.calcType:
    539582            planeSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    574617    def GetSelection(self):
    575618        if 'powder' in self.calcType:
    576             return '0\n0\n3\n','',''
     619            return '0\n0\n3\n','','',self.Parm,self.parmRange,self.parmStep
    577620        elif 'selected' in self.calcType:
    578621            return '0\n0\n4\n1\n%d\n%d\n16\n1\n%d\n0\nend\n'%    \
    579                 (self.planeChoice.index(self.plane)+1,self.lmaxChoice.index(self.lmax)+1,
    580                 self.multChoice.index(self.mult)+1),self.plane,self.lmax
     622                (self.planeChoice.index(self.plane)+1,self.lmaxChoice.index(self.lmax)+1,   \
     623                self.multChoice.index(self.mult)+1),self.plane,self.lmax,       \
     624                self.Parm,self.parmRange,self.parmStep
    581625
    582626    def OnOk(self,event):
     
    17411785        self.LayerDataEdit.Append(id=wxID_LAYERSIMULATE, kind=wx.ITEM_NORMAL,text='Simulate pattern',
    17421786            help='Simulate diffraction pattern from layer stacking')
     1787        self.LayerDataEdit.Append(id=wxID_SEQUENCESIMULATE, kind=wx.ITEM_NORMAL,text='Sequence simulations',
     1788            help='Sequence simulation changing one parameter')
    17431789        self.PostfillDataMenu()
    17441790                 
  • trunk/GSASIIimage.py

    r2179 r2183  
    441441       
    442442def ImageCompress(image,scale):
    443     'Needs a doc string'
     443    ''' Reduces size of image by selecting every n'th point
     444    param: image array: original image
     445    param: scale int: intervsl between selected points
     446    returns: array: reduced size image
     447    '''
    444448    if scale == 1:
    445449        return image
  • trunk/GSASIIimgGUI.py

    r2179 r2183  
    814814    def BackSizer():
    815815       
     816        def ResetThresholds():
     817            Imin = max(0.,np.min(G2frame.ImageZ))
     818            Imax = np.max(G2frame.ImageZ)
     819            data['range'] = [(Imin,Imax),[Imin,Imax]]
     820            masks['Thresholds'] = [(Imin,Imax),[Imin,Imax]]
     821            MaxSizer.GetChildren()[2].Window.SetValue(str(int(Imax)))   #tricky
     822            MaxSizer.GetChildren()[5].Window.SetValue(str(int(Imin)))   #tricky
     823       
    816824        def OnBackImage(event):
    817825            data['background image'][0] = backImage.GetValue()
    818826            G2frame.ImageZ = GetImageZ(G2frame,data)
     827            ResetThresholds()
    819828            G2plt.PlotExposedImage(G2frame,event=event)
    820829           
     
    822831            data['dark image'][0] = darkImage.GetValue()
    823832            G2frame.ImageZ = GetImageZ(G2frame,data)
     833            ResetThresholds()
    824834            G2plt.PlotExposedImage(G2frame,event=event)
    825835           
     
    833843            flatbkg.SetValue("%.0f"%(data['Flat Bkg']))   
    834844            G2frame.ImageZ += (oldFlat-data['Flat Bkg'])
     845            ResetThresholds()
    835846            G2plt.PlotExposedImage(G2frame,event=event)
    836847
     
    843854            backMult.SetValue("%.3f" % (data['background image'][1]))          #reset in case of error
    844855            G2frame.ImageZ = GetImageZ(G2frame,data)
     856            ResetThresholds()
    845857            G2plt.PlotExposedImage(G2frame,event=event)
    846858       
     
    853865            darkMult.SetValue("%.3f" % (data['dark image'][1]))          #reset in case of error
    854866            G2frame.ImageZ = GetImageZ(G2frame,data)
     867            ResetThresholds()
    855868            G2plt.PlotExposedImage(G2frame,event=event)
    856869       
     
    11081121    mainSizer.Add((5,10),0)   
    11091122    mainSizer.Add(ComboSizer(),0,wx.ALIGN_LEFT)
    1110     mainSizer.Add((5,5),0)           
    1111     mainSizer.Add(MaxSizer(),0,wx.ALIGN_LEFT|wx.EXPAND)
     1123    mainSizer.Add((5,5),0)
     1124    MaxSizer = MaxSizer()               #keep this so it can be changed in BackSizer   
     1125    mainSizer.Add(MaxSizer,0,wx.ALIGN_LEFT|wx.EXPAND)
    11121126   
    11131127    mainSizer.Add((5,5),0)
  • trunk/GSASIIphsGUI.py

    r2182 r2183  
    418418                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadDIFFaX, id=G2gd.wxID_LOADDIFFAX)
    419419                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSimulate, id=G2gd.wxID_LAYERSIMULATE)
     420                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSeqSimulate, id=G2gd.wxID_SEQUENCESIMULATE)
    420421                        if 'Wave Data' in pages:
    421422                            pass
     
    626627        def ElemSizer():
    627628           
    628             def OnIsotope(event):   #how can I update Atom weight on isotope change?
     629            def OnIsotope(event):
    629630                Obj = event.GetEventObject()
    630631                item = Indx[Obj.GetId()]
    631632                isotope = Obj.GetValue()
     633                nCols = len(generalData['AtomTypes'])+1
    632634                data['General']['Isotope'][item] = isotope
    633635                indx = generalData['AtomTypes'].index(item)
    634                 data['General']['AtomMass'][indx] = generalData['Isotopes'][item][isotope]['Mass']
     636                wt = generalData['Isotopes'][item][isotope]['Mass']
     637                elemSizer.GetChildren()[indx+3*nCols+1].Window.SetValue('%.3f'%(wt))    #tricky
     638                data['General']['AtomMass'][indx] = wt
    635639                density,mattCoeff = G2mth.getDensity(generalData)
    636640                denSizer[1].SetValue('%.3f'%(density))
     
    29252929        dlg = G2gd.DIFFaXcontrols(G2frame,ctrls)
    29262930        if dlg.ShowModal() == wx.ID_OK:
    2927             ctrls,plane,lmax = dlg.GetSelection()
     2931            ctrls,plane,lmax,x,x,x = dlg.GetSelection()
    29282932            data['Layers']['Sadp'] = {}
    29292933            data['Layers']['Sadp']['Plane'] = plane
     
    29662970        else:   #selected area
    29672971            G2pwd.StackSim(data['Layers'],ctrls)
    2968 #            G2pwd.CalcStackingSADP(data['Layers'])
     2972#            if GSASIIpath.GetConfigValue('debug'):
     2973#                G2pwd.CalcStackingSADP(data['Layers'])
    29692974        wx.CallAfter(UpdateLayerData)
     2975       
     2976    def OnSeqSimulate(event):
     2977       
     2978        ctrls = ''
     2979        Parms = G2pwd.GetStackParms(data['Layers'])
     2980        dlg = G2gd.DIFFaXcontrols(G2frame,ctrls,Parms)
     2981        if dlg.ShowModal() == wx.ID_OK:
     2982            ctrls,plane,lmax,parm,parmRange,parmStep = dlg.GetSelection()
     2983            data['Layers']['Sadp'] = {}
     2984            data['Layers']['Sadp']['Plane'] = plane
     2985            data['Layers']['Sadp']['Lmax'] = lmax
     2986            data['Layers']['Multi'] = [parm,parmRange,parmStep]
     2987        else:
     2988            return
     2989        print 'do sequence of simulations on...',parm,parmRange,parmStep
    29702990       
    29712991################################################################################
     
    70887108            FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.WavesData)
    70897109            G2frame.dataFrame.Bind(wx.EVT_MENU, OnWaveVary, id=G2gd.wxID_WAVEVARY)
    7090         # Stacking faults wxID_LAYERSIMULATE
     7110        # Stacking faults
    70917111        if data['General']['Type'] == 'faulted':
    70927112            FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.LayerData)
    70937113            G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadDIFFaX, id=G2gd.wxID_LOADDIFFAX)
    70947114            G2frame.dataFrame.Bind(wx.EVT_MENU, OnSimulate, id=G2gd.wxID_LAYERSIMULATE)
     7115            G2frame.dataFrame.Bind(wx.EVT_MENU, OnSeqSimulate, id=G2gd.wxID_SEQUENCESIMULATE)
    70957116        # Draw Options
    70967117        FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.DataDrawOptions)
  • trunk/GSASIIplot.py

    r2181 r2183  
    40664066    wx.BeginBusyCursor()
    40674067    try:
    4068         if newImage:                   
     4068        if newImage:
    40694069            Imin,Imax = Data['range'][1]
    40704070            MA = ma.masked_greater(ma.masked_less(G2frame.ImageZ,Zlim[0]),Zlim[1])
  • trunk/GSASIIpwd.py

    r2182 r2183  
    17381738################################################################################
    17391739
     1740def GetStackParms(Layers):
     1741   
     1742    Parms = []
     1743#cell parms
     1744    cell = Layers['Cell']
     1745    if Layers['Laue'] in ['-3','-3m','4/m','4/mmm','6/m','6/mmm']:
     1746        Parms.append('cellA')
     1747        Parms.append('cellC')
     1748    else:
     1749        Parms.append('cellA')
     1750        Parms.append('cellB')
     1751        Parms.append('cellC')
     1752        if Layers['Laue'] != 'mmm':
     1753            Parms.append('cellG')
     1754#Transition parms
     1755    Trans = Layers['Transitions']
     1756    for iY in range(len(Layers['Layers'])):
     1757        for iX in range(len(Layers['Layers'])):
     1758            Parms.append('TransP;%d;%d'%(iY,iX))
     1759            Parms.append('TransX;%d;%d'%(iY,iX))
     1760            Parms.append('TransY;%d;%d'%(iY,iX))
     1761            Parms.append('TransZ;%d;%d'%(iY,iX))
     1762    return Parms
     1763
    17401764def StackSim(Layers,ctrls,HistName='',scale=0.,background={},limits=[],inst={},profile=[]):
    17411765    '''Simulate powder or selected area diffraction pattern from stacking faults using DIFFaX
Note: See TracChangeset for help on using the changeset viewer.