Changeset 36948c92 in sasview for sansmodels/src/sans/models/PowerLawModel.py
- Timestamp:
- Apr 15, 2008 8:08:40 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:
- 3de85b8
- Parents:
- 5aa3bbd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/PowerLawModel.py
r3db3895 r36948c92 38 38 ## Parameter details [units, min, max] 39 39 self.details = {} 40 self.details['m'] = ['', None, None]40 self.details['m'] = ['', 0, None] 41 41 self.details['scale'] = ['', None, None] 42 42 self.details['background'] = ['', None, None] … … 47 47 48 48 """ 49 return self.params['scale']*math.pow(x ,-self.params['m'])\ 49 if x<0 and self.params['m']>0: 50 raise ValueError, "negative number cannot be raised to a fractional power" 51 52 return self.params['scale']*math.pow(x ,-1.0*self.params['m'])\ 50 53 + self.params['background'] 51 54 52 53 55 def run(self, x = 0.0): 54 56 """ Evaluate the model … … 57 59 """ 58 60 if x.__class__.__name__ == 'list': 59 return self._PowerLaw(x[0]*math.cos(x[1]))*self._PowerLaw(x[0]*math.sin(x[1])) 61 # Take absolute value of Q, since this model is really meant to 62 # be defined in 1D for a given length of Q 63 qx = math.fabs(x[0]*math.cos(x[1])) 64 qy = math.fabs(x[0]*math.sin(x[1])) 65 return self._PowerLaw(qx)*self._PowerLaw(qy) 60 66 elif x.__class__.__name__ == 'tuple': 61 67 raise ValueError, "Tuples are not allowed as input to BaseComponent models"
Note: See TracChangeset
for help on using the changeset viewer.