Changes in src/sas/sascalc/data_util/qsmearing.py [2ffe241:0d64713] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/qsmearing.py
r2ffe241 r0d64713 13 13 import logging 14 14 import sys 15 import numpy as np # type: ignore 16 from numpy import pi, exp # type:ignore 15 17 16 from sasmodels.resolution import Slit1D, Pinhole1D 18 from sasmodels.sesans import SesansTransform19 17 from sasmodels.resolution2d import Pinhole2D 20 from src.sas.sascalc.data_util.nxsunit import Converter21 18 22 19 def smear_selection(data, model = None): … … 39 36 # Sanity check. If we are not dealing with a SAS Data1D 40 37 # object, just return None 41 # This checks for 2D data (does not throw exception because fail is common)42 38 if data.__class__.__name__ not in ['Data1D', 'Theory1D']: 43 39 if data == None: … … 45 41 elif data.dqx_data == None or data.dqy_data == None: 46 42 return None 47 return PySmear2D(data )48 # This checks for 1D data with smearing info in the data itself (again, fail is likely; no exceptions) 43 return PySmear2D(data, model) 44 49 45 if not hasattr(data, "dx") and not hasattr(data, "dxl")\ 50 46 and not hasattr(data, "dxw"): … … 52 48 53 49 # Look for resolution smearing data 54 # This is the code that checks for SESANS data; it looks for the file loader55 # TODO: change other sanity checks to check for file loader instead of data structure?56 _found_sesans = False57 #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 = True62 # 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.zacceptance69 SElength = Converter(data._xunit)(data.x, "A")70 zaccept = Converter(qunits)(qmax, "1/A"),71 Rmax = 1000000072 hankel = SesansTransform(data.x, SElength, zaccept, Rmax)73 # Then return the actual transform, as if it were a smearing function74 return PySmear(hankel, model, offset=0)75 76 50 _found_resolution = False 77 51 if data.dx is not None and len(data.dx) == len(data.x): … … 115 89 Wrapper for pure python sasmodels resolution functions. 116 90 """ 117 def __init__(self, resolution, model , offset=None):91 def __init__(self, resolution, model): 118 92 self.model = model 119 93 self.resolution = resolution 120 if offset is None: 121 offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 122 self.offset = offset 94 self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 123 95 124 96 def apply(self, iq_in, first_bin=0, last_bin=None):
Note: See TracChangeset
for help on using the changeset viewer.