Changeset ba91f71 in sasview


Ignore:
Timestamp:
Apr 10, 2017 9:37:39 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
costrafo411
Children:
9f59333
Parents:
3fd3c3a3
Message:

oriented sesans: set up smearer as a 1D smearer for 2D data (won't work yet)

File:
1 edited

Legend:

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

    r3fd3c3a3 rba91f71  
    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 
     
    1818 
    1919from sasmodels.resolution import Slit1D, Pinhole1D 
    20 from sasmodels.sesans import SesansTransform 
     20from sasmodels.sesans import SesansTransform, OrientedSesansTransform 
    2121from sasmodels.resolution2d import Pinhole2D 
    2222from .nxsunit import Converter 
     
    7373        Rmax = 10000000 
    7474        # data must have the isoriented flag here! 
    75         coshankel = SesansTransform(data.x, SElength, zaccept, Rmax) 
    7675        # Then return the actual transform, as if it were a smearing function 
    77         if data.isoriented: 
    78             return PySmear2D(coshankel) 
     76        if getattr(data, 'isoriented', False): 
     77            costransform = OrientedSesansTransform(data.x, SElength, zaccept, Rmax) 
     78            return PySmear(costransform, model, offset=0) 
    7979        else: 
    80             return PySmear(coshankel, model, offset=0) 
     80            hankel = SesansTransform(data.x, SElength, zaccept, Rmax) 
     81            return PySmear(hankel, model, offset=0) 
    8182 
    8283    _found_resolution = False 
     
    138139        first_bin:last_bin set to the resolution smeared values. 
    139140        """ 
    140         if last_bin is None: last_bin = len(iq_in) 
    141         start, end = first_bin + self.offset, last_bin + self.offset 
    142141        q_calc = self.resolution.q_calc 
    143         iq_calc = numpy.empty_like(q_calc) 
    144         if start > 0: 
    145             iq_calc[:start] = self.model.evalDistribution(q_calc[:start]) 
    146         if end+1 < len(q_calc): 
    147             iq_calc[end+1:] = self.model.evalDistribution(q_calc[end+1:]) 
    148         iq_calc[start:end+1] = iq_in[first_bin:last_bin+1] 
     142        if isinstance(q_calc, tuple): 
     143            # We are 2D -> 1D! 
     144            iq_calc = self.model.evalDistribution(q_calc) 
     145        else: 
     146            if last_bin is None: last_bin = len(iq_in) 
     147            start, end = first_bin + self.offset, last_bin + self.offset 
     148            iq_calc = numpy.empty_like(q_calc) 
     149            if start > 0: 
     150                iq_calc[:start] = self.model.evalDistribution(q_calc[:start]) 
     151            if end+1 < len(q_calc): 
     152                iq_calc[end+1:] = self.model.evalDistribution(q_calc[end+1:]) 
     153            iq_calc[start:end+1] = iq_in[first_bin:last_bin+1] 
    149154        smeared = self.resolution.apply(iq_calc) 
    150155        return smeared 
Note: See TracChangeset for help on using the changeset viewer.