Changeset aaf75b6 in sasmodels for sasmodels/resolution.py
- Timestamp:
- Mar 30, 2016 2:39:42 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 885ee37
- Parents:
- d0876c9d (diff), 364d8f7 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/resolution.py
re9b1663d raaf75b6 82 82 self.q_calc = (pinhole_extend_q(q, q_width, nsigma=nsigma) 83 83 if q_calc is None else np.sort(q_calc)) 84 self.weight_matrix = pinhole_resolution( 85 self.q_calc, self.q,np.maximum(q_width, MINIMUM_RESOLUTION))84 self.weight_matrix = pinhole_resolution(self.q_calc, self.q, 85 np.maximum(q_width, MINIMUM_RESOLUTION)) 86 86 87 87 def apply(self, theory): … … 91 91 class Slit1D(Resolution): 92 92 """ 93 Slit aperture with a complicatedresolution function.93 Slit aperture with resolution function. 94 94 95 95 *q* points at which the data is measured. 96 96 97 * qx_width* slit width98 99 * qy_height* slit height97 *dqx* slit width in qx 98 99 *dqy* slit height in qy 100 100 101 101 *q_calc* is the list of points to calculate, or None if this should … … 104 104 The *weight_matrix* is computed by :func:`slit1d_resolution` 105 105 """ 106 def __init__(self, q, width, height=0., q_calc=None):107 # Remember what width/ heightwas used even though we won't need them106 def __init__(self, q, qx_width, qy_width=0., q_calc=None): 107 # Remember what width/dqy was used even though we won't need them 108 108 # after the weight matrix is constructed 109 self. width, self.height = width, height109 self.qx_width, self.qy_width = qx_width, qy_width 110 110 111 111 # Allow independent resolution on each point even though it is not 112 112 # needed in practice. 113 if np.isscalar( width):114 width = np.ones(len(q))*width113 if np.isscalar(qx_width): 114 qx_width = np.ones(len(q))*qx_width 115 115 else: 116 width = np.asarray(width)117 if np.isscalar( height):118 height = np.ones(len(q))*height116 qx_width = np.asarray(qx_width) 117 if np.isscalar(qy_width): 118 qy_width = np.ones(len(q))*qy_width 119 119 else: 120 height = np.asarray(height)120 qy_width = np.asarray(qy_width) 121 121 122 122 self.q = q.flatten() 123 self.q_calc = slit_extend_q(q, width, height) \123 self.q_calc = slit_extend_q(q, qx_width, qy_width) \ 124 124 if q_calc is None else np.sort(q_calc) 125 125 self.weight_matrix = \ 126 slit_resolution(self.q_calc, self.q, width, height)126 slit_resolution(self.q_calc, self.q, qx_width, qy_width) 127 127 128 128 def apply(self, theory): … … 396 396 """ 397 397 q = np.sort(q) 398 if q_min < q[0]:398 if q_min + 2*MINIMUM_RESOLUTION < q[0]: 399 399 if q_min <= 0: q_min = q_min*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 400 400 n_low = np.ceil((q[0]-q_min) / (q[1]-q[0])) if q[1] > q[0] else 15 … … 402 402 else: 403 403 q_low = [] 404 if q_max > q[-1]:404 if q_max - 2*MINIMUM_RESOLUTION > q[-1]: 405 405 n_high = np.ceil((q_max-q[-1]) / (q[-1]-q[-2])) if q[-1] > q[-2] else 15 406 406 q_high = np.linspace(q[-1], q_max, n_high+1)[1:] … … 596 596 Slit smearing with perfect resolution. 597 597 """ 598 resolution = Slit1D(self.x, width=0, height=0, q_calc=self.x)598 resolution = Slit1D(self.x, qx_width=0, qy_width=0, q_calc=self.x) 599 599 theory = self.Iq(resolution.q_calc) 600 600 output = resolution.apply(theory) … … 606 606 Slit smearing with height 0.005 607 607 """ 608 resolution = Slit1D(self.x, width=0, height=0.005, q_calc=self.x)608 resolution = Slit1D(self.x, qx_width=0, qy_width=0.005, q_calc=self.x) 609 609 theory = self.Iq(resolution.q_calc) 610 610 output = resolution.apply(theory) … … 621 621 """ 622 622 q = np.logspace(-4, -1, 10) 623 resolution = Slit1D(q, width=0.2, height=np.inf)623 resolution = Slit1D(q, qx_width=0.2, qy_width=np.inf) 624 624 theory = 1000*self.Iq(resolution.q_calc**4) 625 625 output = resolution.apply(theory) … … 635 635 Slit smearing with width 0.0002 636 636 """ 637 resolution = Slit1D(self.x, width=0.0002, height=0, q_calc=self.x)637 resolution = Slit1D(self.x, qx_width=0.0002, qy_width=0, q_calc=self.x) 638 638 theory = self.Iq(resolution.q_calc) 639 639 output = resolution.apply(theory) … … 648 648 Slit smearing with width > 100*height. 649 649 """ 650 resolution = Slit1D(self.x, width=0.0002, height=0.000001,650 resolution = Slit1D(self.x, qx_width=0.0002, qy_width=0.000001, 651 651 q_calc=self.x) 652 652 theory = self.Iq(resolution.q_calc) … … 773 773 data = np.loadtxt(data_string.split('\n')).T 774 774 q, delta_qv, _, answer = data 775 resolution = Slit1D(q, width=delta_qv, height=0)775 resolution = Slit1D(q, qx_width=delta_qv, qy_width=0) 776 776 output = self._eval_sphere(pars, resolution) 777 777 # TODO: eliminate Igor test since it is too inaccurate to be useful. … … 793 793 q_calc = slit_extend_q(interpolate(q, 2*np.pi/radius/20), 794 794 delta_qv[0], 0.) 795 resolution = Slit1D(q, width=delta_qv, height=0, q_calc=q_calc)795 resolution = Slit1D(q, qx_width=delta_qv, qy_width=0, q_calc=q_calc) 796 796 output = self._eval_sphere(pars, resolution) 797 797 # TODO: relative error should be lower … … 805 805 pars = { 806 806 'scale':0.05, 807 'r polar':500, 'requatorial':15000,808 'sld':6, 's olvent_sld': 1,807 'r_polar':500, 'r_equatorial':15000, 808 'sld':6, 'sld_solvent': 1, 809 809 } 810 810 form = load_model('ellipsoid', dtype='double') 811 811 q = np.logspace(log10(4e-5), log10(2.5e-2), 68) 812 812 width, height = 0.117, 0. 813 resolution = Slit1D(q, width=width, height=height)813 resolution = Slit1D(q, qx_width=width, qy_width=height) 814 814 answer = romberg_slit_1d(q, width, height, form, pars) 815 815 output = resolution.apply(eval_form(resolution.q_calc, form, pars)) … … 837 837 TEST_PARS_PINHOLE_SPHERE = { 838 838 'scale': 1.0, 'background': 0.01, 839 'radius': 60.0, 'sld': 1, 's olvent_sld': 6.3,839 'radius': 60.0, 'sld': 1, 'sld_solvent': 6.3, 840 840 } 841 841 # Q, dQ, I(Q) calculated by NIST Igor SANS package … … 946 946 TEST_PARS_SLIT_SPHERE = { 947 947 'scale': 0.01, 'background': 0.01, 948 'radius': 60000, 'sld': 1, 's olvent_sld': 4,948 'radius': 60000, 'sld': 1, 'sld_solvent': 4, 949 949 } 950 950 # Q dQ I(Q) I_smeared(Q) … … 1047 1047 1048 1048 if name == 'cylinder': 1049 pars = {'length':210, 'radius':500 }1049 pars = {'length':210, 'radius':500, 'background': 0} 1050 1050 elif name == 'teubner_strey': 1051 1051 pars = {'a2':0.003, 'c1':-1e4, 'c2':1e10, 'background':0.312643} … … 1054 1054 elif name == 'ellipsoid': 1055 1055 pars = { 1056 'scale':0.05, 1057 'r polar':500, 'requatorial':15000,1058 'sld':6, 's olvent_sld': 1,1056 'scale':0.05, 'background': 0, 1057 'r_polar':500, 'r_equatorial':15000, 1058 'sld':6, 'sld_solvent': 1, 1059 1059 } 1060 1060 else: … … 1068 1068 1069 1069 if isinstance(resolution, Slit1D): 1070 width, height = resolution. width, resolution.height1070 width, height = resolution.dqx, resolution.dqy 1071 1071 Iq_romb = romberg_slit_1d(resolution.q, width, height, model, pars) 1072 1072 else:
Note: See TracChangeset
for help on using the changeset viewer.