Changes in / [a80e64c:997d4eb] in sasmodels


Ignore:
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/direct_model.py

    r4cc161e r0444c02  
    3131from . import resolution2d 
    3232from .details import make_kernel_args, dispersion_mesh 
     33from sas.sasgui.perspectives.fitting.fitpage import FitPage 
    3334 
    3435try: 
     
    193194        # interpret data 
    194195        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 
    195197            self.data_type = 'sesans' 
    196198        elif hasattr(data, 'qx_data'): 
  • sasmodels/resolution.py

    r2b3a1bd reb8a82e  
    99from numpy import sqrt, log, log10, exp, pi  # type: ignore 
    1010import numpy as np  # type: ignore 
     11 
     12from sasmodels import sesans 
    1113 
    1214__all__ = ["Resolution", "Perfect1D", "Pinhole1D", "Slit1D", 
     
    4345        raise NotImplementedError("Subclass does not define the apply function") 
    4446 
    45  
    4647class Perfect1D(Resolution): 
    4748    """ 
     
    5657        return theory 
    5758 
     59 
     60class 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) 
    5869 
    5970class Pinhole1D(Resolution): 
  • sasmodels/sesans.py

    r7ae2b7f r3023268  
    1515from numpy import pi, exp  # type: ignore 
    1616from scipy.special import jv as besselj 
     17#from sas.sasgui.perspectives.fitting.fitpage import FitPage 
    1718#import direct_model.DataMixin as model 
    1819         
     
    5960    (2016-03-19: currently controlled from parameters script) 
    6061    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: 
    6465        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) 
    6866    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) 
    7682 
    7783    return result 
    7884 
    7985def 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) 
    8594   
    8695def call_HankelAccept(data, q_calc, Iq_calc, q_mono, Iq_mono): 
     
    166175    P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) 
    167176     
    168 def hankel(SElength, wavelength, thickness, q, Iq): 
     177#def hankel(SElength, wavelength, thickness, q, Iq): 
     178def hankel(SElength, q, Iq): 
    169179    r""" 
    170180    Compute the expected SESANS polarization for a given SANS pattern. 
     
    189199 
    190200    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 centimeters 
     201    #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 
    194204    SElength = Converter(SElength[1])(SElength[0],"A") 
    195205 
    196206    G = np.zeros_like(SElength, 'd') 
    197 #============================================================================== 
    198 #     Hankel Transform method if "wavelength" is a scalar; mono-chromatic SESANS 
    199 #============================================================================== 
    200207    for i, SElength_i in enumerate(SElength): 
    201208        integral = besselj(0, q*SElength_i)*Iq*q 
    202209        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 
    204211 
    205212    # [m^-1] step size in q, needed for integration 
     
    210217    G0 = np.sum(Iq*q)*dq*2*np.pi 
    211218 
    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 
    213222 
    214223    return P 
Note: See TracChangeset for help on using the changeset viewer.