Changeset aa4946b in sasmodels
- Timestamp:
- Mar 11, 2015 11:15:40 PM (10 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:
- af1d68c
- Parents:
- 49d1d42f
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
compare.py
r750ffa5 raa4946b 10 10 11 11 from sasmodels.bumps_model import BumpsModel, plot_data, tic 12 try: from sasmodels import kernelcl 13 except: from sasmodels import kerneldll as kernelcl 12 from sasmodels import core 14 13 from sasmodels import kerneldll 15 14 from sasmodels.convert import revert_model … … 22 21 23 22 24 def sasview_model(model name, **pars):23 def sasview_model(model_definition, **pars): 25 24 """ 26 25 Load a sasview model given the model name. … … 28 27 # convert model parameters from sasmodel form to sasview form 29 28 #print "old",sorted(pars.items()) 30 modelname, pars = revert_model(model name, pars)29 modelname, pars = revert_model(model_definition, pars) 31 30 #print "new",sorted(pars.items()) 32 31 sas = __import__('sas.models.'+modelname) … … 48 47 model.setParam(k, v) 49 48 return model 50 51 def load_opencl(modelname, dtype='single'):52 sasmodels = __import__('sasmodels.models.'+modelname)53 module = getattr(sasmodels.models, modelname, None)54 kernel = kernelcl.load_model(module, dtype=dtype)55 return kernel56 57 def load_ctypes(modelname, dtype='single'):58 sasmodels = __import__('sasmodels.models.'+modelname)59 module = getattr(sasmodels.models, modelname, None)60 kernel = kerneldll.load_model(module, dtype=dtype)61 return kernel62 49 63 50 def randomize(p, v): … … 120 107 return value, average_time 121 108 122 def eval_opencl( name, pars, data, dtype='single', Nevals=1, cutoff=0):109 def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, cutoff=0): 123 110 try: 124 model = load_opencl(name, dtype=dtype)111 model = core.load_model(model_definition, dtype=dtype, platform="ocl") 125 112 except Exception,exc: 126 113 print exc 127 114 print "... trying again with single precision" 128 model = load_opencl(name, dtype='single')115 model = core.load_model(model_definition, dtype='single', platform="ocl") 129 116 problem = BumpsModel(data, model, cutoff=cutoff, **pars) 130 117 toc = tic() … … 136 123 return value, average_time 137 124 138 def eval_ctypes( name, pars, data, dtype='double', Nevals=1, cutoff=0):139 model = load_ctypes(name, dtype=dtype)125 def eval_ctypes(model_definition, pars, data, dtype='double', Nevals=1, cutoff=0): 126 model = core.load_model(model_definition, dtype=dtype, platform="dll") 140 127 problem = BumpsModel(data, model, cutoff=cutoff, **pars) 141 128 toc = tic() … … 193 180 print "pars",parlist(pars) 194 181 182 model_definition = core.load_model_definition(name) 195 183 # OpenCl calculation 196 184 if Nocl > 0: 197 ocl, ocl_time = eval_opencl(name, pars, data, dtype, Nocl) 185 ocl, ocl_time = eval_opencl(model_definition, pars, data, 186 dtype=dtype, cutoff=cutoff, Nevals=Nocl) 198 187 print "opencl t=%.1f ms, intensity=%.0f"%(ocl_time, sum(ocl[index])) 199 188 #print max(ocl), min(ocl) … … 201 190 # ctypes/sasview calculation 202 191 if Ncpu > 0 and "-ctypes" in opts: 203 cpu, cpu_time = eval_ctypes(name, pars, data, dtype=dtype, cutoff=cutoff, Nevals=Ncpu) 192 cpu, cpu_time = eval_ctypes(model_definition, pars, data, 193 dtype=dtype, cutoff=cutoff, Nevals=Ncpu) 204 194 comp = "ctypes" 205 195 print "ctypes t=%.1f ms, intensity=%.0f"%(cpu_time, sum(cpu[index])) 206 196 elif Ncpu > 0: 207 cpu, cpu_time = eval_sasview( name, pars, data, Ncpu)197 cpu, cpu_time = eval_sasview(model_definition, pars, data, Ncpu) 208 198 comp = "sasview" 209 199 print "sasview t=%.1f ms, intensity=%.0f"%(cpu_time, sum(cpu[index])) … … 219 209 #bad = (relerr>1e-4) 220 210 #print relerr[bad],cpu[bad],ocl[bad],data.qx_data[bad],data.qy_data[bad] 221 print "max(|ocl-%s|)"%comp, max(abs(resid[index])) 222 print "max(|(ocl-%s)/%s|)"%(comp,comp), max(abs(relerr[index])) 223 p98 = int(len(relerr[index])*0.98) 224 print "98%% (|(ocl-%s)/%s|) <"%(comp,comp), np.sort(abs(relerr[index]))[p98] 225 211 def stats(label,err): 212 sorted_err = np.sort(abs(err)) 213 p50 = int((len(err)-1)*0.50) 214 p98 = int((len(err)-1)*0.98) 215 data = [ 216 "max:%.3e"%sorted_err[-1], 217 "median:%.3e"%sorted_err[p50], 218 "98%%:%.3e"%sorted_err[p98], 219 "rms:%.3e"%np.sqrt(np.mean(err**2)), 220 "zero-offset:%+.3e"%np.mean(err), 221 ] 222 print label," ".join(data) 223 stats("|ocl-%s|"%comp+(" "*(3+len(comp))), resid[index]) 224 stats("|(ocl-%s)/%s|"%(comp,comp), relerr[index]) 226 225 227 226 # Plot if requested -
sasmodels/bumps_model.py
r63b32bb raa4946b 1 1 """ 2 Sasmodels core.2 Wrap sasmodels for direct use by bumps. 3 3 """ 4 4 5 import datetime 5 6 6 from sasmodels import sesans 7 import numpy as np 8 9 from . import sesans 7 10 8 11 # CRUFT python 2.6 … … 15 18 """Return number date-time delta as number seconds""" 16 19 return dt.total_seconds() 17 18 import numpy as np19 20 try:21 from .kernelcl import load_model as _loader22 except RuntimeError, exc:23 import warnings24 warnings.warn(str(exc))25 warnings.warn("OpenCL not available --- using ctypes instead")26 from .kerneldll import load_model as _loader27 28 def load_model(modelname, dtype='single'):29 """30 Load model by name.31 """32 sasmodels = __import__('sasmodels.models.' + modelname)33 module = getattr(sasmodels.models, modelname, None)34 model = _loader(module, dtype=dtype)35 return model36 20 37 21 … … 263 247 *data* is the data to be fitted. 264 248 265 *model* is the SAS model , e.g., from :func:`gen.opencl_model`.249 *model* is the SAS model from :func:`core.load_model`. 266 250 267 251 *cutoff* is the integration cutoff, which avoids computing the … … 280 264 self.model = model 281 265 self.cutoff = cutoff 282 # TODO if isinstance(data,SESANSData1D)283 266 if hasattr(data, 'lam'): 284 267 self.data_type = 'sesans' … … 431 414 def _get_weights(self, par): 432 415 """ 433 416 Get parameter dispersion weights 434 417 """ 435 418 from . import weights -
sasmodels/convert.py
r3c56da87 raa4946b 51 51 for p,v in pars.items()) 52 52 53 def revert_model( name, pars):53 def revert_model(model_definition, pars): 54 54 """ 55 55 Convert model from new style parameter names to old style. 56 56 """ 57 __import__('sasmodels.models.'+name) 58 from . import models 59 model = getattr(models, name, None) 60 mapping = model.oldpars 61 oldname = model.oldname 57 mapping = model_definition.oldpars 58 oldname = model_definition.oldname 62 59 oldpars = _rename_pars(_unscale_sld(pars), mapping) 63 60 return oldname, oldpars -
sasmodels/core.py
r3c56da87 raa4946b 1 __all__ = ["list_models", "load_model_cl", "load_model_dll", 2 "load_model_definition", ] 1 """ 2 Core model handling routines. 3 """ 4 __all__ = ["list_models", "load_model_definition", "precompile_dll", 5 "load_model", "make_kernel", "call_kernel", "call_ER", "call_VR" ] 3 6 4 7 from os.path import basename, dirname, join as joinpath … … 9 12 from . import models 10 13 from . import weights 14 from . import generate 11 15 16 from . import kernelpy 17 from . import kerneldll 12 18 try: 13 from .kernelcl import load_model as load_model_cl 19 from . import kernelcl 20 HAVE_OPENCL = True 14 21 except: 15 # pylint: disable=invalid-name 16 load_model_cl = None 17 from .kerneldll import load_model as load_model_dll 22 HAVE_OPENCL = False 23 18 24 19 25 def list_models(): 26 """ 27 Return the list of available models on the model path. 28 """ 20 29 root = dirname(__file__) 21 30 files = sorted(glob(joinpath(root, 'models', "[a-zA-Z]*.py"))) … … 23 32 return available_models 24 33 34 25 35 def load_model_definition(model_name): 36 """ 37 Load a model definition given the model name. 38 """ 26 39 __import__('sasmodels.models.'+model_name) 27 40 model_definition = getattr(models, model_name, None) 28 41 return model_definition 42 43 44 def precompile_dll(model_name, dtype="double"): 45 """ 46 Precompile the dll for a model. 47 48 Returns the path to the compiled model. 49 50 This can be used when build the windows distribution of sasmodels 51 (which may be missing the OpenCL driver and the dll compiler), or 52 otherwise sharing models with windows users who do not have a compiler. 53 54 See :func:`sasmodels.kerneldll.make_dll` for details on controlling the 55 dll path and the allowed floating point precision. 56 """ 57 model_definition = load_model_definition(model_name) 58 source, info = generate.make(model_definition) 59 return kerneldll.make_dll(source, info, dtype=dtype) 60 61 62 def load_model(model_definition, dtype="single", platform="ocl"): 63 """ 64 Prepare the model for the default execution platform. 65 66 This will return an OpenCL model, a DLL model or a python model depending 67 on the model and the computing platform. 68 69 *dtype* indicates whether the model should use single or double precision 70 for the calculation. Any valid numpy single or double precision identifier 71 is valid, such as 'single', 'f', 'f32', or np.float32 for single, or 72 'double', 'd', 'f64' and np.float64 for double. 73 74 *platform* should be "dll" to force the dll to be used for C models, 75 otherwise it uses the default "ocl". 76 """ 77 source, info = generate.make(model_definition) 78 if callable(info.get('Iq', None)): 79 return kernelpy.PyModel(info) 80 81 ## for debugging: 82 ## 1. uncomment open().write so that the source will be saved next time 83 ## 2. run "python -m sasmodels.direct_model $MODELNAME" to save the source 84 ## 3. recomment the open.write() and uncomment open().read() 85 ## 4. rerun "python -m sasmodels.direct_model $MODELNAME" 86 ## 5. uncomment open().read() so that source will be regenerated from model 87 # open(info['name']+'.c','w').write(source) 88 # source = open(info['name']+'.cl','r').read() 89 90 dtype = np.dtype(dtype) 91 if (platform=="dll" 92 or not HAVE_OPENCL 93 or (dtype == np.float64 and not kernelcl.environment().has_double)): 94 return kerneldll.load_dll(source, info, dtype) 95 else: 96 return kernelcl.GpuModel(source, info, dtype) 29 97 30 98 def make_kernel(model, q_vectors): … … 40 108 in *pars*. 41 109 42 Searches for "name", "name_pd", "name_pd_type", "name_pd_n", "name_pd_sigma" 110 Uses "name", "name_pd", "name_pd_type", "name_pd_n", "name_pd_sigma" 111 from the *pars* dictionary for parameter value and parameter dispersion. 43 112 """ 44 113 relative = name in info['partype']['pd-rel'] … … 69 138 return value, weight 70 139 71 def call_kernel(kernel, pars, cutoff=1e-5): 140 def call_kernel(kernel, pars, cutoff=0): 141 """ 142 Call *kernel* returned from :func:`make_kernel` with parameters *pars*. 143 144 *cutoff* is the limiting value for the product of dispersion weights used 145 to perform the multidimensional dispersion calculation more quickly at a 146 slight cost to accuracy. The default value of *cutoff=0* integrates over 147 the entire dispersion cube. Using *cutoff=1e-5* can be 50% faster, but 148 with an error of about 1%, which is usually less than the measurement 149 uncertainty. 150 """ 72 151 fixed_pars = [pars.get(name, kernel.info['defaults'][name]) 73 152 for name in kernel.fixed_pars] … … 76 155 77 156 def call_ER(info, pars): 157 """ 158 Call the model ER function using *pars*. 159 160 *info* is either *model.info* if you have a loaded model, or *kernel.info* 161 if you have a model kernel prepared for evaluation. 162 """ 78 163 ER = info.get('ER', None) 79 164 if ER is None: … … 88 173 89 174 def call_VR(info, pars): 175 """ 176 Call the model VR function using *pars*. 177 178 *info* is either *model.info* if you have a loaded model, or *kernel.info* 179 if you have a model kernel prepared for evaluation. 180 """ 90 181 VR = info.get('VR', None) 91 182 if VR is None: -
sasmodels/direct_model.py
rf734e7d raa4946b 3 3 import numpy as np 4 4 5 from .core import load_model_definition, make_kernel, call_kernel 6 from .core import load_model_cl as load_model 7 if load_model is None: 8 warnings.warn("unable to load opencl; using ctypes instead") 9 from .core import load_model_dll as load_model 5 from .core import load_model_definition, load_model, make_kernel 6 from .core import call_kernel, call_ER, call_VR 10 7 11 8 class DirectModel: 12 def __init__(self, name, q_vectors , dtype='single'):9 def __init__(self, name, q_vectors=None, dtype='single'): 13 10 self.model_definition = load_model_definition(name) 14 11 self.model = load_model(self.model_definition, dtype=dtype) 15 q_vectors = [np.ascontiguousarray(q,dtype=dtype) for q in q_vectors] 16 self.kernel = make_kernel(self.model, q_vectors) 12 if q_vectors is not None: 13 q_vectors = [np.ascontiguousarray(q,dtype=dtype) for q in q_vectors] 14 self.kernel = make_kernel(self.model, q_vectors) 17 15 def __call__(self, **pars): 18 16 return call_kernel(self.kernel, pars) 17 def ER(self, **pars): 18 return call_ER(self.model.info, pars) 19 def VR(self, **pars): 20 return call_VR(self.model.info, pars) 19 21 20 22 def demo(): … … 24 26 sys.exit(1) 25 27 model_name = sys.argv[1] 26 values = [float(v) for v in sys.argv[2].split(',')] 27 if len(values) == 1: 28 q = values[0] 29 q_vectors = [[q]] 30 elif len(values) == 2: 31 qx,qy = values 32 q_vectors = [[qx],[qy]] 28 call = sys.argv[2].upper() 29 if call in ("ER","VR"): 30 q_vectors = None 33 31 else: 34 print "use q or qx,qy" 35 sys.exit(1) 32 values = [float(v) for v in sys.argv[2].split(',')] 33 if len(values) == 1: 34 q = values[0] 35 q_vectors = [[q]] 36 elif len(values) == 2: 37 qx,qy = values 38 q_vectors = [[qx],[qy]] 39 else: 40 print "use q or qx,qy or ER or VR" 41 sys.exit(1) 36 42 model = DirectModel(model_name, q_vectors) 37 43 pars = dict((k,float(v)) 38 44 for pair in sys.argv[3:] 39 45 for k,v in [pair.split('=')]) 40 Iq = model(**pars) 41 print Iq[0] 46 if call == "ER": 47 print model.ER(**pars) 48 elif call == "VR": 49 print model.VR(**pars) 50 else: 51 Iq = model(**pars) 52 print Iq[0] 42 53 43 54 if __name__ == "__main__": -
sasmodels/kernelcl.py
r63b32bb raa4946b 55 55 MAX_LOOPS = 2048 56 56 57 def load_model(kernel_module, dtype="single"):57 def _load_model(kernel_module, dtype="single"): 58 58 """ 59 59 Load the OpenCL model defined by *kernel_module*. … … 62 62 so models can be defined without using too many resources. 63 63 """ 64 raise DeprecationWarning 64 65 source, info = generate.make(kernel_module) 65 66 if callable(info.get('Iq', None)): -
sasmodels/kerneldll.py
r63b32bb raa4946b 54 54 55 55 56 def load_model(kernel_module, dtype="double"):56 def make_dll(source, info, dtype="double"): 57 57 """ 58 58 Load the compiled model defined by *kernel_module*. … … 60 60 Recompile if any files are newer than the model file. 61 61 62 *dtype* is ignored. Compiled files are always double. 63 64 The DLL is not loaded until the kernel is called so models an 62 *dtype* is a numpy floating point precision specifier indicating whether 63 the model should be single or double precision. The default is double 64 precision. 65 66 The DLL is not loaded until the kernel is called so models can 65 67 be defined without using too many resources. 68 69 Set *sasmodels.kerneldll.DLL_PATH* to the compiled dll output path. 70 The default is the system temporary directory. 71 72 Set *sasmodels.ALLOW_SINGLE_PRECISION_DLLS* to True if single precision 73 models are allowed as DLLs. 66 74 """ 67 75 if not ALLOW_SINGLE_PRECISION_DLLS: dtype = "double" # Force 64-bit dll 68 76 dtype = np.dtype(dtype) 69 77 70 source, info = generate.make(kernel_module)71 78 if callable(info.get('Iq',None)): 72 79 return PyModel(info) … … 79 86 80 87 source_files = generate.sources(info) + [info['filename']] 81 dll path= dll_path(info, dtype)88 dll= dll_path(info, dtype) 82 89 newest = max(os.path.getmtime(f) for f in source_files) 83 if not os.path.exists(dll path) or os.path.getmtime(dllpath)<newest:90 if not os.path.exists(dll) or os.path.getmtime(dll)<newest: 84 91 # Replace with a proper temp file 85 92 fid, filename = tempfile.mkstemp(suffix=".c",prefix=tempfile_prefix) 86 93 os.fdopen(fid,"w").write(source) 87 command = COMPILE%{"source":filename, "output":dll path}94 command = COMPILE%{"source":filename, "output":dll} 88 95 print "Compile command:",command 89 96 status = os.system(command) 90 if status != 0 :97 if status != 0 or not os.path.exists(dll): 91 98 raise RuntimeError("compile failed. File is in %r"%filename) 92 99 else: 93 100 ## uncomment the following to keep the generated c file 94 #os.unlink(filename); print "saving compiled file in %r"%filename 95 pass 96 return DllModel(dllpath, info, dtype=dtype) 101 os.unlink(filename); print "saving compiled file in %r"%filename 102 return dll 103 104 105 def load_dll(source, info, dtype="double"): 106 """ 107 Create and load a dll corresponding to the source,info pair returned 108 from :func:`sasmodels.generate.make` compiled for the target precision. 109 110 See :func:`make_dll` for details on controlling the dll path and the 111 allowed floating point precision. 112 """ 113 filename = make_dll(source, info, dtype=dtype) 114 return DllModel(filename, info, dtype=dtype) 97 115 98 116 -
sasmodels/model_test.py
ra217f7d raa4946b 50 50 import numpy as np 51 51 52 from .core import list_models, load_model_definition 53 from .core import load_model_cl, load_model_dll 52 from .core import list_models, load_model_definition, load_model, HAVE_OPENCL 54 53 from .core import make_kernel, call_kernel, call_ER, call_VR 54 55 55 56 56 def annotate_exception(exc, msg): … … 80 80 exc.args = (" ".join((str(exc),msg)),) 81 81 82 82 83 def make_suite(loaders, models): 83 84 … … 113 114 114 115 # test using opencl if desired 115 if not ispy and ('opencl' in loaders and load_model_cl):116 if not ispy and ('opencl' in loaders and HAVE_OPENCL): 116 117 test_name = "Model: %s, Kernel: OpenCL"%model_name 117 118 test_method = "test_%s_opencl" % model_name 118 119 test = ModelTestCase(test_name, model_definition, 119 load_model_cl, tests, test_method) 120 tests, test_method, 121 platform="ocl", dtype='single') 120 122 #print "defining", test_name 121 123 suite.addTest(test) 122 124 123 125 # test using dll if desired 124 if ispy or ('dll' in loaders and load_model_dll):126 if ispy or 'dll' in loaders: 125 127 test_name = "Model: %s, Kernel: dll"%model_name 126 128 test_method = "test_%s_dll" % model_name 127 129 test = ModelTestCase(test_name, model_definition, 128 load_model_dll, tests, test_method) 130 tests, test_method, 131 platform="dll", dtype="double") 129 132 suite.addTest(test) 130 133 131 134 return suite 135 132 136 133 137 def _hide_model_case_from_nosetests(): 134 138 class ModelTestCase(unittest.TestCase): 135 def __init__(self, test_name, definition, loader, tests, test_method): 139 def __init__(self, test_name, definition, tests, test_method, 140 platform, dtype): 136 141 self.test_name = test_name 137 142 self.definition = definition 138 self.loader = loader139 143 self.tests = tests 144 self.platform = platform 145 self.dtype = dtype 140 146 141 147 setattr(self, test_method, self._runTest) … … 144 150 def _runTest(self): 145 151 try: 146 model = self.loader(self.definition) 152 model = load_model(self.definition, dtype=self.dtype, 153 platform=self.platform) 147 154 for test in self.tests: 148 155 self._run_one_test(model, test) … … 195 202 196 203 def main(): 204 """ 205 Run tests given is sys.argv. 206 207 Returns 0 if success or 1 if any tests fail. 208 """ 197 209 models = sys.argv[1:] 198 210 if models and models[0] == 'opencl': 199 if load_model_cl is None:211 if not HAVE_OPENCL: 200 212 print >>sys.stderr, "opencl is not available" 201 213 return 1 … … 207 219 models = models[1:] 208 220 elif models and models[0] == 'opencl_and_dll': 209 if load_model_cl is None:210 print >>sys.stderr, "opencl is not available"211 return 1212 221 loaders = ['opencl', 'dll'] 213 222 models = models[1:] … … 225 234 226 235 227 # let nosetests sniff out the tests228 236 def model_tests(): 237 """ 238 Test runner visible to nosetests. 239 240 Run "nosetests sasmodels" on the command line to invoke it. 241 """ 229 242 tests = make_suite(['opencl','dll'],['all']) 230 243 for test_i in tests: 231 244 yield test_i._runTest 232 245 246 233 247 if __name__ == "__main__": 234 248 sys.exit(main()) -
sasmodels/sasview_model.py
r63b32bb raa4946b 14 14 """ 15 15 16 # TODO: add a sasview=>sasmodels parameter translation layer17 # this will allow us to use the new sasmodels as drop in replacements, and18 # delay renaming parameters until all models have been converted.19 20 16 import math 21 17 from copy import deepcopy … … 24 20 import numpy as np 25 21 26 try: 27 from .kernelcl import load_model 28 except ImportError, exc: 29 warnings.warn(str(exc)) 30 warnings.warn("using ctypes instead") 31 from .kerneldll import load_model 32 33 34 def make_class(kernel_module, dtype='single', namestyle='name'): 22 from . import core 23 24 def make_class(model_definition, dtype='single', namestyle='name'): 35 25 """ 36 26 Load the sasview model defined in *kernel_module*. … … 38 28 Returns a class that can be used directly as a sasview model. 39 29 40 Defaults to using the new name for a model. Setting namestyle='name' 41 will produce a class with a name compatible with SasView 30 Defaults to using the new name for a model. Setting 31 *namestyle='oldname'* will produce a class with a name 32 compatible with SasView. 42 33 """ 43 model = load_model(kernel_module, dtype=dtype)34 model = core.load_model(model_definition, dtype=dtype) 44 35 def __init__(self, multfactor=1): 45 36 SasviewModel.__init__(self, model) … … 313 304 return 1.0 314 305 else: 315 vol_pars = self._model.info['partype']['volume'] 316 values, weights = self._dispersion_mesh(vol_pars) 306 values, weights = self._dispersion_mesh() 317 307 fv = ER(*values) 318 308 #print values[0].shape, weights.shape, fv.shape … … 329 319 return 1.0 330 320 else: 331 vol_pars = self._model.info['partype']['volume'] 332 values, weights = self._dispersion_mesh(vol_pars) 321 values, weights = self._dispersion_mesh() 333 322 whole, part = VR(*values) 334 323 return np.sum(weights * part) / np.sum(weights * whole) … … 362 351 raise ValueError("%r is not a dispersity or orientation parameter") 363 352 364 def _dispersion_mesh(self , pars):353 def _dispersion_mesh(self): 365 354 """ 366 355 Create a mesh grid of dispersion parameters and weights. … … 370 359 parameter set in the vector. 371 360 """ 372 values, weights = zip(*[self._get_weights(p) for p in pars]) 373 values = [v.flatten() for v in np.meshgrid(*values)] 374 weights = np.vstack([v.flatten() for v in np.meshgrid(*weights)]) 375 weights = np.prod(weights, axis=0) 376 return values, weights 361 pars = self._model.info['partype']['volume'] 362 return core.dispersion_mesh([self._get_weights(p) for p in pars]) 377 363 378 364 def _get_weights(self, par):
Note: See TracChangeset
for help on using the changeset viewer.