Changes in src/sas/sascalc/data_util/qsmearing.py [f8aa738:c6728e1] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/qsmearing.py
rf8aa738 rc6728e1 5 5 #This software was developed by the University of Tennessee as part of the 6 6 #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. 8 8 #See the license text in license.txt 9 9 #copyright 2008, University of Tennessee … … 13 13 import logging 14 14 import sys 15 from sasmodels import sesans 16 import numpy as np # type: ignore 17 from numpy import pi, exp # type: ignore 15 18 16 19 from sasmodels.resolution import Slit1D, Pinhole1D 20 from sasmodels.sesans import SESANS1D 17 21 from sasmodels.resolution2d import Pinhole2D 22 from src.sas.sascalc.data_util.nxsunit import Converter 23 18 24 19 25 def smear_selection(data, model = None): … … 36 42 # Sanity check. If we are not dealing with a SAS Data1D 37 43 # object, just return None 44 45 # This checks for 2D data (does not throw exception because fail is common) 38 46 if data.__class__.__name__ not in ['Data1D', 'Theory1D']: 39 47 if data == None: … … 42 50 return None 43 51 return Pinhole2D(data) 44 52 # This checks for 1D data with smearing info in the data itself (again, fail is likely; no exceptions) 45 53 if not hasattr(data, "dx") and not hasattr(data, "dxl")\ 46 54 and not hasattr(data, "dxw"): … … 48 56 49 57 # Look for resolution smearing data 58 # This is the code that checks for SESANS data; it looks for the file loader 59 # TODO: change other sanity checks to check for file loader instead of data structure? 60 _found_sesans = False 61 #if data.dx is not None and data.meta_data['loader']=='SESANS': 62 if data.dx is not None and data.isSesans: 63 #if data.dx[0] > 0.0: 64 if numpy.size(data.dx[data.dx <= 0]) == 0: 65 _found_sesans = True 66 #if data.dx[0] <= 0.0: 67 if numpy.size(data.dx[data.dx <= 0]) > 0: 68 raise ValueError('one or more of your dx values are negative, please check the data file!') 69 if _found_sesans == True: 70 #Pre-compute the Hankel matrix (H) 71 qmax, qunits = data.sample.zacceptance 72 hankel=sesans.SesansTransform() 73 sesans.SesansTransform.set_transform(hankel, 74 SE = Converter(data._xunit)(data.x, "A"), 75 zaccept = Converter(qunits)(qmax, "1/A"), 76 Rmax = 10000000) 77 # Then return the actual transform, as if it were a smearing function 78 return PySmear(SESANS1D(data, hankel._H0, hankel._H, hankel.q), model) 79 50 80 _found_resolution = False 51 81 if data.dx is not None and len(data.dx) == len(data.x): … … 92 122 self.model = model 93 123 self.resolution = resolution 94 self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 124 if hasattr(self.resolution, 'data'): 125 if self.resolution.data.meta_data['loader'] == 'SESANS': # Always True if file extension is '.ses'! 126 self.offset = 0 127 # This is default behaviour, for future resolution/transform functions this needs to be revisited. 128 else: 129 self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 130 else: 131 self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 132 133 #self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 95 134 96 135 def apply(self, iq_in, first_bin=0, last_bin=None): … … 126 165 q[first:last+1]. 127 166 """ 167 128 168 q = self.resolution.q 129 169 first = numpy.searchsorted(q, q_min)
Note: See TracChangeset
for help on using the changeset viewer.