Ignore:
File:
1 edited

Legend:

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

    rf8aa738 r392056d  
    55#This software was developed by the University of Tennessee as part of the 
    66#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation.  
     7#project funded by the US National Science Foundation. 
    88#See the license text in license.txt 
    99#copyright 2008, University of Tennessee 
     
    1313import logging 
    1414import sys 
     15from sasmodels import sesans 
    1516 
    16 from sasmodels.resolution import Slit1D, Pinhole1D 
     17from sasmodels.resolution import Slit1D, Pinhole1D, SESANS1D 
    1718from sasmodels.resolution2d import Pinhole2D 
    1819 
     
    4849 
    4950    # Look for resolution smearing data 
     51    _found_sesans = False 
     52    if data.dx is not None and data.meta_data['loader']=='SESANS': 
     53        if data.dx[0] > 0.0: 
     54            _found_sesans = True 
     55 
     56    if _found_sesans == True: 
     57        return sesans_smear(data, model) 
     58 
    5059    _found_resolution = False 
    5160    if data.dx is not None and len(data.dx) == len(data.x): 
     
    92101        self.model = model 
    93102        self.resolution = resolution 
    94         self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     103        if hasattr(self.resolution, 'data'): 
     104            if self.resolution.data.meta_data['loader'] == 'SESANS': 
     105                self.offset = 0 
     106            # This is default behaviour, for future resolution/transform functions this needs to be revisited. 
     107            else: 
     108                self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     109        else: 
     110            self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     111 
     112        #self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
    95113 
    96114    def apply(self, iq_in, first_bin=0, last_bin=None): 
     
    126144        q[first:last+1]. 
    127145        """ 
     146 
    128147        q = self.resolution.q 
    129148        first = numpy.searchsorted(q, q_min) 
     
    142161    width = data.dx if data.dx is not None else 0 
    143162    return PySmear(Pinhole1D(q, width), model) 
     163 
     164def sesans_smear(data, model=None): 
     165    #This should be calculated characteristic length scale 
     166    #Probably not a data prameter either 
     167    #Need function to calculate this based on model 
     168    #Here assume a number 
     169    Rmax = 1000000 
     170    q_calc = sesans.make_q(data.sample.zacceptance, Rmax) 
     171    return PySmear(SESANS1D(data,q_calc),model) 
Note: See TracChangeset for help on using the changeset viewer.