Changeset 2646


Ignore:
Timestamp:
Jan 19, 2017 12:18:51 PM (5 years ago)
Author:
vondreele
Message:

added waterfall colors to single & multiple I(Q)..G(r) plots
a start on fitting stacking fault models - does nothing at present

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2645 r2646  
    24172417        self.Legend = False
    24182418        self.SinglePlot = True
     2419        self.Waterfall = False
    24192420        self.selections= None
    24202421        self.PDFselections = None
  • trunk/GSASIIgrid.py

    r2645 r2646  
    8686] = [wx.NewId() for item in range(2)]
    8787
    88 [ wxID_LOADDIFFAX,wxID_LAYERSIMULATE,wxID_SEQUENCESIMULATE, wxID_COPYPHASE,
    89 ] = [wx.NewId() for item in range(4)]
     88[ wxID_LOADDIFFAX,wxID_LAYERSIMULATE,wxID_SEQUENCESIMULATE, wxID_LAYERSFIT, wxID_COPYPHASE,
     89] = [wx.NewId() for item in range(5)]
    9090
    9191[ wxID_PAWLEYLOAD, wxID_PAWLEYESTIMATE, wxID_PAWLEYUPDATE, wxID_PAWLEYSELALL, wxID_PAWLEYSELNONE,
     
    23262326        self.LayerDataEdit.Append(id=wxID_LAYERSIMULATE, kind=wx.ITEM_NORMAL,text='Simulate pattern',
    23272327            help='Simulate diffraction pattern from layer stacking')
     2328        self.LayerDataEdit.Append(id=wxID_LAYERSFIT, kind=wx.ITEM_NORMAL,text='Fit pattern',
     2329            help='Fit diffraction pattern with layer stacking model')
    23282330        self.LayerDataEdit.Append(id=wxID_SEQUENCESIMULATE, kind=wx.ITEM_NORMAL,text='Sequence simulations',
    23292331            help='Sequence simulation changing one parameter')
  • trunk/GSASIIphsGUI.py

    r2642 r2646  
    386386                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSimulate, id=G2gd.wxID_LAYERSIMULATE)
    387387                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSeqSimulate, id=G2gd.wxID_SEQUENCESIMULATE)
     388                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnFitLayers, id=G2gd.wxID_LAYERSFIT)                       
    388389                        if 'Wave Data' in pages:
    389390                            pass
     
    27372738            3*[wg.GRID_VALUE_FLOAT+':10,5',]+2*[wg.GRID_VALUE_FLOAT+':10,4',] #x,y,z,frac,Uiso
    27382739        transTypes = [wg.GRID_VALUE_FLOAT+':10,3',]+3*[wg.GRID_VALUE_FLOAT+':10,5',]+ \
    2739             [wg.GRID_VALUE_CHOICE+": ,P,Dx,Dy,Dz",wg.GRID_VALUE_BOOL,]
     2740            [wg.GRID_VALUE_CHOICE+": ,P,Dx,Dy,Dz,Dxy,Dxz,Dyz,Dxyz",wg.GRID_VALUE_BOOL,]
    27402741        plotDefaults = {'oldxy':[0.,0.],'Quaternion':[0.,0.,0.,1.],'cameraPos':30.,'viewDir':[0,0,1],
    27412742            'viewPoint':[[0.,0.,0.],[]],}
     
    34903491        wx.MessageBox('Simulation finished',caption='Stacking fault simulation',style=wx.ICON_EXCLAMATION)
    34913492        wx.CallAfter(UpdateLayerData)
     3493       
     3494    def OnFitLayers(event):
     3495        print ' fit stacking fault model TBD'
     3496        import scipy.optimize as opt
     3497        wx.BeginBusyCursor()
     3498#        Min,Init,Done = SetupPDFEval()
     3499#        xstart = Init()
     3500#        rms = Min(xstart)
     3501#        print('Optimizing corrections to improve G(r) at low r')
     3502#        print('start: Flat Bkg={:.1f}, BackRatio={:.3f}, Ruland={:.3f} (RMS:{:.2f})'.format(
     3503#                data['Flat Bkg'],data['BackRatio'],data['Ruland'],rms))
     3504#       
     3505#        res = opt.minimize(Min,xstart,bounds=([0,None],[0,1],[0.01,1]),
     3506#                           method='L-BFGS-B',options={'maxiter':5})
     3507#        Done(res['x'])     
     3508#        print('end:   Flat Bkg={:.1f}, BackRatio={:.3f}, Ruland={:.3f} (RMS:{:.2f})\n'.format(
     3509#                data['Flat Bkg'],data['BackRatio'],data['Ruland'],res['fun']))
     3510        wx.EndBusyCursor()
     3511        wx.CallAfter(UpdateLayerData)
     3512        G2plt.PlotPatterns(G2frame,plotType='PWDR')
    34923513       
    34933514    def OnSeqSimulate(event):
     
    79978018        G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadDIFFaX, id=G2gd.wxID_LOADDIFFAX)
    79988019        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSimulate, id=G2gd.wxID_LAYERSIMULATE)
     8020        G2frame.dataFrame.Bind(wx.EVT_MENU, OnFitLayers, id=G2gd.wxID_LAYERSFIT)                       
    79998021        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSeqSimulate, id=G2gd.wxID_SEQUENCESIMULATE)
    80008022        # Draw Options
  • trunk/GSASIIplot.py

    r2637 r2646  
    4343import OpenGL.GLU as GLU
    4444import gltext
     45import matplotlib.colors as mpcls
    4546from matplotlib.backends.backend_wx import _load_bitmap
    4647from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
     
    23802381                G2frame.SinglePlot = False
    23812382                Page.Offset = [0.,0.]
     2383        elif not G2frame.Contour and event.key == 'w':
     2384            G2frame.Waterfall = not G2frame.Waterfall
    23822385        elif event.key == 'f' and not G2frame.SinglePlot:
    23832386            choices = G2gd.GetPatternTreeDataNames(G2frame,'PDF ')
     
    24502453    else:
    24512454        Page.Choice = (' key press','l: offset left','r: offset right','d: offset down','u: offset up',
    2452             'o: reset offset','t: toggle legend','c: contour on',
     2455            'o: reset offset','t: toggle legend','c: contour on','w: toggle waterfall colors (slow!)',
    24532456            'm: toggle multiplot','s: color scheme','f: select data' )
    24542457    Page.keyPress = OnPlotKeyPress
     
    25362539        Ymin = np.amin(XYlist.T[1])
    25372540        Ymax = np.amax(XYlist.T[1])
     2541        normcl = mpcls.Normalize(Ymin,Ymax)
    25382542        dy = 0.02*(Ymax-Ymin)
    25392543        Plot.set_xlim(Xmin-dx,Xmax+dx)
    25402544        Plot.set_ylim(Ymin-dy,Ymax+dy)
    25412545        acolor = mpl.cm.get_cmap(G2frame.ContourColor)
    2542         if XYlist.shape[0]>1:           
    2543             colorRange = np.arange(XYlist.shape[0])
    2544             lines = mplC.LineCollection(XYlist,cmap=acolor)
    2545             lines.set_array(colorRange)
     2546        if XYlist.shape[0]>1:
     2547            if G2frame.Waterfall:
     2548                for xylist in XYlist:           
     2549                    ymin = np.amin(xylist.T[1])
     2550                    ymax = np.amax(xylist.T[1])
     2551                    normcl = mpcls.Normalize(ymin,ymax)
     2552                    colorRange = xylist.T[1]
     2553                    segs = np.reshape(np.hstack((xylist[:-1],xylist[1:])),(-1,2,2))
     2554                    line = mplC.LineCollection(segs,cmap=acolor,norm=normcl)
     2555                    line.set_array(colorRange)
     2556                    Plot.add_collection(line)
     2557                axcb = Page.figure.colorbar(line)
     2558                axcb.set_label('Intensity')
     2559            else:   #ok
     2560                lines = mplC.LineCollection(XYlist,cmap=acolor)
     2561                lines.set_array(np.arange(XYlist.shape[0]))
     2562                Plot.add_collection(lines)
     2563                axcb = Page.figure.colorbar(lines)
     2564                axcb.set_label('PDF number')
    25462565        else:
    2547             lines = mplC.LineCollection(XYlist,color=colors[0])
    2548         Plot.add_collection(lines)
     2566            if G2frame.Waterfall:
     2567                colorRange = XYlist[0].T[1]
     2568                segs = np.reshape(np.hstack((XYlist[0][:-1],XYlist[0][1:])),(-1,2,2))
     2569                line = mplC.LineCollection(segs,cmap=acolor,norm=normcl)
     2570                line.set_array(colorRange)
     2571                Plot.add_collection(line)
     2572                axcb = Page.figure.colorbar(line)
     2573                axcb.set_label('Intensity')
     2574            else:   #ok
     2575                line = mplC.LineCollection(XYlist,color=colors[0])
     2576                Plot.add_collection(line)
    25492577        if plotType == 'G(R)':
    25502578            Xb = [0.,2.5]
     
    25552583        elif plotType == 'S(Q)':
    25562584            Plot.axhline(1.,color=wx.BLACK)
    2557         if XYlist.shape[0] > 1:
    2558             axcb = Page.figure.colorbar(lines)
    2559             axcb.set_label('PDF number')
    25602585       
    25612586#    elif G2frame.Legend:
Note: See TracChangeset for help on using the changeset viewer.