Changeset 17bbadd in sasmodels for sasmodels/direct_model.py
- Timestamp:
- Mar 15, 2016 12:47:12 PM (9 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/direct_model.py
rd18582e r17bbadd 25 25 import numpy as np 26 26 27 from .core import load_model_definition, load_model,make_kernel28 from .core import call_kernel, call_ER , call_VR27 from .core import make_kernel 28 from .core import call_kernel, call_ER_VR 29 29 from . import sesans 30 30 from . import resolution … … 180 180 return self._calc_theory(pars, cutoff=self.cutoff) 181 181 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) 198 187 199 188 def simulate_data(self, noise=None, **pars): … … 210 199 import sys 211 200 from .data import empty_data1D, empty_data2D 201 from .core import load_model_info, build_model 212 202 213 203 if len(sys.argv) < 3: … … 216 206 model_name = sys.argv[1] 217 207 call = sys.argv[2].upper() 218 if call not in ("ER", "VR"):208 if call != "ER_VR": 219 209 try: 220 210 values = [float(v) for v in call.split(',')] … … 233 223 data = empty_data1D([0.001]) # Data not used in ER/VR 234 224 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) 237 227 calculator = DirectModel(data, model) 238 228 pars = dict((k, float(v)) 239 229 for pair in sys.argv[3:] 240 230 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)) 245 233 else: 246 234 Iq = calculator(**pars)
Note: See TracChangeset
for help on using the changeset viewer.