Changeset 9f7fbd9 in sasview
- Timestamp:
- Mar 24, 2015 3:28:54 PM (10 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:
- 66f21cd
- Parents:
- 0efb04d
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/fit/AbstractFitEngine.py
r386ffe1 r9f7fbd9 161 161 # TODO: Should provide an option for users to set it like percent, 162 162 # constant, or dy data 163 if dy ==None or dy == [] or dy.all() == 0:163 if dy is None or dy == [] or dy.all() == 0: 164 164 self.dy = numpy.ones(len(y)) 165 165 else: … … 260 260 """ 261 261 return [] 262 263 262 263 264 264 class FitData2D(Data2D): 265 265 """ -
src/sas/fit/BumpsFitting.py
r386ffe1 r9f7fbd9 107 107 self.model = model.model 108 108 self.data = data 109 if self.data.smearer is not None: 110 self.data.smearer.model = self.model 109 111 self._define_pars() 110 112 self._init_pars(kw) … … 174 176 def _recalculate(self): 175 177 if self._dirty: 176 self._residuals, self._theory = self.data.residuals(self.model.evalDistribution) 178 self._residuals, self._theory \ 179 = self.data.residuals(self.model.evalDistribution) 177 180 self._dirty = False 178 181 -
src/sas/models/qsmearing.py
rfd5ac0d r9f7fbd9 81 81 # If we found slit smearing data, return a slit smearer 82 82 if _found_slit == True: 83 return SlitSmearer(data1D, model)83 return PySlitSmearer(data1D, model) 84 84 return None 85 85 … … 583 583 return nbins_low, nbins_high, \ 584 584 new_width[data_x_ext > 0], data_x_ext[data_x_ext > 0] 585 586 587 588 from .resolution import Slit1D 589 class PySlitSmearer(object): 590 def __init__(self, data1D, model = None): 591 self.model = model 592 593 q = data1D.x 594 width = data1D.dxw if data1D.dxw is not None else 0 595 height = data1D.dxl if data1D.dxl is not None else 0 596 # TODO: width and height seem to be reversed 597 self.resolution = Slit1D(q, height, width) 598 599 def __call__(self, iq_in, first_bin=0, last_bin=None): 600 if last_bin is None or last_bin >= len(iq_in): 601 last_bin = len(iq_in) - 1 602 q_calc = self.resolution.q_calc 603 iq_calc = numpy.empty_like(q_calc) 604 iq_calc[:first_bin] = 0 605 iq_calc[first_bin:last_bin+1] = iq_in 606 if last_bin < len(q_calc)-1: 607 iq_calc[last_bin:] = self.model.evalDistribution(q_calc[last_bin:]) 608 iq_out = self.resolution.apply(iq_calc) 609 return iq_out[first_bin:last_bin+1] 610 611 def get_bin_range(self, q_min=None, q_max=None): 612 """ 613 614 :param q_min: minimum q-value to smear 615 :param q_max: maximum q-value to smear 616 617 """ 618 # assume the data values are sorted 619 first = numpy.searchsorted(self.resolution.q, q_min) 620 # assume that the resolution is much larger than the q range 621 last = len(self.resolution.q)-1 622 return first, last -
test/pr_inversion/test/test_output.txt
r8a428fc r9f7fbd9 3 3 #alpha=0.0007 4 4 #chi2=836.797 5 #elapsed=0.00 1999865 #elapsed=0.000377893 6 6 #qmin=None 7 7 #qmax=None -
test/sasfit/test/utest_fit_smeared.py
refa5e44 r9f7fbd9 165 165 def test_slit(self): 166 166 smear = smear_selection(self.data_slit) 167 self.assertEqual(smear.__class__.__name__, 'SlitSmearer') 167 #self.assertEqual(smear.__class__.__name__, 'SlitSmearer') 168 self.assertEqual(smear.__class__.__name__, 'PySlitSmearer') 168 169 169 170 fitter = Fit('bumps') … … 181 182 182 183 result1, = fitter.fit() 183 184 184 185 #print "v",result1.pvec 185 186 #print "dv",result1.stderr 186 187 #print "chisq(v)",result1.fitness 187 188 self.assertTrue( math.fabs(result1.pvec[0]-2340) < 20 ) 189 self.assertTrue( math.fabs(result1.pvec[1]-0.010) < 0.002 ) 188 189 numpy.testing.assert_allclose(result1.pvec, [2323.466,0.22137], rtol=0.001) 190 190 191 191 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.