Changeset 8221f1c in sasmodels


Ignore:
Timestamp:
Feb 19, 2015 2:07:30 PM (10 years ago)
Author:
ajj
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
cfd4625
Parents:
12076cf (diff), 6edb74a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/SasView/sasmodels

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • example/sesansfit.py

    r0ac3db5 r9c117a2  
    44from sasmodels import bumps_model as sas 
    55kernel = sas.load_model('sphere', dtype='single') 
     6#kernel = sas.load_model('triaxial_ellipsoid', dtype='single') 
    67 
    78 
     
    1112    loader=Loader() 
    1213    data=loader.load('testsasview1.ses') 
     14    data.x /=10 
    1315     
    1416#    data = load_sesans('mydatfile.pz') 
     
    2022    err_data = np.ones_like(SElength)*0.03 
    2123 
     24    class Sample: 
     25        zacceptance = 0.1 # [A^-1] 
     26        thickness = 0.2 # [cm] 
     27         
    2228    class SESANSData1D: 
    2329        #q_zmax = 0.23 # [A^-1] 
    24         zacceptance = 0.1 # [A^-1] 
    25         lam = 2e-10 # [m] 
    26         thickness = 0.2 # [cm] 
     30        lam = 0.2 # [nm] 
    2731        x = SElength 
    2832        y = data 
    2933        dy = err_data 
    30     data = SesansData() 
    31 print dir(data) 
     34        sample = Sample() 
     35    data = SESANSData1D() 
    3236 
    3337radius = 1000 
    3438data.Rmax = 3*radius # [A] 
    3539 
     40##  Sphere parameters 
     41 
    3642phi = Parameter(0.1, name="phi") 
    3743model = sas.BumpsModel(data, kernel, 
    3844    scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) 
    39 phi.pmp(10) 
    40 model.radius.pmp(40) 
    41 model.sld.pm(2) 
    42 model.background.range(0,5) 
    43  
     45phi.range(0.001,0.90) 
     46#model.radius.pmp(40) 
     47model.radius.range(100,10000) 
     48#model.sld.pmp(5) 
     49#model.background 
     50#model.radius_pd=0 
     51#model.radius_pd_n=0 
    4452 
    4553if False: # have sans data 
     
    4957    problem = FitProblem(model) 
    5058 
     59 
     60### Tri-Axial Ellipsoid 
     61# 
     62#phi = Parameter(0.1, name='phi') 
     63#model = sas.BumpsModel(data, kernel, 
     64#    scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) 
     65#phi.range(0.001,0.90) 
     66##model.radius.pmp(40) 
     67#model.radius.range(100,10000) 
     68##model.sld.pmp(5) 
     69##model.background 
     70##model.radius_pd=0 
     71##model.radius_pd_n=0 
     72# 
     73#if False: # have sans data 
     74#    sansmodel = sas.BumpsModel(sans_data, kernel, **model.parameters()) 
     75#    problem = FitProblem([model, sansmodel]) 
     76#else: 
     77#    problem = FitProblem(model) 
  • sasmodels/bumps_model.py

    r62b3cb2 r8632a35  
    354354            #self._theory[:] = self._fn.eval(pars, pd_pars) 
    355355            if self.data_type == 'sesans': 
    356                 P = sesans.hankel(self.data.x, self.data.lam, 
     356                P = sesans.hankel(self.data.x, self.data.lam*1e-9, 
    357357                                  self.data.sample.thickness/10, self._fn_inputs[0], 
    358358                                  self._theory) 
  • sasmodels/direct_model.py

    rae7b97b r16bc3fc  
    4646    limits = kernel.info['limits'] 
    4747    disperser = pars.get(name+'_pd_type', 'gaussian') 
    48     value = pars.get(name) 
     48    value = pars.get(name, kernel.info['defaults'][name]) 
    4949    npts = pars.get(name+'_pd_n', 0) 
    5050    width = pars.get(name+'_pd', 0.0) 
     
    6767        q_vectors = [np.ascontiguousarray(q,dtype=dtype) for q in q_vectors] 
    6868        self.kernel = make_kernel(self.model, q_vectors) 
    69     def __call__(self, pars): 
     69    def __call__(self, **pars): 
    7070        return call_kernel(self.kernel, pars) 
    7171 
     
    9090                for pair in sys.argv[3:] 
    9191                for k,v in [pair.split('=')]) 
    92     Iq = model(pars) 
     92    Iq = model(**pars) 
    9393    print Iq[0] 
    9494 
  • sasmodels/kernelpy.py

    rf786ff3 r6edb74a  
    8787        self.pd_pars = pd_pars 
    8888 
    89     def __call__(self, fixed, pd, cutoff): 
     89    def __call__(self, fixed, pd, cutoff=1e-5): 
    9090        #print "fixed",fixed 
    9191        #print "pd", pd 
     
    144144    ########################################################## 
    145145 
    146     # weight vector, to be populated by polydispersity loops 
    147146    weight = np.empty(len(pd), 'd') 
    148  
    149     # identify which pd parameters are volume parameters 
    150     vol_weight_index = np.array([(index in vol_index) for index in pd_index]) 
    151  
    152     # Sort parameters in decreasing order of pd length 
    153     Npd = np.array([len(pdi[0]) for pdi in pd], 'i') 
    154     order = np.argsort(Npd)[::-1] 
    155     stride = np.cumprod(Npd[order]) 
    156     pd = [pd[index] for index in order] 
    157     pd_index = pd_index[order] 
    158     vol_weight_index = vol_weight_index[order] 
    159  
    160     fast_value = pd[0][0] 
    161     fast_weight = pd[0][1] 
     147    if weight.size > 0: 
     148        # weight vector, to be populated by polydispersity loops 
     149 
     150        # identify which pd parameters are volume parameters 
     151        vol_weight_index = np.array([(index in vol_index) for index in pd_index]) 
     152 
     153        # Sort parameters in decreasing order of pd length 
     154        Npd = np.array([len(pdi[0]) for pdi in pd], 'i') 
     155        order = np.argsort(Npd)[::-1] 
     156        stride = np.cumprod(Npd[order]) 
     157        pd = [pd[index] for index in order] 
     158        pd_index = pd_index[order] 
     159        vol_weight_index = vol_weight_index[order] 
     160 
     161        fast_value = pd[0][0] 
     162        fast_weight = pd[0][1] 
     163    else: 
     164        stride = np.array([1]) 
     165        vol_weight_index = slice(None, None) 
    162166 
    163167    ret = np.zeros_like(args[0]) 
     
    169173        fast_index = k%stride[0] 
    170174        if fast_index == 0:  # bottom loop complete ... check all other loops 
    171             for i,index, in enumerate(k%stride): 
    172                 args[pd_index[i]] = pd[i][0][index] 
    173                 weight[i] = pd[i][1][index] 
     175            if weight.size > 0: 
     176                for i,index, in enumerate(k%stride): 
     177                    args[pd_index[i]] = pd[i][0][index] 
     178                    weight[i] = pd[i][1][index] 
    174179        else: 
    175180            args[pd_index[0]] = fast_value[fast_index] 
  • sasmodels/models/broad_peak.py

    r636adb6 r6edb74a  
    5151 
    5252import numpy as np 
    53 from numpy import pi, inf, sin, cos, sqrt, exp, log 
     53from numpy import pi, inf, sin, cos, sqrt, exp, log, fabs 
    5454 
    5555name = "broad_peak" 
     
    9292def Iq(q, porod_scale, porod_exp, lorentz_scale, lorentz_length, peak_pos, lorentz_exp): 
    9393    inten = porod_scale/pow(q,porod_exp) + lorentz_scale/(1.0 \ 
    94         + pow((math.fabs(q-peak_pos)*lorentz_length),lorentz_exp)) 
     94        + pow((fabs(q-peak_pos)*lorentz_length),lorentz_exp)) 
    9595    return inten   
    9696 
  • sasmodels/generate.py

    rae7b97b r12076cf  
    503503    fn = q_pars['fn'] 
    504504 
    505     # Build polydispersity loops 
    506     depth = 4 
    507     offset = "" 
    508     loop_head = [] 
    509     loop_end = [] 
    510     for name in pd_pars: 
    511         subst = { 'name': name, 'offset': offset } 
    512         loop_head.append(indent(LOOP_OPEN%subst, depth)) 
    513         loop_end.insert(0, (" "*depth) + "}") 
    514         offset += '+N'+name 
    515         depth += 2 
     505    if len(pd_pars) > 0: 
     506        # Build polydispersity loops 
     507        depth = 4 
     508        offset = "" 
     509        loop_head = [] 
     510        loop_end = [] 
     511        for name in pd_pars: 
     512            subst = { 'name': name, 'offset': offset } 
     513            loop_head.append(indent(LOOP_OPEN%subst, depth)) 
     514            loop_end.insert(0, (" "*depth) + "}") 
     515            offset += '+N'+name 
     516            depth += 2 
    516517 
    517518    # The volume parameters in the inner loop are used to call the volume() 
Note: See TracChangeset for help on using the changeset viewer.