Changeset a006b63 in sasmodels


Ignore:
Timestamp:
Feb 18, 2015 5:04:51 PM (5 years ago)
Author:
jhbakker
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:
ff58110, e166cb9, 9c117a2
Parents:
0ac3db5 (diff), ea7ffce (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:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    ra503bfd r3271e20  
    722722        parameters = COMMON_PARAMETERS + kernel_module.parameters, 
    723723        source = getattr(kernel_module, 'source', []), 
     724        oldname = kernel_module.oldname, 
     725        oldpars = kernel_module.oldpars, 
    724726        ) 
    725727    # Fill in attributes which default to None 
  • sasmodels/models/cylinder.py

    ra503bfd rea7ffce  
    4343.. figure:: img/orientation2.jpg 
    4444 
    45     Examples of the angles for oriented pp against the detector plane. 
     45    Examples of the angles for oriented cylinders against the detector plane. 
    4646 
    4747NB: The 2nd virial coefficient of the cylinder is calculated based on the 
     
    113113title = "Right circular cylinder with uniform scattering length density." 
    114114description = """ 
    115      P(q)= 2*(sld - solvent_sld)*V*sin(qLcos(alpha/2)) 
    116             /[qLcos(alpha/2)]*J1(qRsin(alpha/2))/[qRsin(alpha)] 
     115     f(q,alpha) = 2*(sld - solvent_sld)*V*sin(qLcos(alpha/2)) 
     116                /[qLcos(alpha/2)]*J1(qRsin(alpha/2))/[qRsin(alpha)] 
    117117 
    118             P(q,alpha)= scale/V*f(q)^(2)+background 
     118            P(q,alpha)= scale/V*f(q,alpha)^(2)+background 
    119119            V: Volume of the cylinder 
    120120            R: Radius of the cylinder 
     
    125125            :the ouput is P(q)=scale/V*integral 
    126126            from pi/2 to zero of... 
    127             f(q)^(2)*sin(alpha)*dalpha + background 
     127            f(q,alpha)^(2)*sin(alpha)*dalpha + background 
    128128""" 
    129129 
     
    169169oldpars=dict(theta='cyl_theta', phi='cyl_phi', sld='sldCyl', solvent_sld='sldSolv') 
    170170 
     171 
     172# test values: 
     173# [ 
     174#   [ {parameters}, q, I(q)], 
     175#   [ {parameters}, [q], [I(q)] ], 
     176#   [ {parameters}, [q1, q2, ...], [I(q1), I(q2), ...]], 
     177 
     178#   [ {parameters}, (qx, qy), I(qx, Iqy)], 
     179#   [ {parameters}, [(qx1, qy1), (qx2, qy2), ...], [I(qx1,qy1), I(qx2,qy2), ...], 
     180#   ... 
     181# ] 
     182# Precision defaults to 7 digits (relative) for single, 14 for double 
     183# May want a limited precision version that checks for 8-n or 15-n digits respectively 
     184tests = [ 
     185    [{},  0.2, 0.041761386790780453], 
     186    [{'theta':10.0, 'phi':10.0}, [0.2], [0.041761386790780453]], 
     187    [{'theta':10.0, 'phi':10.0}, (0.2, 2.5), 0.038176446608393366], 
     188    [{'theta':10.0, 'phi':10.0}, [(0.2, 2.5)], [0.038176446608393366]], 
     189    ] 
     190 
  • sasmodels/sasview_model.py

    r250fa25 r0a82216  
    3232 
    3333 
    34 def make_class(kernel_module, dtype='single'): 
     34def make_class(kernel_module, dtype='single', namestyle='name'): 
    3535    """ 
    3636    Load the sasview model defined in *kernel_module*. 
    3737 
    3838    Returns a class that can be used directly as a sasview model. 
     39 
     40    Defaults to using the new name for a model. Setting namestyle='name' 
     41    will produce a class with a name compatible with SasView 
    3942    """ 
    4043    model =  load_model(kernel_module, dtype=dtype) 
     
    4245        SasviewModel.__init__(self, model) 
    4346    attrs = dict(__init__=__init__) 
    44     ConstructedModel = type(model.info['name'],  (SasviewModel,), attrs) 
     47    ConstructedModel = type(model.info[namestyle],  (SasviewModel,), attrs) 
    4548    return ConstructedModel 
    4649 
     
    5457 
    5558        self.name = model.info['name'] 
     59        self.oldname = model.info['oldname'] 
    5660        self.description = model.info['description'] 
    5761        self.category = None 
  • example/sesansfit.py

    re806077 r0ac3db5  
    66 
    77 
    8 radius = 1000 
    9 if False: # fix when data loader exists 
    10     from sasmodels.dataloader import load_sesans, load_sans 
    11     data = load_sesans('mydatfile.pz') 
    12     sans_data = load_sans('mysansfile.xml') 
     8if True: # fix when data loader exists 
     9#    from sas.dataloader.readers\ 
     10    from sas.dataloader.loader import Loader 
     11    loader=Loader() 
     12    data=loader.load('testsasview1.ses') 
     13     
     14#    data = load_sesans('mydatfile.pz') 
     15#    sans_data = load_sans('mysansfile.xml') 
     16 
    1317else: 
    1418    SElength = np.linspace(0, 2400, 61) # [A] 
     
    1620    err_data = np.ones_like(SElength)*0.03 
    1721 
    18     class SesansData: 
     22    class SESANSData1D: 
    1923        #q_zmax = 0.23 # [A^-1] 
    20         q_zmax = 0.1 # [A^-1] 
    21         SElength = np.linspace(0, 2400, 61) # [A] 
    22         Rmax = 3*radius # [A] 
    23         wavelength = 2e-10 # [m] 
     24        zacceptance = 0.1 # [A^-1] 
     25        lam = 2e-10 # [m] 
    2426        thickness = 0.2 # [cm] 
    25         SElength = SElength 
    26         data = data 
    27         err_data = err_data 
     27        x = SElength 
     28        y = data 
     29        dy = err_data 
    2830    data = SesansData() 
     31print dir(data) 
     32 
     33radius = 1000 
     34data.Rmax = 3*radius # [A] 
    2935 
    3036phi = Parameter(0.1, name="phi") 
  • sasmodels/bumps_model.py

    rc97724e r0ac3db5  
    217217def _plot_sesans(data, theory, view): 
    218218    import matplotlib.pyplot as plt 
    219     resid = (theory - data.data)/data.err_data 
     219    resid = (theory - data.y)/data.dy 
    220220    plt.subplot(121) 
    221     plt.errorbar(data.SElength, data.data, yerr=data.err_data) 
    222     plt.plot(data.SElength, theory, '-', hold=True) 
     221    plt.errorbar(data.x, data.y, yerr=data.dy) 
     222    plt.plot(data.x, theory, '-', hold=True) 
    223223    plt.xlabel('spin echo length (A)') 
    224224    plt.ylabel('polarization') 
    225225    plt.subplot(122) 
    226     plt.plot(data.SElength, resid, 'x') 
     226    plt.plot(data.x, resid, 'x') 
    227227    plt.xlabel('spin echo length (A)') 
    228228    plt.ylabel('residuals') 
     
    267267        self.model = model 
    268268        self.cutoff = cutoff 
    269         if hasattr(data, 'SElength'): 
     269# TODO       if  isinstance(data,SESANSData1D)         
     270        if hasattr(data, 'lam'): 
    270271            self.data_type = 'sesans' 
    271272        elif hasattr(data, 'qx_data'): 
     
    278279        # interpret data 
    279280        if self.data_type == 'sesans': 
    280             q = sesans.make_q(data.q_zmax, data.Rmax) 
     281            q = sesans.make_q(data.sample.zacceptance, data.Rmax) 
    281282            self.index = slice(None,None) 
    282             self.iq = data.data 
    283             self.diq = data.err_data 
     283            self.iq = data.y 
     284            self.diq = data.dy 
    284285            self._theory = np.zeros_like(q) 
    285286            q_vectors = [q] 
     
    353354            #self._theory[:] = self._fn.eval(pars, pd_pars) 
    354355            if self.data_type == 'sesans': 
    355                 P = sesans.hankel(self.data.SElength, self.data.wavelength, 
    356                                   self.data.thickness, self._fn_inputs[0], 
     356                P = sesans.hankel(self.data.x, self.data.lam, 
     357                                  self.data.sample.thickness/10, self._fn_inputs[0], 
    357358                                  self._theory) 
    358359                self._cache['theory'] = P 
     
    401402            self.data.data[self.index] = y 
    402403        elif self.data_type == 'sesans': 
    403             self.data.data[self.index] = y 
     404            self.data.y[self.index] = y 
    404405        else: 
    405406            raise ValueError("Unknown model") 
Note: See TracChangeset for help on using the changeset viewer.