Changeset 8cfdd5e in sasview for sansmodels/src/sans/models
- Timestamp:
- Mar 17, 2009 11:47:45 AM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- bb18ef1
- Parents:
- 4d74a8f
- Location:
- sansmodels/src/sans/models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/MultiplicationModel.py
r996fd35 r8cfdd5e 13 13 14 14 15 ## Name of the model 16 self.name="" 17 ## model description 15 ## Setting model name model description 18 16 self.description="" 19 17 if model1.name != "NoStructure"and model2.name != "NoStructure": … … 34 32 self.model2= model2 35 33 ## dispersion 36 self.dispersion = {}37 34 self._set_dispersion() 38 35 ## Define parameters 39 self.params = {}40 36 self._set_params() 41 37 ## Parameter details [units, min, max] 42 self.details = {}43 38 self._set_details() 44 39 #list of parameter that can be fitted 45 self.fixed= []46 40 self._set_fixed_params() 47 41 … … 83 77 self.details[name]= detail 84 78 79 def setParam(self, name, value): 80 """ 81 Set the value of a model parameter 82 83 @param name: name of the parameter 84 @param value: value of the parameter 85 """ 86 self._setParamHelper( name, value) 87 if name in self.model1.getParamList(): 88 self.model1.setParam( name, value) 89 90 if name in self.model2.getParamList(): 91 self.model2.setParam( name, value) 92 93 94 def _setParamHelper(self, name, value): 95 """ 96 Helper function to setparam 97 """ 98 # Look for dispersion parameters 99 toks = name.split('.') 100 if len(toks)==2: 101 for item in self.dispersion.keys(): 102 if item.lower()==toks[0].lower(): 103 for par in self.dispersion[item]: 104 if par.lower() == toks[1].lower(): 105 self.dispersion[item][par] = value 106 return 107 else: 108 # Look for standard parameter 109 for item in self.params.keys(): 110 if item.lower()==name.lower(): 111 self.params[item] = value 112 return 113 114 raise ValueError, "Model does not contain parameter %s" % name 115 116 117 118 119 85 120 def _set_fixed_params(self): 86 121 """ -
sansmodels/src/sans/models/NoStructure.py
r4ef9dff r8cfdd5e 21 21 F(x)= 1 22 22 """ 23 ## Parameter details [units, min, max] 24 self.details = {} 25 #list of parameter that cannot be fitted 26 self.fixed= [] 23 27 24 def clone(self): 28 25 """ Return a identical copy of self """ -
sansmodels/src/sans/models/test/utest_modelmultiplication.py
rc9636f7 r8cfdd5e 27 27 fixed=[] 28 28 fixed=['radius.width'] 29 30 31 def test_multiplication(self): 32 """ test multiplication model""" 33 from sans.models.MultiplicationModel import MultiplicationModel 34 from sans.models.SphereModel import SphereModel 35 from sans.models.NoStructure import NoStructure 36 model1 = MultiplicationModel(SphereModel(),NoStructure()) 37 model2 = SphereModel() 38 x= 2 39 a = model1.run(x) 40 41 b= model2.run(x) 42 self.assertEqual(a, b) 43 model2.setParam("scale", 10) 44 c= model2.run(x) 45 self.assertEqual(c, 10*b) 46 model1.setParam("scale", 10) 47 d= model1.run(x) 48 self.assertEqual(d, 10*a) 49 self.assertEqual(model1.getParam("scale"), 10) 50 51 29 52 def testMultiplicationModel(self): 30 53 """ Test Multiplication sphere with SquareWellStructure"""
Note: See TracChangeset
for help on using the changeset viewer.