Changeset 17bbadd in sasmodels for sasmodels/direct_model.py


Ignore:
Timestamp:
Mar 15, 2016 12:47:12 PM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
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:
754e27b
Parents:
5ceb7d0
Message:

refactor so all model defintion queries use model_info; better documentation of model_info structure; initial implementation of product model (broken)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/direct_model.py

    rd18582e r17bbadd  
    2525import numpy as np 
    2626 
    27 from .core import load_model_definition, load_model, make_kernel 
    28 from .core import call_kernel, call_ER, call_VR 
     27from .core import make_kernel 
     28from .core import call_kernel, call_ER_VR 
    2929from . import sesans 
    3030from . import resolution 
     
    180180        return self._calc_theory(pars, cutoff=self.cutoff) 
    181181 
    182     def ER(self, **pars): 
    183         """ 
    184         Compute the equivalent radius for the model. 
    185  
    186         Return 0. if not defined. 
    187         """ 
    188         return call_ER(self.model.info, pars) 
    189  
    190     def VR(self, **pars): 
    191         """ 
    192         Compute the equivalent volume for the model, including polydispersity 
    193         effects. 
    194  
    195         Return 1. if not defined. 
    196         """ 
    197         return call_VR(self.model.info, pars) 
     182    def ER_VR(self, **pars): 
     183        """ 
     184        Compute the equivalent radius and volume ratio for the model. 
     185        """ 
     186        return call_ER_VR(self.model.info, pars) 
    198187 
    199188    def simulate_data(self, noise=None, **pars): 
     
    210199    import sys 
    211200    from .data import empty_data1D, empty_data2D 
     201    from .core import load_model_info, build_model 
    212202 
    213203    if len(sys.argv) < 3: 
     
    216206    model_name = sys.argv[1] 
    217207    call = sys.argv[2].upper() 
    218     if call not in ("ER", "VR"): 
     208    if call != "ER_VR": 
    219209        try: 
    220210            values = [float(v) for v in call.split(',')] 
     
    233223        data = empty_data1D([0.001])  # Data not used in ER/VR 
    234224 
    235     model_definition = load_model_definition(model_name) 
    236     model = load_model(model_definition) 
     225    model_info = load_model_info(model_name) 
     226    model = build_model(model_info) 
    237227    calculator = DirectModel(data, model) 
    238228    pars = dict((k, float(v)) 
    239229                for pair in sys.argv[3:] 
    240230                for k, v in [pair.split('=')]) 
    241     if call == "ER": 
    242         print(calculator.ER(**pars)) 
    243     elif call == "VR": 
    244         print(calculator.VR(**pars)) 
     231    if call == "ER_VR": 
     232        print(calculator.ER_VR(**pars)) 
    245233    else: 
    246234        Iq = calculator(**pars) 
Note: See TracChangeset for help on using the changeset viewer.