Changes in / [a80e64c:997d4eb] in sasmodels
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/direct_model.py
r4cc161e r0444c02 31 31 from . import resolution2d 32 32 from .details import make_kernel_args, dispersion_mesh 33 from sas.sasgui.perspectives.fitting.fitpage import FitPage 33 34 34 35 try: … … 193 194 # interpret data 194 195 if hasattr(data, 'lam'): 196 #if not FitPage.no_transform.GetValue(): #if the no_transform radio button is not active DOES NOT WORK! not active before fitting 195 197 self.data_type = 'sesans' 196 198 elif hasattr(data, 'qx_data'): -
sasmodels/resolution.py
r2b3a1bd reb8a82e 9 9 from numpy import sqrt, log, log10, exp, pi # type: ignore 10 10 import numpy as np # type: ignore 11 12 from sasmodels import sesans 11 13 12 14 __all__ = ["Resolution", "Perfect1D", "Pinhole1D", "Slit1D", … … 43 45 raise NotImplementedError("Subclass does not define the apply function") 44 46 45 46 47 class Perfect1D(Resolution): 47 48 """ … … 56 57 return theory 57 58 59 60 class SESANS1D(Resolution): 61 62 def __init__(self, data, q_calc): 63 self.q = data.x 64 self.data = data 65 self.q_calc = q_calc 66 67 def apply(self, theory): 68 return sesans.transform(self.data, self.q_calc, theory, None, None) 58 69 59 70 class Pinhole1D(Resolution): -
sasmodels/sesans.py
r7ae2b7f r3023268 15 15 from numpy import pi, exp # type: ignore 16 16 from scipy.special import jv as besselj 17 #from sas.sasgui.perspectives.fitting.fitpage import FitPage 17 18 #import direct_model.DataMixin as model 18 19 … … 59 60 (2016-03-19: currently controlled from parameters script) 60 61 nqmono is the number of q vectors to be used for the detector integration 61 """62 nqmono = len(qmono)63 if nqmono == 0:62 qmono are the detector limits: can be a 1D or 2D array (depending on Q-limit or Qx,Qy limits) 63 """ 64 if qmono == None: 64 65 result = call_hankel(data, q_calc, Iq_calc) 65 elif nqmono == 1:66 q = qmono[0]67 result = call_HankelAccept(data, q_calc, Iq_calc, q, Iq_mono)68 66 else: 69 Qx, Qy = [qmono[0], qmono[1]] 70 Qx = np.reshape(Qx, nqx, nqy) 71 Qy = np.reshape(Qy, nqx, nqy) 72 Iq_mono = np.reshape(Iq_mono, nqx, nqy) 73 qx = Qx[0, :] 74 qy = Qy[:, 0] 75 result = call_Cosine2D(data, q_calc, Iq_calc, qx, qy, Iq_mono) 67 nqmono = len(qmono) 68 if nqmono == 0: # if radiobutton hankel is active 69 #if FitPage.hankel.GetValue(): 70 result = call_hankel(data, q_calc, Iq_calc) 71 elif nqmono == 1: 72 q = qmono[0] 73 result = call_HankelAccept(data, q_calc, Iq_calc, q, Iq_mono) 74 else: #if radiobutton Cosine is active 75 Qx, Qy = [qmono[0], qmono[1]] 76 Qx = np.reshape(Qx, nqx, nqy) 77 Qy = np.reshape(Qy, nqx, nqy) 78 Iq_mono = np.reshape(Iq_mono, nqx, nqy) 79 qx = Qx[0, :] 80 qy = Qy[:, 0] 81 result = call_Cosine2D(data, q_calc, Iq_calc, qx, qy, Iq_mono) 76 82 77 83 return result 78 84 79 85 def call_hankel(data, q_calc, Iq_calc): 80 return hankel((data.x, data.x_unit), 81 (data.lam, data.lam_unit), 82 (data.sample.thickness, 83 data.sample.thickness_unit), 84 q_calc, Iq_calc) 86 # data.lam_unit='nm' 87 #return hankel((data.x, data.x_unit), 88 # (data.lam, data.lam_unit), 89 # (data.sample.thickness, 90 # data.sample.thickness_unit), 91 # q_calc, Iq_calc) 92 93 return hankel((data.x, data._xunit), q_calc, Iq_calc) 85 94 86 95 def call_HankelAccept(data, q_calc, Iq_calc, q_mono, Iq_mono): … … 166 175 P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) 167 176 168 def hankel(SElength, wavelength, thickness, q, Iq): 177 #def hankel(SElength, wavelength, thickness, q, Iq): 178 def hankel(SElength, q, Iq): 169 179 r""" 170 180 Compute the expected SESANS polarization for a given SANS pattern. … … 189 199 190 200 from sas.sascalc.data_util.nxsunit import Converter 191 wavelength = Converter(wavelength[1])(wavelength[0],"A")192 thickness = Converter(thickness[1])(thickness[0],"A")193 Iq = Converter("1/cm")(Iq,"1/A") # All models default to inverse centimeters201 #wavelength = Converter(wavelength[1])(wavelength[0],"A") 202 #thickness = Converter(thickness[1])(thickness[0],"A") 203 #Iq = Converter("1/cm")(Iq,"1/A") # All models default to inverse centimeters 194 204 SElength = Converter(SElength[1])(SElength[0],"A") 195 205 196 206 G = np.zeros_like(SElength, 'd') 197 #==============================================================================198 # Hankel Transform method if "wavelength" is a scalar; mono-chromatic SESANS199 #==============================================================================200 207 for i, SElength_i in enumerate(SElength): 201 208 integral = besselj(0, q*SElength_i)*Iq*q 202 209 G[i] = np.sum(integral) 203 G0 = np.sum(Iq*q) 210 G0 = np.sum(Iq*q) #relation to ksi? For generalization to all models 204 211 205 212 # [m^-1] step size in q, needed for integration … … 210 217 G0 = np.sum(Iq*q)*dq*2*np.pi 211 218 212 P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) 219 #P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) 220 P = (G-G0)/(4*pi**2) 221 #P=G-G0 213 222 214 223 return P
Note: See TracChangeset
for help on using the changeset viewer.