Changeset 90e5ca1 in sasview
- Timestamp:
- Mar 17, 2010 9:01:04 PM (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:
- 9ce7641c
- Parents:
- 43e685d
- Location:
- Invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Invariant/invariant.py
rc75a8ed r90e5ca1 362 362 self._low_extrapolation_function = Guinier() 363 363 self._low_extrapolation_power = None 364 self._low_extrapolation_power_fitted = None 364 365 365 366 self._high_extrapolation_npts = 4 366 367 self._high_extrapolation_function = PowerLaw() 367 368 self._high_extrapolation_power = None 369 self._high_extrapolation_power_fitted = None 368 370 369 371 # Extrapolation range … … 391 393 return new_data 392 394 393 def _fit(self, model, qmin=Q_MINIMUM, qmax=Q_MAXIMUM, power=None ):395 def _fit(self, model, qmin=Q_MINIMUM, qmax=Q_MAXIMUM, power=None, range=None): 394 396 """ 395 397 fit data with function using … … 408 410 extrapolator = Extrapolator(data=self._data, model=model) 409 411 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] 410 416 411 417 return model.extract_model_parameters(constant=p[1], slope=p[0], dconstant=dp[1], dslope=dp[0]) … … 511 517 return result_data 512 518 519 def get_extrapolation_power(self, range='high'): 520 """ 521 return the fitted power for power law function at a givenr ange 522 """ 523 if range == 'low': 524 return self._low_extrapolation_power_fitted 525 return self._high_extrapolation_power_fitted 526 513 527 def get_qstar_low(self): 514 528 """ … … 529 543 qmin=qmin, 530 544 qmax=qmax, 531 power=self._low_extrapolation_power) 545 power=self._low_extrapolation_power, 546 range='low') 532 547 533 548 # Distribution starting point … … 566 581 qmin=qmin, 567 582 qmax=qmax, 568 power=self._high_extrapolation_power) 583 power=self._high_extrapolation_power, 584 range='high') 569 585 570 586 #create new Data1D to compute the invariant … … 653 669 self._high_extrapolation_npts = npts 654 670 self._high_extrapolation_power = power 671 self._high_extrapolation_power_fitted = power 655 672 else: 656 673 if function == 'power_law': … … 660 677 self._low_extrapolation_npts = npts 661 678 self._low_extrapolation_power = power 679 self._low_extrapolation_power_fitted = power 662 680 663 681 def get_qstar(self, extrapolation=None): -
Invariant/test/utest_use_cases.py
rbdd162f r90e5ca1 237 237 self.assertAlmostEquals(s , 941.7452, 3) 238 238 239 239 def test_use_case_6(self): 240 """ 241 Invariant with high-Q extrapolation 242 """ 243 # Create invariant object. Background and scale left as defaults. 244 inv = invariant.InvariantCalculator(data=self.data) 245 246 # Set the extrapolation parameters for the high-Q range 247 inv.set_extrapolation(range='low', npts=10, function='power_law', power=4) 248 249 # The version of the call without error 250 # The function parameter defaults to None, then is picked to be 'power_law' for extrapolation='high' 251 qstar = inv.get_qstar(extrapolation='low') 252 253 # The version of the call with error 254 qstar, qstar_err = inv.get_qstar_with_error(extrapolation='low') 255 256 # Get the volume fraction and surface 257 v, dv = inv.get_volume_fraction_with_error(contrast=2.6e-6) 258 s, ds = inv.get_surface_with_error(contrast=2.6e-6, porod_const=2) 259 260 # Test results 261 self.assertAlmostEquals(qstar, 7.49e-5,2) 262 self.assertAlmostEquals(v, 0.005952674, 3) 263 self.assertAlmostEquals(s , 941.7452, 3) 264 240 265 class TestInvPinholeSmear(unittest.TestCase): 241 266 """
Note: See TracChangeset
for help on using the changeset viewer.