Changeset f552ff3 in sasview
- Timestamp:
- Mar 24, 2015 8:42:33 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:
- f71700b
- Parents:
- dea2f6e (diff), 9f7fbd9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 8 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 -
src/sas/perspectives/pr/explore_dialog.py
r8b21fa7 r0efb04d 257 257 or when a new computation is finished. 258 258 """ 259 self.npts_ctl.SetFocus() 259 260 # Get the output type selection 260 261 output_type = self.output_box.GetString(self.output_box.GetSelection()) … … 329 330 # Ouput selection box 330 331 selection_msg = wx.StaticText(self, -1, "Select a dependent variable:") 331 self.output_box = wx.ComboBox(self, -1 )332 self.output_box = wx.ComboBox(self, -1, style=wx.CB_READONLY) 332 333 for item in self.results.outputs.keys(): 333 334 self.output_box.Append(item, "") 334 335 self.output_box.SetStringSelection(DEFAULT_OUTPUT) 336 self.output_box.SetEditable(False) 335 337 336 338 output_sizer = wx.GridBagSizer(5, 5) -
src/sas/perspectives/pr/inversion_panel.py
rdea2f6e rf552ff3 703 703 try: 704 704 alpha = self.alpha_estimate_ctl.GetLabel() 705 self.alpha_ctl.SetValue(float(alpha)) 705 # Check that we have a number 706 float(alpha) 707 self.alpha_ctl.SetValue(alpha) 708 except ValueError: 709 logging.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha ) 706 710 except: 707 711 # No estimate or bad estimate, either do nothing … … 715 719 try: 716 720 nterms = self.nterms_estimate_ctl.GetLabel() 717 self.nfunc_ctl.SetValue(float(nterms)) 721 # Check that we have a number 722 float(nterms) 723 self.nfunc_ctl.SetValue(nterms) 724 except ValueError: 725 logging.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms ) 718 726 except: 719 727 # No estimate or bad estimate, either do nothing -
src/sas/pr/num_term.py
r5f8fc78 rc1bffa5 107 107 """ 108 108 # Generate data 109 # ls_osc =self.get0_out()109 self.get0_out() 110 110 med = self.median_osc() 111 111 … … 144 144 return nt, self.alpha_list[nt - 10], self.mess_list[nt - 10] 145 145 except: 146 return self.nterm_min, self.alpha_list[10], self.mess_list[10] 146 #TODO: check the logic above and make sure it doesn't 147 # rely on the try-except. 148 return self.nterm_min, self.invertor.alpha, '' 147 149 148 150 -
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.