Changeset eb320682 in sasview


Ignore:
Timestamp:
Jul 12, 2016 5:29:11 AM (8 years ago)
Author:
lewis
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
41345d7e
Parents:
c512f7d
Message:

Fix bug that occurs when correlation function has no linear section

Location:
src/sas
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/corfunc/corfunc_calculator.py

    ra2db1ab reb320682  
    201201        mask = np.where(np.abs((y-(m*x+b))/y) < 0.01)[0] 
    202202        if len(mask) == 0:  # Return garbage for bad fits 
    203             return garbage 
     203            return { 'max': self._round_sig_figs(x[maxs[0]], 6) } 
    204204        dtr = x[mask[0]]  # Beginning of Linear Section 
    205205        d0 = x[mask[-1]]  # End of Linear Section 
  • src/sas/sasgui/perspectives/corfunc/corfunc_panel.py

    rc512f7d reb320682  
    108108            return 
    109109        if self.state.outputs is not None and self.state.outputs != {}: 
    110             self.set_extracted_params(self.state.outputs) 
     110            self.set_extracted_params(self.state.outputs, reset=True) 
    111111 
    112112    def get_state(self): 
     
    151151        self._calculator.set_data(data) 
    152152        # Reset the outputs 
    153         self.set_extracted_params(None) 
     153        self.set_extracted_params(None, reset=True) 
    154154        if self._manager is not None: 
    155155            self._manager.clear_data() 
     
    285285        self._calculator.background = bg 
    286286 
    287     def set_extracted_params(self, params): 
     287    def set_extracted_params(self, params=None, reset=False): 
    288288        self.extracted_params = params 
     289        error = False 
    289290        if params is None: 
     291            if not reset: error = True 
    290292            for key in OUTPUT_STRINGS.keys(): 
    291293                self._output_boxes[key].SetValue('-') 
    292294        else: 
    293             for key in OUTPUT_STRINGS.keys(): 
    294                 value = params[key] 
     295            if len(params) < len(OUTPUT_STRINGS): 
     296                # Not all parameters were calculated 
     297                error = True 
     298            for key, value in params.iteritems(): 
    295299                self._output_boxes[key].SetValue(value) 
     300        if error: 
     301            msg = 'Not all parameters were able to be calculated' 
     302            wx.PostEvent(self._manager.parent, StatusEvent( 
     303                status=msg, info='error')) 
     304 
    296305 
    297306    def plot_qrange(self, active=None, leftdown=False): 
Note: See TracChangeset for help on using the changeset viewer.