Changeset 2f1a0dc in sasview for sansmodels


Ignore:
Timestamp:
May 27, 2010 11:16:29 AM (15 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:
beb374a
Parents:
06c7fcc
Message:

2d input for eval is now qr instead of list (qx,qr), this way we can use numpy.vertorize and it is much faster; So we don't support anisotropic 2D for python models.

File:
1 edited

Legend:

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

    r3080527 r2f1a0dc  
    7575            qy_prime = [ qy[0], qy[1], qy[2], ....]  
    7676             
     77            Then get 
     78            q = numpy.sqrt(qx_prime^2+qy_prime^2) 
     79             
     80            that is a qr in 1D array; 
     81            q = [q[0], q[1], q[2], ....]  
     82            Note: Due to 2D speed issue, no anisotropic scattering is supported for python models,  
     83            thus C-models should have their own evalDistribution methods. 
     84             
    7785            The method is then called the following way: 
    7886             
    79             evalDistribution([qx_prime, qy_prime]) 
     87            evalDistribution(q) 
     88            where q is a numpy array. 
    8089             
    8190            @param qdist: ndarray of scalar q-values or list [qx,qy] where qx,qy are 1D ndarrays  
     
    92101            qy = qdist[1] 
    93102             
    94             # Create output array 
    95             iq_array = numpy.zeros((len(qx))) 
    96              
    97             for i in range(len(qx)): 
    98                     iq_array[i] = self.runXY([qx[i],qy[i]]) 
     103            # calculate q_r component for 2D isotropic 
     104            q = numpy.sqrt(qx**2+qy**2) 
     105            # vectorize the model function runXY 
     106            v_model = numpy.vectorize(self.runXY,otypes=[float]) 
     107            # calculate the scattering 
     108            iq_array = v_model(q) 
     109 
    99110            return iq_array 
    100111                 
    101112        elif qdist.__class__.__name__ == 'ndarray': 
    102113                # We have a simple 1D distribution of q-values 
    103                 iq_array = numpy.zeros(len(qdist)) 
    104                 for i in range(len(qdist)): 
    105                     iq_array[i] = self.runXY(qdist[i]) 
     114                v_model = numpy.vectorize(self.runXY,otypes=[float]) 
     115                iq_array = v_model(qdist) 
     116 
    106117                return iq_array 
    107118             
     
    110121            mesg += " or a list [qx,qy] where qx,qy are 2D ndarrays." 
    111122            raise RuntimeError, mesg 
     123         
     124     
    112125     
    113126    def clone(self): 
Note: See TracChangeset for help on using the changeset viewer.