Changeset c4f52e3 in sasview for Invariant


Ignore:
Timestamp:
Mar 27, 2010 8:11:58 AM (14 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:
d1b43cd
Parents:
18e6c5e
Message:

invariant: minor clean up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Invariant/invariant.py

    r90e5ca1 rc4f52e3  
    134134        self.dscale = math.exp(constant)*dconstant 
    135135        self.dradius = -3.0/2.0/math.sqrt(-3 * slope)*dslope 
     136         
     137        return [self.radius, self.scale], [self.dradius, self.dscale] 
    136138         
    137139    def evaluate_model(self, x): 
     
    195197        # Errors 
    196198        self.dscale = math.exp(constant)*dconstant 
    197         self.dradius = -dslope 
     199        self.dpower = -dslope 
     200         
     201        return [self.power, self.scale], [self.dpower, self.dscale] 
    198202         
    199203    def evaluate_model(self, x): 
     
    210214        """ 
    211215        p1 = numpy.array([self.dscale * math.pow(q, -self.power) for q in x]) 
    212         p2 = numpy.array([self.scale * self.power * math.pow(q, -self.power-1) * self.dradius for q in x]) 
     216        p2 = numpy.array([self.scale * self.power * math.pow(q, -self.power-1) * self.dpower for q in x]) 
    213217        diq2 = p1*p1 + p2*p2         
    214218        return numpy.array( [math.sqrt(err) for err in diq2] ) 
     
    393397        return  new_data 
    394398      
    395     def _fit(self, model, qmin=Q_MINIMUM, qmax=Q_MAXIMUM, power=None, range=None): 
     399    def _fit(self, model, qmin=Q_MINIMUM, qmax=Q_MAXIMUM, power=None): 
    396400        """ 
    397401            fit data with function using  
     
    410414        extrapolator = Extrapolator(data=self._data, model=model) 
    411415        p, dp = extrapolator.fit(power=power, qmin=qmin, qmax=qmax)  
    412         if range is not None and range == 'low': 
    413             self._low_extrapolation_power_fitted = -1*p[0] 
    414         if range is not None and range == 'high': 
    415             self._high_extrapolation_power_fitted = -1*p[0] 
    416416         
    417417        return model.extract_model_parameters(constant=p[1], slope=p[0], dconstant=dp[1], dslope=dp[0]) 
     
    519519    def get_extrapolation_power(self, range='high'): 
    520520        """ 
    521             return the fitted power for power law function at a givenr ange 
     521            return the fitted power for power law function for a given extrapolation range 
    522522        """ 
    523523        if range == 'low': 
     
    540540         
    541541        # Extrapolate the low-Q data 
    542         self._fit(model=self._low_extrapolation_function, 
    543                          qmin=qmin, 
    544                          qmax=qmax, 
    545                          power=self._low_extrapolation_power, 
    546                          range='low') 
     542        p, dp = self._fit(model=self._low_extrapolation_function, 
     543                              qmin=qmin, 
     544                          qmax=qmax, 
     545                          power=self._low_extrapolation_power) 
     546        self._low_extrapolation_power_fitted = p[0] 
    547547         
    548548        # Distribution starting point 
     
    578578         
    579579        # fit the data with a model to get the appropriate parameters 
    580         self._fit(model=self._high_extrapolation_function, 
    581                          qmin=qmin, 
    582                          qmax=qmax, 
    583                          power=self._high_extrapolation_power, 
    584                          range='high') 
     580        p, dp = self._fit(model=self._high_extrapolation_function, 
     581                          qmin=qmin, 
     582                          qmax=qmax, 
     583                          power=self._high_extrapolation_power) 
     584        self._high_extrapolation_power_fitted = p[0] 
    585585         
    586586        #create new Data1D to compute the invariant 
Note: See TracChangeset for help on using the changeset viewer.