Changeset 345e7e4 in sasview for src/sas/sascalc/data_util/qsmearing.py
- Timestamp:
- Dec 19, 2016 5:23:36 AM (8 years ago)
- 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:
- b61bd57
- Parents:
- f2724b6
- git-author:
- jhbakker <j.h.bakker@…> (12/19/16 05:23:36)
- git-committer:
- GitHub <noreply@…> (12/19/16 05:23:36)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/qsmearing.py
rc6728e1 r345e7e4 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 sesans16 import numpy as np # type: ignore17 from numpy import pi, exp # type: ignore18 15 19 16 from sasmodels.resolution import Slit1D, Pinhole1D 20 from sasmodels.sesans import SESANS1D21 17 from sasmodels.resolution2d import Pinhole2D 22 from src.sas.sascalc.data_util.nxsunit import Converter23 24 18 25 19 def smear_selection(data, model = None): … … 42 36 # Sanity check. If we are not dealing with a SAS Data1D 43 37 # object, just return None 44 45 # This checks for 2D data (does not throw exception because fail is common)46 38 if data.__class__.__name__ not in ['Data1D', 'Theory1D']: 47 39 if data == None: … … 50 42 return None 51 43 return Pinhole2D(data) 52 # This checks for 1D data with smearing info in the data itself (again, fail is likely; no exceptions) 44 53 45 if not hasattr(data, "dx") and not hasattr(data, "dxl")\ 54 46 and not hasattr(data, "dxw"): … … 56 48 57 49 # Look for resolution smearing data 58 # This is the code that checks for SESANS data; it looks for the file loader59 # TODO: change other sanity checks to check for file loader instead of data structure?60 _found_sesans = False61 #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 = True66 #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.zacceptance72 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 function78 return PySmear(SESANS1D(data, hankel._H0, hankel._H, hankel.q), model)79 80 50 _found_resolution = False 81 51 if data.dx is not None and len(data.dx) == len(data.x): … … 122 92 self.model = model 123 93 self.resolution = resolution 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]) 94 self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 134 95 135 96 def apply(self, iq_in, first_bin=0, last_bin=None): … … 165 126 q[first:last+1]. 166 127 """ 167 168 128 q = self.resolution.q 169 129 first = numpy.searchsorted(q, q_min)
Note: See TracChangeset
for help on using the changeset viewer.