Changeset c4f52e3 in sasview
- Timestamp:
- Mar 27, 2010 10:11:58 AM (15 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:
- d1b43cd
- Parents:
- 18e6c5e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Invariant/invariant.py
r90e5ca1 rc4f52e3 134 134 self.dscale = math.exp(constant)*dconstant 135 135 self.dradius = -3.0/2.0/math.sqrt(-3 * slope)*dslope 136 137 return [self.radius, self.scale], [self.dradius, self.dscale] 136 138 137 139 def evaluate_model(self, x): … … 195 197 # Errors 196 198 self.dscale = math.exp(constant)*dconstant 197 self.dradius = -dslope 199 self.dpower = -dslope 200 201 return [self.power, self.scale], [self.dpower, self.dscale] 198 202 199 203 def evaluate_model(self, x): … … 210 214 """ 211 215 p1 = numpy.array([self.dscale * math.pow(q, -self.power) for q in x]) 212 p2 = numpy.array([self.scale * self.power * math.pow(q, -self.power-1) * self.d radiusfor q in x])216 p2 = numpy.array([self.scale * self.power * math.pow(q, -self.power-1) * self.dpower for q in x]) 213 217 diq2 = p1*p1 + p2*p2 214 218 return numpy.array( [math.sqrt(err) for err in diq2] ) … … 393 397 return new_data 394 398 395 def _fit(self, model, qmin=Q_MINIMUM, qmax=Q_MAXIMUM, power=None , range=None):399 def _fit(self, model, qmin=Q_MINIMUM, qmax=Q_MAXIMUM, power=None): 396 400 """ 397 401 fit data with function using … … 410 414 extrapolator = Extrapolator(data=self._data, model=model) 411 415 p, dp = extrapolator.fit(power=power, qmin=qmin, qmax=qmax) 412 if range is not None and range == 'low':413 self._low_extrapolation_power_fitted = -1*p[0]414 if range is not None and range == 'high':415 self._high_extrapolation_power_fitted = -1*p[0]416 416 417 417 return model.extract_model_parameters(constant=p[1], slope=p[0], dconstant=dp[1], dslope=dp[0]) … … 519 519 def get_extrapolation_power(self, range='high'): 520 520 """ 521 return the fitted power for power law function at a givenrange521 return the fitted power for power law function for a given extrapolation range 522 522 """ 523 523 if range == 'low': … … 540 540 541 541 # Extrapolate the low-Q data 542 self._fit(model=self._low_extrapolation_function,543 544 qmax=qmax,545 power=self._low_extrapolation_power,546 range='low')542 p, dp = self._fit(model=self._low_extrapolation_function, 543 qmin=qmin, 544 qmax=qmax, 545 power=self._low_extrapolation_power) 546 self._low_extrapolation_power_fitted = p[0] 547 547 548 548 # Distribution starting point … … 578 578 579 579 # fit the data with a model to get the appropriate parameters 580 self._fit(model=self._high_extrapolation_function,581 qmin=qmin,582 qmax=qmax,583 power=self._high_extrapolation_power,584 range='high')580 p, dp = self._fit(model=self._high_extrapolation_function, 581 qmin=qmin, 582 qmax=qmax, 583 power=self._high_extrapolation_power) 584 self._high_extrapolation_power_fitted = p[0] 585 585 586 586 #create new Data1D to compute the invariant
Note: See TracChangeset
for help on using the changeset viewer.