Changeset 2f1a0dc in sasview for sansmodels/src/sans/models
- Timestamp:
- May 27, 2010 11:16:29 AM (14 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/BaseComponent.py
r3080527 r2f1a0dc 75 75 qy_prime = [ qy[0], qy[1], qy[2], ....] 76 76 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 77 85 The method is then called the following way: 78 86 79 evalDistribution([qx_prime, qy_prime]) 87 evalDistribution(q) 88 where q is a numpy array. 80 89 81 90 @param qdist: ndarray of scalar q-values or list [qx,qy] where qx,qy are 1D ndarrays … … 92 101 qy = qdist[1] 93 102 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 99 110 return iq_array 100 111 101 112 elif qdist.__class__.__name__ == 'ndarray': 102 113 # 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 106 117 return iq_array 107 118 … … 110 121 mesg += " or a list [qx,qy] where qx,qy are 2D ndarrays." 111 122 raise RuntimeError, mesg 123 124 112 125 113 126 def clone(self):
Note: See TracChangeset
for help on using the changeset viewer.