Changeset ed2276f in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Apr 4, 2017 10:00:18 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7b15990
Parents:
9a5097c (diff), 571bf4b (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:
Andrew Jackson <andrew.jackson@…> (04/04/17 10:00:18)
git-committer:
GitHub <noreply@…> (04/04/17 10:00:18)
Message:

Merge branch 'master' into numpy_import

Location:
src/sas/sasgui/perspectives/fitting
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r9a5097c red2276f  
    14491449                self.state_change = True 
    14501450                self._draw_model() 
    1451                 # Time delay has been introduced to prevent _handle error 
    1452                 # on Windows 
    1453                 # This part of code is executed when model is selected and 
    1454                 # it's parameters are changed (with respect to previously 
    1455                 # selected model). There are two Iq evaluations occuring one 
    1456                 # after another and therefore there may be compilation error 
    1457                 # if model is calculated for the first time. 
    1458                 # This seems to be Windows only issue - haven't tested on Linux 
    1459                 # though.The proper solution (other than time delay) requires 
    1460                 # more fundemental code refatoring 
    1461                 # Wojtek P. Nov 7, 2016 
    1462                 if not ON_MAC: 
    1463                     time.sleep(0.1) 
    14641451                self.Refresh() 
    14651452 
     
    26092596            Layout is called after fitting. 
    26102597        """ 
    2611         self._sleep4sec() 
    26122598        self.Layout() 
    26132599        return 
    2614  
    2615     def _sleep4sec(self): 
    2616         """ 
    2617             sleep for 1 sec only applied on Mac 
    2618             Note: This 1sec helps for Mac not to crash on self. 
    2619             Layout after self._draw_model 
    2620         """ 
    2621         if ON_MAC: 
    2622             time.sleep(1) 
    26232600 
    26242601    def _find_polyfunc_selection(self, disp_func=None): 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r9a5097c red2276f  
    18091809            self.onSmear(None) 
    18101810 
    1811     def _mac_sleep(self, sec=0.2): 
    1812         """ 
    1813         Give sleep to MAC 
    1814         """ 
    1815         if self.is_mac: 
    1816             time.sleep(sec) 
    1817  
    18181811    def get_view_mode(self): 
    18191812        """ 
     
    21882181        self.save_current_state() 
    21892182 
    2190         if not self.is_mac: 
    2191             self.Layout() 
    2192             self.Refresh() 
    2193         self._mac_sleep(0.1) 
    21942183        # plot model ( when drawing, do not update chisqr value again) 
    21952184        self._draw_model(update_chisqr=False, source='fit') 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r9a5097c red2276f  
    876876                qmin=qmin, qmax=qmax, weight=weight) 
    877877 
    878     def _mac_sleep(self, sec=0.2): 
    879         """ 
    880         Give sleep to MAC 
    881         """ 
    882         if ON_MAC: 
    883             time.sleep(sec) 
    884  
    885878    def draw_model(self, model, page_id, data=None, smearer=None, 
    886879                   enable1D=True, enable2D=False, 
     
    10301023                                manager=self, 
    10311024                                improvement_delta=0.1) 
    1032         self._mac_sleep(0.2) 
    10331025 
    10341026        # batch fit 
     
    12701262        :param elapsed: time spent at the fitting level 
    12711263        """ 
    1272         self._mac_sleep(0.2) 
    12731264        uid = page_id[0] 
    12741265        if uid in self.fit_thread_list.keys(): 
     
    15201511            page_id = [] 
    15211512        ## fit more than 1 model at the same time 
    1522         self._mac_sleep(0.2) 
    15231513        try: 
    15241514            index = 0 
     
    17551745                                          data_id="Data  " + data.name + " unsmeared", 
    17561746                                          dy=unsmeared_error) 
    1757                  
    1758             if sq_model is not None and pq_model is not None: 
    1759                 self.create_theory_1D(x, sq_model, page_id, model, data, state, 
    1760                                       data_description=model.name + " S(q)", 
    1761                                       data_id=str(page_id) + " " + data.name + " S(q)") 
    1762                 self.create_theory_1D(x, pq_model, page_id, model, data, state, 
    1763                                       data_description=model.name + " P(q)", 
    1764                                       data_id=str(page_id) + " " + data.name + " P(q)") 
    1765  
     1747            # Comment this out until we can get P*S models with correctly populated parameters 
     1748            #if sq_model is not None and pq_model is not None: 
     1749            #    self.create_theory_1D(x, sq_model, page_id, model, data, state, 
     1750            #                          data_description=model.name + " S(q)", 
     1751            #                          data_id=str(page_id) + " " + data.name + " S(q)") 
     1752            #    self.create_theory_1D(x, pq_model, page_id, model, data, state, 
     1753            #                          data_description=model.name + " P(q)", 
     1754            #                          data_id=str(page_id) + " " + data.name + " P(q)") 
    17661755 
    17671756            current_pg = self.fit_panel.get_page_by_id(page_id) 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r9a5097c red2276f  
    819819 
    820820        attr = newdoc.createAttribute("version") 
    821         import sasview 
     821        from sas import sasview 
    822822        attr.nodeValue = sasview.__version__ 
    823823        # attr.nodeValue = '1.0' 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    rc1c9929 r9a5097c  
    44 
    55import time 
    6 import numpy 
     6import numpy as np 
    77import math 
    88from sas.sascalc.data_util.calcthread import CalcThread 
     
    6868 
    6969        # Define matrix where data will be plotted 
    70         radius = numpy.sqrt((self.data.qx_data * self.data.qx_data) + \ 
     70        radius = np.sqrt((self.data.qx_data * self.data.qx_data) + \ 
    7171                    (self.data.qy_data * self.data.qy_data)) 
    7272 
     
    7575        index_model = (self.qmin <= radius) & (radius <= self.qmax) 
    7676        index_model = index_model & self.data.mask 
    77         index_model = index_model & numpy.isfinite(self.data.data) 
     77        index_model = index_model & np.isfinite(self.data.data) 
    7878 
    7979        if self.smearer is not None: 
     
    9191                self.data.qy_data[index_model] 
    9292            ]) 
    93         output = numpy.zeros(len(self.data.qx_data)) 
     93        output = np.zeros(len(self.data.qx_data)) 
    9494        # output default is None 
    9595        # This method is to distinguish between masked 
     
    163163        """ 
    164164        self.starttime = time.time() 
    165         output = numpy.zeros((len(self.data.x))) 
     165        output = np.zeros((len(self.data.x))) 
    166166        index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 
    167167 
     
    175175                                                             self.qmax) 
    176176            mask = self.data.x[first_bin:last_bin+1] 
    177             unsmeared_output = numpy.zeros((len(self.data.x))) 
     177            unsmeared_output = np.zeros((len(self.data.x))) 
    178178            unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 
    179179            self.smearer.model = self.model 
     
    183183            # Check that the arrays are compatible. If we only have a model but no data, 
    184184            # the length of data.y will be zero. 
    185             if isinstance(self.data.y, numpy.ndarray) and output.shape == self.data.y.shape: 
    186                 unsmeared_data = numpy.zeros((len(self.data.x))) 
    187                 unsmeared_error = numpy.zeros((len(self.data.x))) 
     185            if isinstance(self.data.y, np.ndarray) and output.shape == self.data.y.shape: 
     186                unsmeared_data = np.zeros((len(self.data.x))) 
     187                unsmeared_error = np.zeros((len(self.data.x))) 
    188188                unsmeared_data[first_bin:last_bin+1] = self.data.y[first_bin:last_bin+1]\ 
    189189                                                        * unsmeared_output[first_bin:last_bin+1]\ 
     
    209209 
    210210        if p_model is not None and s_model is not None: 
    211             sq_values = numpy.zeros((len(self.data.x))) 
    212             pq_values = numpy.zeros((len(self.data.x))) 
     211            sq_values = np.zeros((len(self.data.x))) 
     212            pq_values = np.zeros((len(self.data.x))) 
    213213            sq_values[index] = s_model.evalDistribution(self.data.x[index]) 
    214214            pq_values[index] = p_model.evalDistribution(self.data.x[index]) 
  • src/sas/sasgui/perspectives/fitting/utils.py

    rd85c194 r9a5097c  
    22Module contains functions frequently used in this package 
    33""" 
    4 import numpy 
     4import numpy as np 
    55 
    66 
     
    1919        data = data.y 
    2020    if flag == 0: 
    21         weight = numpy.ones_like(data) 
     21        weight = np.ones_like(data) 
    2222    elif flag == 1: 
    2323        weight = dy_data 
    2424    elif flag == 2: 
    25         weight = numpy.sqrt(numpy.abs(data)) 
     25        weight = np.sqrt(np.abs(data)) 
    2626    elif flag == 3: 
    27         weight = numpy.abs(data) 
     27        weight = np.abs(data) 
    2828    return weight 
Note: See TracChangeset for help on using the changeset viewer.