Changeset 26b848d in sasmodels
- Timestamp:
- Nov 20, 2016 7:39:44 AM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 777d369
- Parents:
- 589b740
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/resolution.py
r589b740 r26b848d 11 11 12 12 from sasmodels import sesans 13 from sasmodels.sesans import SesansTransform as SesansTransform 13 14 14 15 __all__ = ["Resolution", "Perfect1D", "Pinhole1D", "Slit1D", … … 57 58 return theory 58 59 59 60 class SESANS1D(Resolution):61 def __init__(self, data, H0, H, q_calc):62 self.q = data.x63 self.H0 = H064 self.H = H65 self.data=data66 self.q_calc = q_calc67 def apply(self, theory):68 return sesans.SesansTransform.apply(theory)69 #return sesans.hankeltrafo(self.H0, self.H, theory)70 71 """72 def __init__(self, data, q_calc):73 self.q = data.x74 self.data = data75 self.q_calc = q_calc76 77 def apply(self, theory):78 return sesans.transform(self.data, self.q_calc, theory, None, None)79 """80 60 class Pinhole1D(Resolution): 81 61 r""" -
sasmodels/sesans.py
r589b740 r26b848d 14 14 import numpy as np # type: ignore 15 15 from numpy import pi, exp # type: ignore 16 #from scipy.special import jv as besselj17 16 from scipy.special import j0 18 17 #from mpmath import j0 as j0 19 #from mpmath import besselj20 #from mpmath import mpf21 from src.sas.sascalc.data_util.nxsunit import Converter22 #from sas.sasgui.perspectives.fitting.fitpage import FitPage23 #import direct_model.DataMixin as model24 18 25 def make_q(q_max, Rmax):26 r"""27 Return a $q$ vector suitable for SESANS covering from $2\pi/ (10 R_{\max})$28 to $q_max$. This is the integration range of the Hankel transform; bigger range and29 more points makes a better numerical integration.30 Smaller q_min will increase reliable spin echo length range.31 Rmax is the "radius" of the largest expected object and can be set elsewhere.32 q_max is determined by the acceptance angle of the SESANS instrument.33 """34 from sas.sascalc.data_util.nxsunit import Converter35 36 q_min = dq = 0.1 * 2*pi / Rmax37 return np.arange(q_min,38 Converter(q_max[1])(q_max[0],39 units="1/A"),40 dq)41 42 def Hankelconstructor(data):43 Rmax = 100000044 #Rmax = #value in text box?45 q_calc = make_q(data.sample.zacceptance, Rmax)46 SElength = Converter(data._xunit)(data.x, "A")47 dq = q_calc[1] - q_calc[0]48 H0 = dq / (2 * pi) * q_calc49 repSE, repq = np.meshgrid(SElength,q_calc)50 repq=np.array(repq,dtype='f')51 repSE=np.array(repSE,dtype='f')52 H = dq / (2 * pi) * j0(repSE*repq)*repq53 return H0, H, q_calc54 55 def hankeltrafo(H0, H, Iq_calc):56 G0 = np.dot(H0, Iq_calc)57 G = np.dot(H.T, Iq_calc)58 P = G - G059 return P # This is the logarithmic Polarization, not the linear one as found in Andersson2008!60 61 62 19 class SesansTransform(object): 63 20 #: Set of spin-echo lengths in the measured data 64 SE length= None # type: np.ndarray21 SE = None # type: np.ndarray 65 22 #: Maximum acceptance of scattering vector in the spin echo encoding dimension (for ToF: Q of min(R) and max(lam)) 66 23 zaccept = None # type: float … … 89 46 q_min = dq = 0.1 * 2*pi / self.Rmax 90 47 q_max = self.zaccept 91 q=np.arange(q_min, q_max)48 q=np.arange(q_min, q_max, q_min) 92 49 self.q = q 93 50 self.dq = dq … … 100 57 101 58 H0 = dq / (2 * pi) * q 102 repSE, repq = np.meshgrid(SElength, q)103 repq=np.array(repq,dtype='f ')104 repSE=np.array(repSE,dtype='f ')59 repSE, repq = np.meshgrid(SElength, q) 60 repq=np.array(repq,dtype='float32') 61 repSE=np.array(repSE,dtype='float32') 105 62 H = dq / (2 * pi) * j0(repSE*repq)*repq 106 63 107 64 self._H, self._H0 = H, H0 108 65 66 class SESANS1D(SesansTransform): 67 def __init__(self, data, _H0, _H, q_calc): 68 # x values of the data (Sasview requires these to be named "q") 69 self.q = data.x 70 self._H0 = _H0 71 self._H = _H 72 # Pysmear does some checks on the smearer object, these checks require the "data" object... 73 self.data=data 74 # q values of the SAS model 75 self.q_calc = q_calc # These are the MODEL's q values used by the smearer (in this case: the Hankel transform) 76 def apply(self, theory): 77 return SesansTransform.apply(self,theory)
Note: See TracChangeset
for help on using the changeset viewer.