Ignore:
Timestamp:
Sep 23, 2009 6:42:33 PM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
6e9150d
Parents:
3f31159
Message:

park_integration: refactor code using new smearing code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • park_integration/AbstractFitEngine.py

    r920a6e5 r4bb2917  
    190190            self.qmax = qmax 
    191191             
    192         # Range used for input to smearing 
     192        # Determine the range needed in unsmeared-Q to cover 
     193        # the smeared Q range 
    193194        self._qmin_unsmeared = self.qmin 
    194195        self._qmax_unsmeared = self.qmax     
    195196         
    196         # Determine the range needed in unsmeared-Q to cover 
    197         # the smeared Q range 
    198         #TODO: use the smearing matrix to determine which  
    199         # bin range to use 
    200         if self.smearer.__class__.__name__ == 'SlitSmearer': 
    201             self._qmin_unsmeared = min(self.data.x) 
    202             self._qmax_unsmeared = max(self.data.x) 
    203         elif self.smearer.__class__.__name__ == 'QSmearer': 
    204             # Take 3 sigmas as the offset between smeared and unsmeared space 
    205             try: 
    206                 offset = 3.0*max(self.smearer.width) 
    207                 self._qmin_unsmeared = max([min(self.data.x), self.qmin-offset]) 
    208                 self._qmax_unsmeared = min([max(self.data.x), self.qmax+offset]) 
    209             except: 
    210                 logging.error("FitData1D.setFitRange: %s" % sys.exc_value) 
     197        self._first_unsmeared_bin = 0 
     198        self._last_unsmeared_bin  = len(self.data.x)-1 
     199         
     200        if self.smearer!=None: 
     201            self._first_unsmeared_bin, self._last_unsmeared_bin = self.smearer.get_bin_range(self.qmin, self.qmax) 
     202            self._qmin_unsmeared = self.data.x[self._first_unsmeared_bin] 
     203            self._qmax_unsmeared = self.data.x[self._last_unsmeared_bin] 
     204             
    211205        # Identify the bin range for the unsmeared and smeared spaces 
    212206        self.idx = (self.x>=self.qmin) & (self.x <= self.qmax) 
     
    232226        # Compute theory data f(x) 
    233227        fx= numpy.zeros(len(self.x)) 
    234         _first_bin = None 
    235         _last_bin  = None 
    236         
    237228        fx[self.idx_unsmeared] = fn(self.x[self.idx_unsmeared]) 
    238229        
    239          
    240         for i_x in range(len(self.x)): 
    241             if self.idx_unsmeared[i_x]==True: 
    242                 # Identify first and last bin 
    243                 #TODO: refactor this to pass q-values to the smearer 
    244                 # and let it figure out which bin range to use 
    245                 if _first_bin is None: 
    246                     _first_bin = i_x 
    247                 else: 
    248                     _last_bin  = i_x 
    249                 
    250230        ## Smear theory data 
    251231        if self.smearer is not None: 
    252             fx = self.smearer(fx, _first_bin, _last_bin) 
     232            fx = self.smearer(fx, self._first_unsmeared_bin, self._last_unsmeared_bin) 
    253233        
    254234        ## Sanity check 
Note: See TracChangeset for help on using the changeset viewer.