Changeset eb8a82e in sasmodels


Ignore:
Timestamp:
Oct 10, 2016 4:53:04 PM (8 years ago)
Author:
jhbakker
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3023268
Parents:
0ae0f9a
Message:

SESANS mods, This is not a stable version!!

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/resolution.py

    r0ae0f9a 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", 
     
    5961 
    6062    def __init__(self, data, q_calc): 
     63        self.q = data.x 
    6164        self.data = data 
    6265        self.q_calc = q_calc 
  • sasmodels/sesans.py

    r0444c02 reb8a82e  
    1515from numpy import pi, exp  # type: ignore 
    1616from scipy.special import jv as besselj 
    17 from sas.sasgui.perspectives.fitting.fitpage import FitPage 
     17#from sas.sasgui.perspectives.fitting.fitpage import FitPage 
    1818#import direct_model.DataMixin as model 
    1919         
     
    6060    (2016-03-19: currently controlled from parameters script) 
    6161    nqmono is the number of q vectors to be used for the detector integration 
    62     """ 
    63     nqmono = len(qmono) 
    64     #if nqmono == 0 # if radiobutton hankel is active 
    65     if FitPage.hankel.GetValue(): 
     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: 
    6665        result = call_hankel(data, q_calc, Iq_calc) 
    67     elif nqmono == 1: 
    68         q = qmono[0] 
    69         result = call_HankelAccept(data, q_calc, Iq_calc, q, Iq_mono) 
    70     else: #if radiobutton Cosine is active 
    71         Qx, Qy = [qmono[0], qmono[1]] 
    72         Qx = np.reshape(Qx, nqx, nqy) 
    73         Qy = np.reshape(Qy, nqx, nqy) 
    74         Iq_mono = np.reshape(Iq_mono, nqx, nqy) 
    75         qx = Qx[0, :] 
    76         qy = Qy[:, 0] 
    77         result = call_Cosine2D(data, q_calc, Iq_calc, qx, qy, Iq_mono) 
     66    else: 
     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) 
    7882 
    7983    return result 
    8084 
    8185def call_hankel(data, q_calc, Iq_calc): 
    82     return hankel((data.x, data.x_unit), 
    83                   (data.lam, data.lam_unit), 
    84                   (data.sample.thickness, 
    85                    data.sample.thickness_unit), 
    86                   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) 
    8794   
    8895def call_HankelAccept(data, q_calc, Iq_calc, q_mono, Iq_mono): 
     
    168175    P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) 
    169176     
    170 def hankel(SElength, wavelength, thickness, q, Iq): 
     177#def hankel(SElength, wavelength, thickness, q, Iq): 
     178def hankel(SElength, q, Iq): 
    171179    r""" 
    172180    Compute the expected SESANS polarization for a given SANS pattern. 
     
    191199 
    192200    from sas.sascalc.data_util.nxsunit import Converter 
    193     wavelength = Converter(wavelength[1])(wavelength[0],"A") 
    194     thickness = Converter(thickness[1])(thickness[0],"A") 
     201    #wavelength = Converter(wavelength[1])(wavelength[0],"A") 
     202    #thickness = Converter(thickness[1])(thickness[0],"A") 
    195203    Iq = Converter("1/cm")(Iq,"1/A") # All models default to inverse centimeters 
    196204    SElength = Converter(SElength[1])(SElength[0],"A") 
     
    203211        integral = besselj(0, q*SElength_i)*Iq*q 
    204212        G[i] = np.sum(integral) 
    205     G0 = np.sum(Iq*q) 
     213    G0 = np.sum(Iq*q) #relation to ksi? For generalization to all models 
    206214 
    207215    # [m^-1] step size in q, needed for integration 
     
    212220    G0 = np.sum(Iq*q)*dq*2*np.pi 
    213221 
    214     P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) 
     222    #P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) 
     223    P = (G-G0)/(4*pi**2) 
    215224 
    216225    return P 
Note: See TracChangeset for help on using the changeset viewer.