Changeset fcd7bbd in sasmodels
- Timestamp:
- Mar 16, 2016 9:27:13 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:
- 70bbb74
- Parents:
- 63776d3
- Location:
- sasmodels
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/bumps_model.py
r190fc2b rfcd7bbd 83 83 pars = {} 84 84 for p in model_info['parameters']: 85 name, default, limits = p[0], p[2], p[3] 86 value = kwargs.pop(name, default) 87 pars[name] = Parameter.default(value, name=name, limits=limits) 85 value = kwargs.pop([p.name, p.default]) 86 pars[p.name] = Parameter.default(value, name=p.name, limits=p.limits) 88 87 for name in model_info['partype']['pd-2d']: 89 88 for xpart, xdefault, xlimits in [ 90 ('_pd', 0., limits),89 ('_pd', 0., pars[name].limits), 91 90 ('_pd_n', 35., (0, 1000)), 92 91 ('_pd_nsigma', 3., (0, 10)), -
sasmodels/compare.py
r91c5fdc rfcd7bbd 681 681 """ 682 682 # Get the default values for the parameters 683 pars = dict((p [0], p[2]) for p in model_info['parameters'])683 pars = dict((p.name, p.default) for p in model_info['parameters']) 684 684 685 685 # Fill in default values for the polydispersity parameters 686 686 for p in model_info['parameters']: 687 if p [4]in ('volume', 'orientation'):688 pars[p [0]+'_pd'] = 0.0689 pars[p [0]+'_pd_n'] = 0690 pars[p [0]+'_pd_nsigma'] = 3.0691 pars[p [0]+'_pd_type'] = "gaussian"687 if p.type in ('volume', 'orientation'): 688 pars[p.name+'_pd'] = 0.0 689 pars[p.name+'_pd_n'] = 0 690 pars[p.name+'_pd_nsigma'] = 3.0 691 pars[p.name+'_pd_type'] = "gaussian" 692 692 693 693 # Plug in values given in demo … … 833 833 pars = suppress_pd(pars) 834 834 pars.update(presets) # set value after random to control value 835 #import pprint; pprint.pprint(model_info) 835 836 constrain_pars(model_info, pars) 836 837 constrain_new_to_old(model_info, pars) -
sasmodels/generate.py
r2f0c07d rfcd7bbd 80 80 is selected, or when an initial value is not otherwise specified. 81 81 82 [*lb*, *ub*] are the hard limits on the parameter value, used to limit83 the polydispersity density function. In the fit, the parameter limits82 *limits = [lb, ub]* are the hard limits on the parameter value, used to 83 limit the polydispersity density function. In the fit, the parameter limits 84 84 given to the fit are the limits on the central value of the parameter. 85 85 If there is polydispersity, it will evaluate parameter values outside … … 216 216 import re 217 217 import string 218 from collections import namedtuple 218 219 219 220 import numpy as np 221 222 PARAMETER_FIELDS = ['name', 'units', 'default', 'limits', 'type', 'description'] 223 Parameter = namedtuple('Parameter', PARAMETER_FIELDS) 220 224 221 225 #TODO: determine which functions are useful outside of generate … … 293 297 """ 294 298 column_widths = [ 295 max(len(p [0]) for p in pars),296 max(len(p [-1]) for p in pars),297 max(len(format_units(p [1])) for p in pars),299 max(len(p.name) for p in pars), 300 max(len(p.description) for p in pars), 301 max(len(format_units(p.units)) for p in pars), 298 302 PARTABLE_VALUE_WIDTH, 299 303 ] … … 310 314 for p in pars: 311 315 lines.append(" ".join([ 312 "%-*s" % (column_widths[0], p [0]),313 "%-*s" % (column_widths[1], p [-1]),314 "%-*s" % (column_widths[2], format_units(p [1])),315 "%*g" % (column_widths[3], p [2]),316 "%-*s" % (column_widths[0], p.name), 317 "%-*s" % (column_widths[1], p.description), 318 "%-*s" % (column_widths[2], format_units(p.units)), 319 "%*g" % (column_widths[3], p.default), 316 320 ])) 317 321 lines.append(sep) … … 469 473 fixed_2d = partype['fixed-1d'] 470 474 471 iq_parameters = [p [0]475 iq_parameters = [p.name 472 476 for p in model_info['parameters'][2:] # skip scale, background 473 if p [0]in set(fixed_1d + pd_1d)]474 iqxy_parameters = [p [0]477 if p.name in set(fixed_1d + pd_1d)] 478 iqxy_parameters = [p.name 475 479 for p in model_info['parameters'][2:] # skip scale, background 476 if p [0]in set(fixed_2d + pd_2d)]477 volume_parameters = [p [0]480 if p.name in set(fixed_2d + pd_2d)] 481 volume_parameters = [p.name 478 482 for p in model_info['parameters'] 479 if p [4]== 'volume']483 if p.type == 'volume'] 480 484 481 485 # Fill in defintions for volume parameters … … 606 610 607 611 for p in pars: 608 name, ptype = p[0], p[4] 609 if ptype == 'volume': 610 partype['pd-1d'].append(name) 611 partype['pd-2d'].append(name) 612 partype['pd-rel'].add(name) 613 elif ptype == 'magnetic': 614 partype['fixed-2d'].append(name) 615 elif ptype == 'orientation': 616 partype['pd-2d'].append(name) 617 elif ptype == '': 618 partype['fixed-1d'].append(name) 619 partype['fixed-2d'].append(name) 612 if p.type == 'volume': 613 partype['pd-1d'].append(p.name) 614 partype['pd-2d'].append(p.name) 615 partype['pd-rel'].add(p.name) 616 elif p.type == 'magnetic': 617 partype['fixed-2d'].append(p.name) 618 elif p.type == 'orientation': 619 partype['pd-2d'].append(p.name) 620 elif p.type == '': 621 partype['fixed-1d'].append(p.name) 622 partype['fixed-2d'].append(p.name) 620 623 else: 621 raise ValueError("unknown parameter type %r" % p type)622 partype[p type].append(name)624 raise ValueError("unknown parameter type %r" % p.type) 625 partype[p.type].append(p.name) 623 626 624 627 return partype … … 628 631 Process parameter block, precalculating parameter details. 629 632 """ 633 # convert parameters into named tuples 634 pars = [Parameter(*p) for p in model_info['parameters']] 630 635 # Fill in the derived attributes 631 partype = categorize_parameters(model_info['parameters']) 632 model_info['limits'] = dict((p[0], p[3]) for p in model_info['parameters']) 636 model_info['parameters'] = pars 637 partype = categorize_parameters(pars) 638 model_info['limits'] = dict((p.name, p.limits) for p in pars) 633 639 model_info['partype'] = partype 634 model_info['defaults'] = dict((p [0], p[2]) for p in model_info['parameters'])640 model_info['defaults'] = dict((p.name, p.default) for p in pars) 635 641 if model_info.get('demo', None) is None: 636 642 model_info['demo'] = model_info['defaults'] … … 649 655 * *id* is the id of the kernel 650 656 * *name* is the display name of the kernel 657 * *filename* is the full path to the module defining the file (if any) 651 658 * *title* is a short description of the kernel 652 659 * *description* is a long description of the kernel (this doesn't seem -
sasmodels/kernelpy.py
r17bbadd rfcd7bbd 111 111 112 112 # First two fixed pars are scale and background 113 pars = [p [0]for p in model_info['parameters'][2:]]113 pars = [p.name for p in model_info['parameters'][2:]] 114 114 offset = len(self.q_input.q_vectors) 115 115 self.args = self.q_input.q_vectors + [None] * len(pars) -
sasmodels/list_pars.py
r17bbadd rfcd7bbd 26 26 model_info = load_model_info(name) 27 27 for p in model_info['parameters']: 28 pname = p[0] 29 partable.setdefault(pname, []) 30 partable[pname].append(name) 28 partable.setdefault(p.name, []) 29 partable[p.name].append(name) 31 30 return partable 32 31 -
sasmodels/model_test.py
r17bbadd rfcd7bbd 251 251 python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 252 252 253 If -v is included on the 253 If -v is included on the command line, then use verboe output. 254 254 255 If neither opencl nor dll is specified, then models will be tested with 255 256 both opencl and dll; the compute target is ignored for pure python models. -
sasmodels/product.py
r35b4c47 rfcd7bbd 28 28 s_id, s_name, s_pars = s_info['id'], s_info['name'], s_info['parameters'] 29 29 # We require models to start with scale and background 30 assert s_pars[SCALE] [0]== 'scale'31 assert s_pars[BACKGROUND] [0]== 'background'30 assert s_pars[SCALE].name == 'scale' 31 assert s_pars[BACKGROUND].name == 'background' 32 32 # We require structure factors to start with effect radius and volfraction 33 assert s_pars[EFFECT_RADIUS] [0]== 'effect_radius'34 assert s_pars[VOLFRACTION] [0]== 'volfraction'33 assert s_pars[EFFECT_RADIUS].name == 'effect_radius' 34 assert s_pars[VOLFRACTION].name == 'volfraction' 35 35 # Combine the parameter sets. We are skipping the first three 36 36 # parameters of S since scale, background are defined in P and … … 38 38 pars = p_pars + s_pars[3:] 39 39 # check for duplicates; can't use assertion since they may never be checked 40 if len(set(p [0]for p in pars)) != len(pars):40 if len(set(p.name for p in pars)) != len(pars): 41 41 raise ValueError("Duplicate parameters in %s and %s"%(p_id)) 42 42 # For comparison with sasview, determine the old parameters. … … 52 52 model_info['title'] = 'Product of %s and structure factor %s'%(p_name, s_name) 53 53 model_info['description'] = model_info['title'] 54 model_info['docs'] = model_info['title'] 54 55 model_info['category'] = "custom" 55 56 model_info['parameters'] = pars 56 # Remember the component info blocks so we can build the product model 57 model_info['composition'] = ('product', [p_info, s_info]) 57 #model_info['single'] = p_info['single'] and s_info['single'] 58 model_info['structure_factor'] = False 59 model_info['variant_info'] = None 60 #model_info['tests'] = [] 61 #model_info['source'] = [] 62 # Iq, Iqxy, form_volume, ER, VR and sesans 58 63 model_info['oldname'] = oldname 59 64 model_info['oldpars'] = oldpars 65 model_info['composition'] = ('product', [p_info, s_info]) 60 66 process_parameters(model_info) 61 67 return model_info -
sasmodels/sasview_model.py
r28da77d rfcd7bbd 60 60 self.dispersion = dict() 61 61 partype = model.info['partype'] 62 for name, units, default, limits, _, _in model.info['parameters']:63 self.params[ name] =default64 self.details[ name] = [units] +limits62 for p in model.info['parameters']: 63 self.params[p.name] = p.default 64 self.details[p.name] = [p.units] + p.limits 65 65 66 66 for name in partype['pd-2d']:
Note: See TracChangeset
for help on using the changeset viewer.