Ignore:
Timestamp:
Apr 15, 2008 8:08:40 AM (16 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:
3de85b8
Parents:
5aa3bbd
Message:

Modified to testing and modified according to testing results

File:
1 edited

Legend:

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

    r3db3895 r36948c92  
    3838        ## Parameter details [units, min, max] 
    3939        self.details = {} 
    40         self.details['m']           = ['', None, None ] 
     40        self.details['m']           = ['', 0,    None] 
    4141        self.details['scale']       = ['', None, None] 
    4242        self.details['background']  = ['', None, None] 
     
    4747            
    4848        """ 
    49         return self.params['scale']*math.pow(x ,-self.params['m'])\ 
     49        if x<0 and self.params['m']>0: 
     50            raise ValueError, "negative number cannot be raised to a fractional power" 
     51         
     52        return self.params['scale']*math.pow(x ,-1.0*self.params['m'])\ 
    5053                + self.params['background'] 
    5154        
    52     
    5355    def run(self, x = 0.0): 
    5456        """ Evaluate the model 
     
    5759        """ 
    5860        if x.__class__.__name__ == 'list': 
    59             return self._PowerLaw(x[0]*math.cos(x[1]))*self._PowerLaw(x[0]*math.sin(x[1])) 
     61            # Take absolute value of Q, since this model is really meant to 
     62            # be defined in 1D for a given length of Q 
     63            qx = math.fabs(x[0]*math.cos(x[1])) 
     64            qy = math.fabs(x[0]*math.sin(x[1])) 
     65            return self._PowerLaw(qx)*self._PowerLaw(qy) 
    6066        elif x.__class__.__name__ == 'tuple': 
    6167            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
Note: See TracChangeset for help on using the changeset viewer.