Changeset 1266


Ignore:
Timestamp:
Mar 28, 2014 11:03:17 AM (8 years ago)
Author:
vondreele
Message:

change some formats in Image Controls
enable insertion of additional points in polygon & frame masks
add code for particle distributions

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r1222 r1266  
    418418            except ValueError:
    419419                pass
    420             waveSel.SetValue("%6.5f" % (data['wavelength']))          #reset in case of error
     420            waveSel.SetValue("%7.5f" % (data['wavelength']))          #reset in case of error
    421421           
    422422        def OnDetDepthRef(event):
     
    437437            wx.ALIGN_CENTER_VERTICAL)
    438438        cent = data['center']
    439         centText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%8.3f,%8.3f" % (cent[0],cent[1])),style=wx.TE_READONLY)
     439        centText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%7.2f,%7.2f" % (cent[0],cent[1])),style=wx.TE_READONLY)
    440440        centText.SetBackgroundColour(VERY_LIGHT_GREY)
    441441        calibSizer.Add(centText,0,wx.ALIGN_CENTER_VERTICAL)       
    442442        calibSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Wavelength'),0,
    443443            wx.ALIGN_CENTER_VERTICAL)
    444         waveSel = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%6.5f" % (data['wavelength'])),
     444        waveSel = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%7.5f" % (data['wavelength'])),
    445445            style=wx.TE_PROCESS_ENTER)
    446446        waveSel.Bind(wx.EVT_TEXT_ENTER,OnWavelength)
     
    449449        calibSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Distance'),0,
    450450            wx.ALIGN_CENTER_VERTICAL)
    451         distSel = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%8.3f"%(data['distance'])),style=wx.TE_READONLY)
     451        distSel = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%8.2f"%(data['distance'])),style=wx.TE_READONLY)
    452452        distSel.SetBackgroundColour(VERY_LIGHT_GREY)
    453453        calibSizer.Add(distSel,0,wx.ALIGN_CENTER_VERTICAL)
  • trunk/GSASIIplot.py

    r1264 r1266  
    25062506                    polygon.append([x0,y0])
    25072507                    G2frame.MaskKey = ''
    2508                     G2frame.G2plotNB.status.SetFields(['','Polygon closed - RB drag a vertex to change shape'])
     2508                    G2frame.G2plotNB.status.SetFields(['','Polygon closed - RB vertex drag to move, LB vertex drag to insert'])
    25092509                else:
    25102510                    G2frame.G2plotNB.status.SetFields(['','New polygon point: %.1f,%.1f'%(Xpos,Ypos)])
     
    25162516                    frame.append([x0,y0])
    25172517                    G2frame.MaskKey = ''
    2518                     G2frame.G2plotNB.status.SetFields(['','Frame closed - RB drag a vertex to change shape'])
     2518                    G2frame.G2plotNB.status.SetFields(['','Frame closed - RB vertex drag to move, LB vertex drag to insert'])
    25192519                else:
    25202520                    G2frame.G2plotNB.status.SetFields(['','New frame point: %.1f,%.1f'%(Xpos,Ypos)])
     
    26072607                            else:
    26082608                                arcs[aN][1][1] = int(G2img.GetAzm(Xpos,Ypos,Data))
    2609                     for poly in G2frame.polyList:   #merging points problem here & how can we insert a point?
     2609                    for poly in G2frame.polyList:   #merging points problem here?
    26102610                        if Obj == poly[0]:
    26112611                            ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0]
     
    26142614                            for i,xy in enumerate(polygons[pN]):
    26152615                                if np.allclose(np.array([xy]),oldPos,atol=1.0):
    2616                                     polygons[pN][i] = Xpos,Ypos
     2616                                    if event.button == 1:
     2617                                        polygons[pN][i] = Xpos,Ypos
     2618                                    elif event.button == 3:
     2619                                        polygons[pN].insert(i,[Xpos,Ypos])
     2620                                        break
    26172621                    if frame:
    26182622                        oldPos = np.array([G2frame.mousePicked.xdata,G2frame.mousePicked.ydata])
    26192623                        for i,xy in enumerate(frame):
    26202624                            if np.allclose(np.array([xy]),oldPos,atol=1.0):
    2621                                 frame[i] = Xpos,Ypos
     2625                                if event.button == 1:
     2626                                    frame[i] = Xpos,Ypos
     2627                                elif event.button == 3:
     2628                                    frame.insert(i,[Xpos,Ypos])
     2629                                    break
    26222630                    G2imG.UpdateMasks(G2frame,Masks)
    26232631#                else:                  #keep for future debugging
  • trunk/GSASIIsasd.py

    r1263 r1266  
    311311    L,T = arg[:2]
    312312    return CylinderVol(R,[L,])-CylinderVol(R-T,[L,])
     313   
     314################################################################################
     315#### Distribution functions & their cumulative fxns
     316################################################################################
     317
     318def LogNormalDist(x,pos,scale,shape):
     319    ''' Standard LogNormal distribution - numpy friendly on x axis
     320    ref: http://www.itl.nist.gov/div898/handbook/index.htm 1.3.6.6.9
     321    param float x: independent axis (can be numpy array)
     322    param float pos: location of distribution
     323    param float scale: width of distribution (m)
     324    param float shape: shape - (sigma of log(LogNormal))
     325    returns float: LogNormal distribution
     326    '''
     327    return np.exp(-np.log((x-pos)/scale)**2/(2.*shape**2))/(np.sqrt(2.*np.pi)*(x-pos)*shape)
     328   
     329def GaussDist(x,pos,scale,shape):
     330    ''' Standard Normal distribution - numpy friendly on x axis
     331    param float x: independent axis (can be numpy array)
     332    param float pos: location of distribution
     333    param float scale: width of distribution (sigma)
     334    param float shape: not used
     335    returns float: Normal distribution
     336    '''
     337    return (1./scale*np.sqrt(2.*np.pi))*np.exp(-(x-pos)**2/(2.*scale**2))
     338   
     339def LSWDist(x,pos,scale,shape):
     340    ''' Lifshitz-Slyozov-Wagner Ostwald ripening distribution - numpy friendly on x axis
     341    ref:
     342    param float x: independent axis (can be numpy array)
     343    param float pos: location of distribution
     344    param float scale: not used
     345    param float shape: not used
     346    returns float: LSW distribution   
     347    '''
     348    redX = x/pos
     349    result = (81.*2**(-5/3.))*(redX**2*np.exp(-redX/(1.5-redX)))/((1.5-redX)**(11/3.)*(3.-redX)**(7/3.))
     350    return result/pos
     351   
     352def SchulzZimmDist(x,pos,scale,shape):
     353    ''' Schulz-Zimm macromolecule distribution - numpy friendly on x axis
     354    ref: http://goldbook.iupac.org/S05502.html
     355    param float x: independent axis (can be numpy array)
     356    param float pos: location of distribution
     357    param float scale: width of distribution (sigma)
     358    param float shape: not used
     359    returns float: Schulz-Zimm distribution
     360    '''
     361    b = (2.*pos/scale)**2
     362    a = b/pos
     363    if b<70:    #why bother?
     364        return (a**(b+1.))*x**b*np.exp(-a*x)/scsp.gamma(b+1.)
     365    else:
     366        return np.exp((b+1.)*np.log(a)-spsc.gammaln(b+1.)+b*np.log(x)-(a*x))
     367           
     368def LogNormalCume(x,pos,scale,shape):
     369    ''' Standard LogNormal cumulative distribution - numpy friendly on x axis
     370    ref: http://www.itl.nist.gov/div898/handbook/index.htm 1.3.6.6.9
     371    param float x: independent axis (can be numpy array)
     372    param float pos: location of distribution
     373    param float scale: width of distribution (sigma)
     374    param float shape: shape parameter
     375    returns float: LogNormal cumulative distribution
     376    '''
     377    return scsp.erf(np.log((x-pos)/shape)/(np.sqrt(2.)*scale)+1.)/2.
     378   
     379def GaussCume(x,pos,scale,shape):
     380    ''' Standard Normal cumulative distribution - numpy friendly on x axis
     381    param float x: independent axis (can be numpy array)
     382    param float pos: location of distribution
     383    param float scale: width of distribution (sigma)
     384    param float shape: not used
     385    returns float: Normal cumulative distribution
     386    '''
     387    return scsp.erf((x-pos)/(np.sqrt(2.)*scale)+1.)/2.
     388   
     389def LSWCume(x,pos,scale,shape):
     390    ''' Lifshitz-Slyozov-Wagner Ostwald ripening cumulative distribution - numpy friendly on x axis
     391    param float x: independent axis (can be numpy array)
     392    param float pos: location of distribution
     393    param float scale: not used
     394    param float shape: not used
     395    returns float: LSW cumulative distribution
     396    '''
     397    nP = int(np.ceil(x/30+30))
     398    return []
     399   
     400def SchulzZimmCume(x,pos,scale,shape):
     401    ''' Schulz-Zimm cumulative distribution - numpy friendly on x axis
     402    param float x: independent axis (can be numpy array)
     403    param float pos: location of distribution
     404    param float scale: width of distribution (sigma)
     405    param float shape: not used
     406    returns float: Normal distribution
     407    '''
     408    return []
     409   
    313410         
    314411################################################################################
     
    804901def ModelFit(Profile,ProfDict,Limits,Substances,Sample,data):
    805902    print 'do model fit'
     903   
     904def ModelFxn(Q,G,parmDict,SQfxn,args=[]):
     905    return SQfxn(Q,args)
    806906           
    807907   
Note: See TracChangeset for help on using the changeset viewer.