Ignore:
Timestamp:
Feb 24, 2017 9:39:00 AM (8 years ago)
Author:
GitHub <noreply@…>
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:
c221349
Parents:
2ffe241 (diff), cb05bfd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (02/24/17 09:39:00)
git-committer:
GitHub <noreply@…> (02/24/17 09:39:00)
Message:

Merge branch 'master' into sesans41

File:
1 edited

Legend:

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

    rd3911e3 r2ffe241  
    1313import logging 
    1414import sys 
    15  
     15import numpy as np  # type: ignore 
     16from numpy import pi, exp # type:ignore 
    1617from sasmodels.resolution import Slit1D, Pinhole1D 
     18from sasmodels.sesans import SesansTransform 
    1719from sasmodels.resolution2d import Pinhole2D 
     20from src.sas.sascalc.data_util.nxsunit import Converter 
    1821 
    1922def smear_selection(data, model = None): 
     
    3639    # Sanity check. If we are not dealing with a SAS Data1D 
    3740    # object, just return None 
     41    # This checks for 2D data (does not throw exception because fail is common) 
    3842    if  data.__class__.__name__ not in ['Data1D', 'Theory1D']: 
    3943        if data == None: 
     
    4145        elif data.dqx_data == None or data.dqy_data == None: 
    4246            return None 
    43         return PySmear2D(data, model) 
    44  
     47        return PySmear2D(data) 
     48    # This checks for 1D data with smearing info in the data itself (again, fail is likely; no exceptions) 
    4549    if  not hasattr(data, "dx") and not hasattr(data, "dxl")\ 
    4650         and not hasattr(data, "dxw"): 
     
    4852 
    4953    # Look for resolution smearing data 
     54    # This is the code that checks for SESANS data; it looks for the file loader 
     55    # TODO: change other sanity checks to check for file loader instead of data structure? 
     56    _found_sesans = False 
     57    #if data.dx is not None and data.meta_data['loader']=='SESANS': 
     58    if data.dx is not None and data.isSesans: 
     59        #if data.dx[0] > 0.0: 
     60        if numpy.size(data.dx[data.dx <= 0]) == 0: 
     61            _found_sesans = True 
     62        # if data.dx[0] <= 0.0: 
     63        if numpy.size(data.dx[data.dx <= 0]) > 0: 
     64            raise ValueError('one or more of your dx values are negative, please check the data file!') 
     65 
     66    if _found_sesans == True: 
     67        #Pre-compute the Hankel matrix (H) 
     68        qmax, qunits = data.sample.zacceptance 
     69        SElength = Converter(data._xunit)(data.x, "A") 
     70        zaccept = Converter(qunits)(qmax, "1/A"), 
     71        Rmax = 10000000 
     72        hankel = SesansTransform(data.x, SElength, zaccept, Rmax) 
     73        # Then return the actual transform, as if it were a smearing function 
     74        return PySmear(hankel, model, offset=0) 
     75 
    5076    _found_resolution = False 
    5177    if data.dx is not None and len(data.dx) == len(data.x): 
     
    89115    Wrapper for pure python sasmodels resolution functions. 
    90116    """ 
    91     def __init__(self, resolution, model): 
     117    def __init__(self, resolution, model, offset=None): 
    92118        self.model = model 
    93119        self.resolution = resolution 
    94         self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     120        if offset is None: 
     121            offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     122        self.offset = offset 
    95123 
    96124    def apply(self, iq_in, first_bin=0, last_bin=None): 
Note: See TracChangeset for help on using the changeset viewer.