Changeset ac995be in sasmodels
- Timestamp:
- Jun 12, 2018 10:29:02 AM (7 years ago)
- Branches:
- master
- Children:
- b032200
- Parents:
- d7af1c6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sesans.py
rd7af1c6 rac995be 14 14 import numpy as np # type: ignore 15 15 from numpy import pi # type: ignore 16 from scipy.special import j 0, j116 from scipy.special import j1 17 17 18 18 … … 39 39 40 40 # transform arrays 41 _H = None # type: np.ndarray42 _H0 = None # type: np.ndarray41 _H = None # type: np.ndarray 42 _H0 = None # type: np.ndarray 43 43 44 44 def __init__(self, z, SElength, lam, zaccept, Rmax): 45 45 # type: (np.ndarray, float, float) -> None 46 #import logging; logging.info("creating SESANS transform")47 46 self.q = z 48 47 self._set_hankel(SElength, lam, zaccept, Rmax) … … 52 51 G0 = np.dot(self._H0, Iq) 53 52 G = np.dot(self._H.T, Iq) 53 G0 = G[0] # FIXME: This is a kludge 54 54 P = G - G0 55 55 return P … … 57 57 def _set_hankel(self, SElength, lam, zaccept, Rmax): 58 58 # type: (np.ndarray, float, float) -> None 59 # Force float32 arrays, otherwise run into memory problems on some machines 59 # Force float32 arrays, otherwise run into memory problems on 60 # some machines 60 61 SElength = np.asarray(SElength, dtype='float32') 61 62 … … 64 65 q_min = 0.1 * 2*pi / (np.size(SElength) * SElength[-1]) 65 66 # q = np.arange(q_min, q_max, q_min, dtype='float32') 66 q = np.exp(np.arange(np.log(q_min), np.log(q_max), np.log(2), 67 dtype=np.float32)) 68 q = np.hstack([0], q) 67 # q = np.exp(np.arange(np.log(q_min), np.log(q_max), np.log(2), 68 # dtype=np.float32)) 69 q = np.exp(np.linspace(np.log(q_min), np.log(q_max), 10*SElength.size, 70 dtype=np.float32)) 71 q = np.hstack([[0], q]) 69 72 70 H0 = np.pi * (q[1:]**2 - q[ -1]**2)73 H0 = np.pi * (q[1:]**2 - q[:-1]**2) * (q[1:] - q[:-1]) 71 74 72 75 # repq = np.tile(q, (SElength.size, 1)).T 73 76 H = np.outer(q, SElength) 74 77 j1(H, out=H) 75 H *= q 78 H *= q.reshape((-1, 1)) 76 79 H = H[1:] - H[:-1] 77 80 H *= 2 * np.pi / SElength 78 81 79 82 lam = np.asarray(lam, dtype=np.float32) 80 reptheta = np.outer(q , lam)83 reptheta = np.outer(q[1:], lam) 81 84 reptheta /= np.float32(2*np.pi) 82 85 np.arcsin(reptheta, out=reptheta) 83 86 # reptheta = np.arcsin(repq*replam/2*np.pi) 84 87 mask = reptheta > zaccept 85 H[mask] = 088 # H[mask] = 0 86 89 87 90 # H = np.zeros((q.size, SElength.size), dtype=np.float32) 88 91 # H0 = q * 0 89 assert(H.shape == (q.size , SElength.size))92 assert(H.shape == (q.size-1, SElength.size)) 90 93 91 self.q_calc = q 94 self.q_calc = q[1:] 92 95 self._H, self._H0 = H, H0
Note: See TracChangeset
for help on using the changeset viewer.