Changeset 1237 for trunk/GSASIIsasd.py


Ignore:
Timestamp:
Mar 5, 2014 2:14:48 PM (8 years ago)
Author:
vondreele
Message:

Allow changes to limits when in SASD Models
"fix" matplotlib warning message when log plot is hit with a mouse button event
There is still an underlying problem.
Mods to SASD Model to have scaled errors on data for fitting purposes - uses wtFactor
Start on size distribution fitting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIsasd.py

    r1234 r1237  
    5757   
    5858###############################################################################
    59 #### Particle form factors
     59#### Particle form factors & volumes as class definitions
    6060###############################################################################
    6161
    6262class SASDParticles(object):
    63     def __init__(self,Q,name=None,parms=None,parNames=None):
    64         self.Q = Q
     63    def __init__(self,name=None,parNames=None):
    6564        self.name = name
    66         self.Parms = parms
    6765        self.ParmNames = parmNames
    6866       
     
    7674       
    7775class Sphere(SASDParticles):
    78     def __init__(self,Q,name=None,parms=None,parmNames=None):
    79         self.Q = Q
     76    def __init__(self,name=None,parmNames=None):
    8077        self.Name = name
    8178        if self.Name == None:
    8279            self.Name = 'Sphere'
    83         self.Parms = parms
    84         if self.Parms == None:
    85             self.Parms = [50.0,]
    8680        self.ParmNames = parmNames
    8781        if self.ParmNames == None:
    8882            self.ParmNames = ['Radius',]
    8983       
    90     def FormFactor(self):
     84    def FormFactor(self,Q,Parms):
    9185        ''' Compute hard sphere form factor - can use numpy arrays
    9286        param float:Q Q value array (usually in A-1)
     
    9488        returns float: form factors as array as needed
    9589        '''
    96         QR = self.Q*self.Parms[0]
     90        QR = Q*Parms[0]
    9791        return (3./(QR**3))*(np.sin(QR)-(QR*np.cos(QR)))
    9892       
    99     def Volume(self):
     93    def Volume(self,Parms):
    10094        ''' Compute volume of sphere
    10195        - numpy array friendly
     
    10397        returns float: volume
    10498        '''
    105         return (4./3.)*np.pi*self.Parms[0]**3
    106        
    107        
    108    
     99        return (4./3.)*np.pi*Parms[0]**3
     100       
     101class Spheroid(SASDParticles):
     102    def __init__(self,name=None,parmNames=None):
     103        self.Name = name
     104        if self.Name == None:
     105            self.Name = 'Spheroid'
     106        self.ParmNames = parmNames
     107        if self.ParmNames == None:
     108            self.ParmNames = ['Radius','Aspect ratio']
     109   
     110    def FormFactor(self,Q,Parms):
     111        ''' Compute form factor of cylindrically symmetric ellipsoid (spheroid)
     112        - can use numpy arrays for R & AR; will return corresponding numpy array
     113        param float:Q Q value array (usually in A-1)
     114        param float R: radius along 2 axes of spheroid
     115        param float AR: aspect ratio so 3rd axis = R*AR
     116        returns float: form factors as array as needed
     117        '''
     118        R,AR = Parms
     119        NP = 50
     120        if 0.99 < AR < 1.01:
     121            return SphereFF(Q,R,0)
     122        else:
     123            cth = np.linspace(0,1.,NP)
     124            Rct = R*np.sqrt(1.+(AR**2-1.)*cth**2)
     125            return np.sqrt(np.sum(SphereFF(Q[:,np.newaxis],Rct,0)**2,axis=1)/NP)
     126       
     127    def Volume(self,Parms):
     128        ''' Compute volume of cylindrically symmetric ellipsoid (spheroid)
     129        - numpy array friendly
     130        param float R: radius along 2 axes of spheroid
     131        param float AR: aspect ratio so radius of 3rd axis = R*AR
     132        returns float: volume
     133        '''
     134        R,AR = Parms
     135        return AR*(4./3.)*np.pi*R**3
     136       
     137###############################################################################
     138#### Particle form factors
     139###############################################################################
    109140
    110141def SphereFF(Q,R,dummy=0):
     
    274305###############################################################################
    275306
    276 def SizeDistribution(Profile,Limits,Substances,Sample,data):
     307def SizeDistribution(Profile,ProfDict,Limits,Substances,Sample,data):
     308    if data['Size']['logBins']:
     309        Bins = np.logspace(np.log10(data['Size']['MinDiam']),np.log10(data['Size']['MaxDiam']),
     310            data['Size']['Nbins']+1,True)
     311    else:
     312        Bins = np.linspace(data['Size']['MinDiam'],data['Size']['MaxDiam'],
     313            data['Size']['Nbins']+1,True)
     314    Dbins = np.diff(Bins)
     315    BinMag = Dbins*np.ones_like(Dbins)
     316    print np.sum(BinMag)
     317       
    277318    print data['Size']
    278319#    print Limits
Note: See TracChangeset for help on using the changeset viewer.