Ignore:
Timestamp:
Nov 9, 2016 3:58:30 PM (8 years ago)
Author:
jhbakker
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
f5e226c9
Parents:
9087214
Message:

Experimenting with optimization to Hankel trafo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/data_util/qsmearing.py

    r392056d r4581ac9  
    1515from sasmodels import sesans 
    1616 
     17import numpy as np  # type: ignore 
     18from numpy import pi, exp  # type: ignore 
     19from scipy.special import jv as besselj 
     20 
    1721from sasmodels.resolution import Slit1D, Pinhole1D, SESANS1D 
    1822from sasmodels.resolution2d import Pinhole2D 
     23from src.sas.sascalc.data_util.nxsunit import Converter 
     24 
    1925 
    2026def smear_selection(data, model = None): 
     
    3743    # Sanity check. If we are not dealing with a SAS Data1D 
    3844    # object, just return None 
     45 
     46    # This checks for 2D data (does not throw exception because fail is common) 
    3947    if  data.__class__.__name__ not in ['Data1D', 'Theory1D']: 
    4048        if data == None: 
     
    4351            return None 
    4452        return Pinhole2D(data) 
    45  
     53    # This checks for 1D data with smearing info in the data itself (again, fail is likely; no exceptions) 
    4654    if  not hasattr(data, "dx") and not hasattr(data, "dxl")\ 
    4755         and not hasattr(data, "dxw"): 
     
    4957 
    5058    # Look for resolution smearing data 
     59    # This is the code that checks for SESANS data; it looks for the file loader 
     60    # TODO: change other sanity checks to check for file loader instead of data structure? 
    5161    _found_sesans = False 
    5262    if data.dx is not None and data.meta_data['loader']=='SESANS': 
     
    5565 
    5666    if _found_sesans == True: 
    57         return sesans_smear(data, model) 
     67        #Pre-computing the Hankel matrix 
     68        Rmax = 1000000 
     69        q_calc = sesans.make_q(data.sample.zacceptance, Rmax) 
     70        SElength = Converter(data._xunit)(data.x, "A") 
     71        dq = q_calc[1] - q_calc[0] 
     72        H0 = dq / (2 * pi) * q_calc 
     73        H = dq / (2 * pi) * besselj(0, np.outer(q_calc, SElength)) 
     74 
     75        return PySmear(SESANS1D(data, H0, H, q_calc), model) 
    5876 
    5977    _found_resolution = False 
     
    169187    Rmax = 1000000 
    170188    q_calc = sesans.make_q(data.sample.zacceptance, Rmax) 
    171     return PySmear(SESANS1D(data,q_calc),model) 
     189    SElength=Converter(data._xunit)(data.x, "A") 
     190    #return sesans.HankelTransform(q_calc, SElength) 
     191    #Old return statement, running through the smearer 
     192    #return PySmear(SESANS1D(data,q_calc),model) 
Note: See TracChangeset for help on using the changeset viewer.