Changeset 18695bf in sasview


Ignore:
Timestamp:
Jan 18, 2011 10:38:36 AM (14 years ago)
Author:
Jae Cho <jhjcho@…>
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:
18b89c4
Parents:
1b02da1d
Message:

replaced math.pow to numpy.power since math.pow is not working with list of x values(remember we use the list in fitting for speed)

Location:
sansmodels/src/sans/models
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/BroadPeakModel.py

    r8f20419d r18695bf  
    55 
    66from sans.models.BaseComponent import BaseComponent 
    7 from math import pow, fabs 
     7from math import fabs 
     8from numpy import power 
    89 
    910class BroadPeakModel(BaseComponent): 
     
    1920        # Initialize BaseComponent first, then sphere 
    2021        BaseComponent.__init__(self) 
    21          
     22        self.counter = 0 
    2223        ## Name of the model 
    2324        self.name = "BroadPeak" 
     
    6061        inten = self.params['scale_p']/pow(x,self.params['exponent_p']) 
    6162        inten += self.params['scale_l']/(1.0 + \ 
    62                 pow((fabs(x-self.params['q_peak'])*self.params['length_l']),self.params['exponent_l'])) 
     63                power((fabs(x-self.params['q_peak'])*self.params['length_l']),\ 
     64                    self.params['exponent_l'])) 
     65 
    6366        inten += self.params['background'] 
    64  
     67         
    6568        return inten   
    6669    
  • sansmodels/src/sans/models/CorrLengthModel.py

    r8f20419d r18695bf  
    55 
    66from sans.models.BaseComponent import BaseComponent 
    7 from math import pow 
     7from numpy import power 
    88 
    99class CorrLengthModel(BaseComponent): 
     
    5757        inten = self.params['scale_p']/pow(x,self.params['exponent_p']) 
    5858        inten += self.params['scale_l']/(1.0 + \ 
    59                 pow((x*self.params['length_l']),self.params['exponent_l'])) 
     59                power((x*self.params['length_l']),self.params['exponent_l'])) 
    6060        inten += self.params['background'] 
    6161 
  • sansmodels/src/sans/models/FractalCoreShellModel.py

    r8f20419d r18695bf  
    33from sans.models.CoreShellModel import CoreShellModel 
    44from scipy.special import gammaln 
    5 from math import exp, pow, sin, atan 
     5from math import exp, sin, atan 
     6from numpy import power 
    67from copy import deepcopy 
    78 
     
    7980        #calculate S(q) 
    8081        sq = Df*exp(gammaln(Df-1.0))*sin((Df-1.0)*atan(x*corr)) 
    81         sq /= pow((x*r0),Df) * pow((1.0 + 1.0/(x*corr*x*corr)),((Df-1)/2)) 
     82        sq /= power((x*r0),Df) * power((1.0 + 1.0/(x*corr*x*corr)),((Df-1)/2)) 
    8283        sq += 1.0 
    8384        return sq 
  • sansmodels/src/sans/models/TwoLorentzianModel.py

    r8f20419d r18695bf  
    55 
    66from sans.models.BaseComponent import BaseComponent 
    7 from math import pow 
     7from numpy import power 
    88 
    99class TwoLorentzianModel(BaseComponent): 
     
    5959        """ 
    6060        inten = self.params['scale_1']/(1.0 + \ 
    61                 pow((x*self.params['length_1']),self.params['exponent_1'])) 
     61                power((x*self.params['length_1']),self.params['exponent_1'])) 
    6262        inten += self.params['scale_2']/(1.0 + \ 
    63                 pow((x*self.params['length_2']),self.params['exponent_2'])) 
     63                power((x*self.params['length_2']),self.params['exponent_2'])) 
    6464        inten += self.params['background'] 
    6565 
  • sansmodels/src/sans/models/TwoPowerLawModel.py

    r8f20419d r18695bf  
    77 
    88from sans.models.BaseComponent import BaseComponent 
    9 from math import pow 
     9from numpy import power 
    1010 
    1111class TwoPowerLawModel(BaseComponent): 
     
    6565        qc= self.params['qc'] 
    6666        if(x<=qc): 
    67             inten = self.params['coef_A']*pow(x,-1.0*self.params['power1']) 
     67            inten = self.params['coef_A']*power(x,-1.0*self.params['power1']) 
    6868        else: 
    69             scale = self.params['coef_A']*pow(qc,-1.0*self.params['power1']) \ 
    70                                     / pow(qc,-1.0*self.params['power2']) 
    71             inten = scale*pow(x,-1.0*self.params['power2']) 
     69            scale = self.params['coef_A']*power(qc,-1.0*self.params['power1']) \ 
     70                                    / power(qc,-1.0*self.params['power2']) 
     71            inten = scale*power(x,-1.0*self.params['power2']) 
    7272        inten += self.params['background'] 
    7373 
  • sansmodels/src/sans/models/UnifiedPowerRgModel.py

    r29100cb r18695bf  
    11    
    22from sans.models.BaseComponent import BaseComponent 
    3 from math import pow,exp, sqrt 
     3from math import exp, sqrt 
     4from numpy import power 
    45from scipy.special import erf 
    56max_level_n = 7 
     
    7475        for ind in range(1,l_num+1): 
    7576            # get exp term 
    76             exp_now = exp(-pow(x*self.params['Rg%s'% ind],2)/3.0) 
     77            exp_now = exp(-power(x*self.params['Rg%s'% ind],2)/3.0) 
    7778            # get erf term 
    7879            erf_now = erf(x*self.params['Rg%s'% ind]/sqrt(6.0)) 
    7980            # get power term 
    80             pow_now = pow((erf_now*erf_now*erf_now/x),self.params['power%s'% ind]) 
     81            pow_now = power((erf_now*erf_now*erf_now/x),self.params['power%s'% ind]) 
    8182            # get next exp term only if it exists 
    8283            try: 
    83                 exp_next = exp(-pow(x*self.params['Rg%s'% (ind+1)],2)/3.0) 
     84                exp_next = exp(-power(x*self.params['Rg%s'% (ind+1)],2)/3.0) 
    8485            except: 
    8586                exp_next = 1.0 
Note: See TracChangeset for help on using the changeset viewer.