Changeset bb3eb744 in sasview


Ignore:
Timestamp:
Dec 21, 2016 9:31:55 AM (7 years ago)
Author:
GitHub <noreply@…>
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:
b61bd57, b0bebdc
Parents:
24fd27a (diff), 505706a (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.
git-author:
Jeff Krzywon <krzywon@…> (12/21/16 09:31:55)
git-committer:
GitHub <noreply@…> (12/21/16 09:31:55)
Message:

Merge pull request #28 from SasView?/ticket-811

Ticket 811

Location:
src/sas
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/data_util/qsmearing.py

    r345e7e4 rd3911e3  
    4141        elif data.dqx_data == None or data.dqy_data == None: 
    4242            return None 
    43         return Pinhole2D(data) 
     43        return PySmear2D(data, model) 
    4444 
    4545    if  not hasattr(data, "dx") and not hasattr(data, "dxl")\ 
     
    142142    width = data.dx if data.dx is not None else 0 
    143143    return PySmear(Pinhole1D(q, width), model) 
     144 
     145 
     146class PySmear2D(object): 
     147    """ 
     148    Q smearing class for SAS 2d pinhole data 
     149    """ 
     150 
     151    def __init__(self, data=None, model=None): 
     152        self.data = data 
     153        self.model = model 
     154        self.accuracy = 'Low' 
     155        self.limit = 3.0 
     156        self.index = None 
     157        self.coords = 'polar' 
     158        self.smearer = True 
     159 
     160    def set_accuracy(self, accuracy='Low'): 
     161        """ 
     162        Set accuracy. 
     163 
     164        :param accuracy:  string 
     165        """ 
     166        self.accuracy = accuracy 
     167 
     168    def set_smearer(self, smearer=True): 
     169        """ 
     170        Set whether or not smearer will be used 
     171 
     172        :param smearer: smear object 
     173 
     174        """ 
     175        self.smearer = smearer 
     176 
     177    def set_data(self, data=None): 
     178        """ 
     179        Set data. 
     180 
     181        :param data: DataLoader.Data_info type 
     182        """ 
     183        self.data = data 
     184 
     185    def set_model(self, model=None): 
     186        """ 
     187        Set model. 
     188 
     189        :param model: sas.models instance 
     190        """ 
     191        self.model = model 
     192 
     193    def set_index(self, index=None): 
     194        """ 
     195        Set index. 
     196 
     197        :param index: 1d arrays 
     198        """ 
     199        self.index = index 
     200 
     201    def get_value(self): 
     202        """ 
     203        Over sampling of r_nbins times phi_nbins, calculate Gaussian weights, 
     204        then find smeared intensity 
     205        """ 
     206        if self.smearer: 
     207            res = Pinhole2D(data=self.data, index=self.index, 
     208                            nsigma=3.0, accuracy=self.accuracy, 
     209                            coords=self.coords) 
     210            val = self.model.evalDistribution(res.q_calc) 
     211            return res.apply(val) 
     212        else: 
     213            index = self.index if self.index is not None else slice(None) 
     214            qx_data = self.data.qx_data[index] 
     215            qy_data = self.data.qy_data[index] 
     216            q_calc = [qx_data, qy_data] 
     217            val = self.model.evalDistribution(q_calc) 
     218            return val 
     219 
  • src/sas/sascalc/fit/AbstractFitEngine.py

    r345e7e4 rd3911e3  
    359359        if self.smearer != None: 
    360360            fn.set_index(self.idx) 
    361             # Get necessary data from self.data and set the data for smearing 
    362             fn.get_data() 
    363  
    364361            gn = fn.get_value() 
    365362        else: 
  • src/sas/sasgui/guiframe/gui_manager.py

    r67b0a99 r505706a  
    19901990                wx.PostEvent(self, 
    19911991                             StatusEvent(status="Completed saving.")) 
    1992             except: 
     1992            except Exception: 
    19931993                msg = "Error occurred while saving: " 
     1994                msg += traceback.format_exc() 
    19941995                msg += "To save, the application panel should have a data set.." 
    19951996                wx.PostEvent(self, StatusEvent(status=msg)) 
     
    20402041                logging.warning(msg) 
    20412042                wx.PostEvent(self, StatusEvent(status=msg, info="error")) 
    2042         except: 
     2043        except Exception: 
    20432044            msg = "Error occurred while saving: " 
     2045            msg += traceback.format_exc() 
    20442046            msg += "To save, at least one application panel " 
    20452047            msg += "should have a data set.." 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r06a4306 r505706a  
    10411041                        disp_model = POLYDISPERSITY_MODELS['array']() 
    10421042                        if hasattr(state, "values") and \ 
    1043                                  self.disp_cb_dict[item].GetValue() is True: 
     1043                                 self.disp_cb_dict[item].GetValue(): 
    10441044                            if len(state.values) > 0: 
    10451045                                self.values = state.values 
     
    15411541                        index_data = ((self.qmin_x <= self.data.x) & 
    15421542                                      (self.data.x <= self.qmax_x)) 
    1543                         val = self.data.x[index_data is True] 
    1544                         val = len(val) if isinstance(val, list) else 1 
    1545                         self.Npts_fit.SetValue(str(val)) 
    1546  
     1543                        val = str(len(self.data.x[index_data])) 
     1544                        self.Npts_fit.SetValue(val) 
    15471545                    else: 
    15481546                        # No data in the panel 
     
    21472145                flag = False 
    21482146            else: 
    2149                 self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
     2147                self.Npts_fit.SetValue(str(len(index_data[index_data]))) 
    21502148                self.fitrange = True 
    21512149 
     
    21822180                flag = False 
    21832181            else: 
    2184                 val = index_data[index_data is True] 
    2185                 val = len(val) if isinstance(val, list) else 1 
    2186                 self.Npts_fit.SetValue(str(val)) 
     2182                self.Npts_fit.SetValue(str(len(index_data[index_data]))) 
    21872183                self.fitrange = True 
    21882184 
     
    26282624            Layout after self._draw_model 
    26292625        """ 
    2630         if ON_MAC is True: 
     2626        if ON_MAC: 
    26312627            time.sleep(1) 
    26322628 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    r286c757 rd3911e3  
    8282            fn.set_model(self.model) 
    8383            fn.set_index(index_model) 
    84             # Get necessary data from self.data and set the data for smearing 
    85             fn.get_data() 
    8684            # Calculate smeared Intensity 
    8785            #(by Gaussian averaging): DataLoader/smearing2d/Smearer2D() 
     
    8987        else: 
    9088            # calculation w/o smearing 
    91             value = self.model.evalDistribution(\ 
    92                 [self.data.qx_data[index_model], 
    93                  self.data.qy_data[index_model]]) 
     89            value = self.model.evalDistribution([ 
     90                self.data.qx_data[index_model], 
     91                self.data.qy_data[index_model] 
     92            ]) 
    9493        output = numpy.zeros(len(self.data.qx_data)) 
    9594        # output default is None 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    rbf44249e r24fd27a  
    16181618                return 
    16191619        # check if it is pinhole smear and get min max if it is. 
    1620         if data.dx is not None and not numpy.any(data.dx): 
     1620        if data.dx is not None and numpy.any(data.dx): 
    16211621            self.smear_type = "Pinhole" 
    16221622            self.dq_l = data.dx[0] 
Note: See TracChangeset for help on using the changeset viewer.