Changeset 5b5ea20 in sasmodels
- Timestamp:
- Oct 30, 2017 12:55:42 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 904cd9c
- Parents:
- 87a6591
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
explore/jitter.py
r87a6591 r5b5ea20 197 197 return Rz(longitude)*Ry(latitude) 198 198 def weight(theta_i, phi_j, wi, wj): 199 # Weighting for each point comes from the integral: 200 # \int\int I(q, lat, log) sin(lat) dlat dlog 201 # We are doing a conformal mapping from disk to sphere, so we need 202 # a change of variables g(theta, phi) -> (lat, long): 203 # lat, long = sqrt(theta^2 + phi^2), arctan(phi/theta) 204 # giving: 205 # dtheta dphi = det(J) dlat dlong 206 # where J is the jacobian from the partials of g. Using 207 # R = sqrt(theta^2 + phi^2), 208 # then 209 # J = [[x/R, Y/R], -y/R^2, x/R^2]] 210 # and 211 # det(J) = 1/R 212 # with the final integral being: 213 # \int\int I(q, theta, phi) sin(R)/R dtheta dphi 214 # 215 # This does approximately the right thing, decreasing the weight 216 # of each point as you go farther out on the disk, but it hasn't 217 # yet been checked against the 1D integral results. Prior 218 # to declaring this "good enough" and checking that integrals 219 # work in practice, we will examine alternative mappings. 220 # 221 # The issue is that the mapping does not support the case of free 222 # rotation about a single axis correctly, with a small deviation 223 # in the orthogonal axis independent of the first axis. Like the 224 # usual polar coordiates integration, the integrated sections 225 # form wedges, though at least in this case the wedge cuts through 226 # the entire sphere, and treats theta and phi identically. 199 227 latitude = sqrt(theta_i**2 + phi_j**2) 200 w = wi*wj if latitude < 180 else 0201 return w 228 w = sin(radians(latitude))/latitude if latitude != 0 else 1 229 return w*wi*wj if latitude < 180 else 0 202 230 elif PROJECTION == 'azimuthal_equal_area': 203 231 # https://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection … … 209 237 return Rz(longitude)*Ry(latitude) 210 238 def weight(theta_i, phi_j, wi, wj): 211 R= sqrt(theta_i**2 + phi_j**2)212 return wi*wj if R <= 180 else 0213 #return wi*wj if latitude <=180 else 0239 latitude = sqrt(theta_i**2 + phi_j**2) 240 w = sin(radians(latitude))/latitude if latitude != 0 else 1 241 return w*wi*wj if latitude < 180 else 0 214 242 elif SCALED_PHI == 10: # random thrashing 215 243 def rotate(theta_i, phi_j): … … 234 262 for wi, theta_i in zip(weights, dtheta*t) 235 263 for wj, phi_j in zip(weights, dphi*t)]) 264 #print(max(w), min(w), min(w[w>0])) 236 265 points = points[:, w>0] 237 266 w = w[w>0] 267 w /= max(w) 238 268 239 269 if 0: # Kent distribution … … 504 534 505 535 ## use gaussian distribution unless testing integration 506 #dist = 'rectangle'507 dist = 'gaussian'536 dist = 'rectangle' 537 #dist = 'gaussian' 508 538 509 539 ## initial view
Note: See TracChangeset
for help on using the changeset viewer.