Changeset f552ff3 in sasview


Ignore:
Timestamp:
Mar 24, 2015 8:42:33 PM (10 years ago)
Author:
butler
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.
Message:

Merge branch 'master' of https://github.com/SasView/sasview.git

Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/sas/fit/AbstractFitEngine.py

    r386ffe1 r9f7fbd9  
    161161        # TODO: Should provide an option for users to set it like percent, 
    162162        # 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: 
    164164            self.dy = numpy.ones(len(y)) 
    165165        else: 
     
    260260        """ 
    261261        return [] 
    262      
    263      
     262 
     263 
    264264class FitData2D(Data2D): 
    265265    """ 
  • src/sas/fit/BumpsFitting.py

    r386ffe1 r9f7fbd9  
    107107        self.model = model.model 
    108108        self.data = data 
     109        if self.data.smearer is not None: 
     110            self.data.smearer.model = self.model 
    109111        self._define_pars() 
    110112        self._init_pars(kw) 
     
    174176    def _recalculate(self): 
    175177        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) 
    177180            self._dirty = False 
    178181 
  • src/sas/models/qsmearing.py

    rfd5ac0d r9f7fbd9  
    8181    # If we found slit smearing data, return a slit smearer 
    8282    if _found_slit == True: 
    83         return SlitSmearer(data1D, model) 
     83        return PySlitSmearer(data1D, model) 
    8484    return None 
    8585             
     
    583583    return nbins_low, nbins_high, \ 
    584584             new_width[data_x_ext > 0], data_x_ext[data_x_ext > 0] 
     585 
     586 
     587 
     588from .resolution import Slit1D 
     589class 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  
    257257        or when a new computation is finished. 
    258258        """ 
     259        self.npts_ctl.SetFocus() 
    259260        # Get the output type selection 
    260261        output_type = self.output_box.GetString(self.output_box.GetSelection()) 
     
    329330        # Ouput selection box 
    330331        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) 
    332333        for item in self.results.outputs.keys(): 
    333334            self.output_box.Append(item, "") 
    334335        self.output_box.SetStringSelection(DEFAULT_OUTPUT) 
     336        self.output_box.SetEditable(False) 
    335337 
    336338        output_sizer = wx.GridBagSizer(5, 5) 
  • src/sas/perspectives/pr/inversion_panel.py

    rdea2f6e rf552ff3  
    703703        try: 
    704704            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 ) 
    706710        except: 
    707711            # No estimate or bad estimate, either do nothing 
     
    715719        try: 
    716720            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 ) 
    718726        except: 
    719727            # No estimate or bad estimate, either do nothing 
  • src/sas/pr/num_term.py

    r5f8fc78 rc1bffa5  
    107107        """ 
    108108        # Generate data 
    109         # ls_osc = self.get0_out() 
     109        self.get0_out() 
    110110        med = self.median_osc() 
    111111 
     
    144144            return nt, self.alpha_list[nt - 10], self.mess_list[nt - 10] 
    145145        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, '' 
    147149 
    148150 
  • test/pr_inversion/test/test_output.txt

    r8a428fc r9f7fbd9  
    33#alpha=0.0007 
    44#chi2=836.797 
    5 #elapsed=0.00199986 
     5#elapsed=0.000377893 
    66#qmin=None 
    77#qmax=None 
  • test/sasfit/test/utest_fit_smeared.py

    refa5e44 r9f7fbd9  
    165165    def test_slit(self): 
    166166        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') 
    168169 
    169170        fitter = Fit('bumps') 
     
    181182         
    182183        result1, = fitter.fit() 
    183          
     184 
    184185        #print "v",result1.pvec 
    185186        #print "dv",result1.stderr 
    186187        #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) 
    190190 
    191191if __name__ == '__main__': 
Note: See TracChangeset for help on using the changeset viewer.