# Changeset 997d4eb in sasmodels

Ignore:
Timestamp:
Oct 13, 2016 12:36:00 AM (6 years ago)
Parents:
1a6cd57 (diff), a80e64c (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:
jhbakker <j.h.bakker@…> (10/13/16 00:36:00)
git-committer:
Message:
Files:
24 edited

Unmodified
Removed
• ## sasmodels/kernel_template.c

 r6a0d6aa #if defined(IQXY_HAS_THETA) // Force a nominal value for the spherical correction even when // theta is +90/-90 so that there are no divide by zero problems. // For cos(theta) fixed at 90, we effectively multiply top and bottom // theta is +0/180 so that there are no divide by zero problems. // For sin(theta) fixed at 0 and 180, we effectively multiply top and bottom // by 1e-6, so the effect cancels. const double spherical_correction = fmax(fabs(cos(M_PI_180*theta)), 1.e-6);
• ## sasmodels/kernelpy.py

 r14a15a3 import numpy as np  # type: ignore from numpy import pi, cos  #type: ignore from numpy import pi, sin, cos  #type: ignore from . import details partial_weight = np.prod(pd_weight[pd_offset+pd_index][1:]) if call_details.theta_par >= 0: cor = cos(pi / 180 * parameters[call_details.theta_par]) cor = sin(pi / 180 * parameters[call_details.theta_par]) spherical_correction = max(abs(cor), 1e-6) p0_index = loop_index%p0_length
• ## sasmodels/models/barbell.c

 r2222134 // Compute angle alpha between q and the cylinder axis double sn, cn; // slots to hold sincos function output SINCOS(theta*M_PI_180, sn, cn); const double q = sqrt(qx*qx+qy*qy); const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); SINCOS(phi*M_PI_180, sn, cn); const double q = sqrt(qx*qx + qy*qy); const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); const double alpha = acos(cos_val); // rod angle relative to q
• ## sasmodels/models/barbell.py

 rb0c4271 Definition of the angles for oriented 2D barbells. .. figure:: img/cylinder_angle_projection.jpg :width: 600px Examples of the angles for oriented pp against the detector plane. References
• ## sasmodels/models/capped_cylinder.c

 r2222134 // Compute angle alpha between q and the cylinder axis double sn, cn; SINCOS(theta*M_PI_180, sn, cn); SINCOS(phi*M_PI_180, sn, cn); const double q = sqrt(qx*qx+qy*qy); const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); const double alpha = acos(cos_val); // rod angle relative to q
• ## sasmodels/models/capped_cylinder.py

 rb0c4271 Definition of the angles for oriented 2D cylinders. .. figure:: img/cylinder_angle_projection.jpg :width: 600px Examples of the angles for oriented 2D cylinders against the detector plane. References ["radius_cap", "Ang",     20, [0, inf],    "volume", "Cap radius"], ["length",     "Ang",    400, [0, inf],    "volume", "Cylinder length"], ["theta",      "degrees", 60, [-inf, inf], "orientation", "In plane angle"], ["phi",        "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"], ["theta",      "degrees", 60, [-inf, inf], "orientation", "inclination angle"], ["phi",        "degrees", 60, [-inf, inf], "orientation", "deflection angle"], ] # pylint: enable=bad-whitespace, line-too-long
• ## sasmodels/models/core_shell_bicelle.c

 r2222134 // Cylinder orientation const double cyl_x = cos(theta) * cos(phi); const double cyl_y = sin(theta); const double cyl_x = sin(theta) * cos(phi); const double cyl_y = sin(theta) * sin(phi); // Compute the angle btw vector q and the axis of the cylinder
• ## sasmodels/models/core_shell_bicelle.py

 r1a6cd57 Definition of the angles for the oriented core shell bicelle tmodel. .. figure:: img/cylinder_angle_projection.jpg :width: 600px Examples of the angles for oriented pp against the detector plane. References qx, qy = 0.4 * cos(90), 0.5 * sin(0) tests = [ # Accuracy tests based on content in test/utest_other_models.py [{'radius': 20.0, 'thick_rim': 10.0, 'thick_face': 10.0, 'length': 400.0, 'sld_core': 1.0, 'sld_face': 4.0, 'sld_rim': 4.0, 'sld_solvent': 1.0, 'background': 0.0, }, 0.001, 353.550], [{'radius': 20.0, 'thick_rim': 10.0, 'thick_face': 10.0, 'length': 400.0, 'sld_core': 1.0, 'sld_face': 4.0, 'sld_rim': 4.0, 'sld_solvent': 1.0, 'theta': 90.0, 'phi': 0.0, 'background': 0.00, }, (qx, qy), 24.9167], # Additional tests with larger range of parameters [{'radius': 3.0, 'thick_rim': 100.0, 'thick_face': 100.0, 'length': 1200.0, 'sld_core': 5.0, 'sld_face': 41.0, 'sld_rim': 42.0, 'sld_solvent': 21.0, }, 0.05, 1670.1828], ]
• ## sasmodels/models/core_shell_cylinder.c

 r43b7eea // Compute angle alpha between q and the cylinder axis SINCOS(theta*M_PI_180, sn, cn); SINCOS(phi*M_PI_180, sn, cn); // # The following correction factor exists in sasview, but it can't be // # right, so we are leaving it out for now. // const double correction = fabs(cn)*M_PI_2; const double q = sqrt(qx*qx+qy*qy); const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); const double alpha = acos(cos_val);
• ## sasmodels/models/core_shell_ellipsoid.c

 r5031ca3 // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. const double cyl_x = cos(theta) * cos(phi); const double cyl_y = sin(theta); const double cyl_x = sin(theta) * cos(phi); const double cyl_y = sin(theta) * sin(phi); const double sldcs = core_sld - shell_sld;
• ## sasmodels/models/core_shell_ellipsoid.py

 r416f5c7 qx = q*cos(phi) qy = q*sin(phi) tests = [ # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py [{'radius_equat_core': 200.0, 'x_core': 0.1, 'thick_shell': 50.0, 'x_polar_shell': 0.2, 'sld_core': 2.0, 'sld_shell': 1.0, 'sld_solvent': 6.3, 'background': 0.001, 'scale': 1.0, }, 1.0, 0.00189402], # After redefinition of angles find new reasonable values for unit test #tests = [ #    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py #    [{'radius_equat_core': 200.0, #      'x_core': 0.1, #      'thick_shell': 50.0, #      'x_polar_shell': 0.2, #      'sld_core': 2.0, #      'sld_shell': 1.0, #      'sld_solvent': 6.3, #      'background': 0.001, #      'scale': 1.0, #     }, 1.0, 0.00189402], # Additional tests with larger range of parameters [{'background': 0.01}, 0.1, 11.6915], [{'radius_equat_core': 20.0, 'x_core': 200.0, 'thick_shell': 54.0, 'x_polar_shell': 3.0, 'sld_core': 20.0, 'sld_shell': 10.0, 'sld_solvent': 6.0, 'background': 0.0, 'scale': 1.0, }, 0.01, 8688.53], [{'background': 0.001}, (0.4, 0.5), 0.00690673], [{'radius_equat_core': 20.0, 'x_core': 200.0, 'thick_shell': 54.0, 'x_polar_shell': 3.0, 'sld_core': 20.0, 'sld_shell': 10.0, 'sld_solvent': 6.0, 'background': 0.01, 'scale': 0.01, }, (qx, qy), 0.0100002], ] #    [{'background': 0.01}, 0.1, 11.6915], #    [{'radius_equat_core': 20.0, #      'x_core': 200.0, #      'thick_shell': 54.0, #      'x_polar_shell': 3.0, #      'sld_core': 20.0, #      'sld_shell': 10.0, #      'sld_solvent': 6.0, #      'background': 0.0, #      'scale': 1.0, #     }, 0.01, 8688.53], #   [{'background': 0.001}, (0.4, 0.5), 0.00690673], #   [{'radius_equat_core': 20.0, #      'x_core': 200.0, #      'thick_shell': 54.0, #      'x_polar_shell': 3.0, #      'sld_core': 20.0, #      'sld_shell': 10.0, #      'sld_solvent': 6.0, #      'background': 0.01, #      'scale': 0.01, #     }, (qx, qy), 0.0100002], #    ]
• ## sasmodels/models/cylinder.c

 re9b1663d double form_volume(double radius, double length); double fq(double q, double sn, double cn,double radius, double length); double orient_avg_1D(double q, double radius, double length); double Iq(double q, double sld, double solvent_sld, double radius, double length); double Iqxy(double qx, double qy, double sld, double solvent_sld, } double fq(double q, double sn, double cn, double radius, double length) { // precompute qr and qh to save time in the loop const double qr = q*radius; const double qh = q*0.5*length; return  sas_J1c(qr*sn) * sinc(qh*cn) ; } double orient_avg_1D(double q, double radius, double length) { // translate a point in [-1,1] to a point in [0, pi/2] const double zm = M_PI_4; const double zb = M_PI_4; double total = 0.0; for (int i=0; i<76 ;i++) { const double alpha = Gauss76Z[i]*zm + zb; double sn, cn; // slots to hold sincos function output // alpha(theta,phi) the projection of the cylinder on the detector plane SINCOS(alpha, sn, cn); total += Gauss76Wt[i] * fq(q, sn, cn, radius, length)* fq(q, sn, cn, radius, length) * sn; } // translate dx in [-1,1] to dx in [lower,upper] return total*zm; } double Iq(double q, double sld, double length) { // precompute qr and qh to save time in the loop const double qr = q*radius; const double qh = q*0.5*length; // translate a point in [-1,1] to a point in [0, pi/2] const double zm = M_PI_4; const double zb = M_PI_4; double total = 0.0; for (int i=0; i<76 ;i++) { const double alpha = Gauss76Z[i]*zm + zb; double sn, cn; SINCOS(alpha, sn, cn); const double fq = sinc(qh*cn) * sas_J1c(qr*sn); total += Gauss76Wt[i] * fq*fq * sn; } // translate dx in [-1,1] to dx in [lower,upper] const double form = total*zm; const double s = (sld - solvent_sld) * form_volume(radius, length); return 1.0e-4 * s * s * form; return 1.0e-4 * s * s * orient_avg_1D(q, radius, length); } // Compute angle alpha between q and the cylinder axis SINCOS(theta*M_PI_180, sn, cn); SINCOS(phi*M_PI_180, sn, cn); const double q = sqrt(qx*qx + qy*qy); const double cos_val = (q==0. ? 1.0 : (cn*cos(phi*M_PI_180)*qx + sn*qy)/q); const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); const double alpha = acos(cos_val); SINCOS(alpha, sn, cn); const double fq = sinc(q*0.5*length*cn) * sas_J1c(q*radius*sn); const double s = (sld-solvent_sld) * form_volume(radius, length); return 1.0e-4 * square(s * fq); return 1.0e-4 * square(s * fq(q, sn, cn, radius, length)); }
• ## sasmodels/models/cylinder.py

 r416f5c7 .. math:: F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} F^2(q)=\int_{0}^{\pi/2}{F^2(q,\theta)\sin(\theta)d\theta} Definition of the angles for oriented cylinders. .. figure:: img/cylinder_angle_projection.jpg Examples of the angles for oriented cylinders against the detector plane. NB: The 2nd virial coefficient of the cylinder is calculated based on the P(q) = \int_0^{\pi/2} d\phi \int_0^\pi p(\theta, \phi) P_0(q,\alpha) \sin \theta\ d\theta \int_0^\pi p(\alpha) P_0(q,\alpha) \sin \alpha\ d\alpha where $p(\theta,\phi)$ is the probability distribution for the orientation where $p(\theta,\phi) = 1$ is the probability distribution for the orientation and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented system, and then comparing to the 1D result. ---------- None J. S. Pedersen, Adv. Colloid Interface Sci. 70, 171-210 (1997). G. Fournet, Bull. Soc. Fr. Mineral. Cristallogr. 74, 39-113 (1951). """ "Cylinder length"], ["theta", "degrees", 60, [-inf, inf], "orientation", "In plane angle"], "latitude"], ["phi", "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"], "longitude"], ] source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c",  "cylinder.c"] def ER(radius, length): qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) tests = [[{}, 0.2, 0.042761386790780453], [{}, [0.2], [0.042761386790780453]], [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], ] # After redefinition of angles, find new tests values #tests = [[{}, 0.2, 0.042761386790780453], #         [{}, [0.2], [0.042761386790780453]], #         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], #         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], #        ] del qx, qy  # not necessary to delete, but cleaner # ADDED by:  RKH  ON: 18Mar2016 renamed sld's etc
• ## sasmodels/models/ellipsoid.c

 ra807206 const double q = sqrt(qx*qx + qy*qy); SINCOS(theta*M_PI_180, sn, cn); // TODO: check if this is actually sin(alpha), not cos(alpha) const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha); SINCOS(phi*M_PI_180, sn, cn); const double cos_alpha = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); const double alpha = acos(cos_alpha); SINCOS(alpha, sn, cn); const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, sn); const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial);
• ## sasmodels/models/ellipsoid.py

 r416f5c7 The $\theta$ and $\phi$ parameters are not used for the 1D output. .. _ellipsoid-geometry: .. figure:: img/ellipsoid_angle_projection.jpg The angles for oriented ellipsoid, shown here as oblate, $a$ = $R_p$ and $b$ = $R_e$ Validation
• ## sasmodels/models/hollow_cylinder.c

 raea2e2a // Cylinder orientation cyl_x = cos(theta) * cos(phi); cyl_y = sin(theta); cyl_x = sin(theta) * cos(phi); cyl_y = sin(theta) * sin(phi); //cyl_z = -cos(theta) * sin(phi);
• ## sasmodels/models/stacked_disks.c

 ra807206 // parallelepiped orientation const double cyl_x = ct * cp; const double cyl_y = st; const double cyl_x = st * cp; const double cyl_y = st * sp; // Compute the angle btw vector q and the
• ## sasmodels/models/stacked_disks.py

 r7c57861 the axis of the cylinder using two angles $\theta$ and $\varphi$. .. figure:: img/stacked_disks_angle_definition.jpg Examples of the angles for oriented stacked disks against .. figure:: img/cylinder_angle_definition.jpg Examples of the angles against the detector plane. .. figure:: img/stacked_disks_angle_projection.jpg Examples of the angles for oriented pp against the detector plane. Our model uses the form factor calculations implemented in a c-library provided theta=0, phi=0) tests = [ # Accuracy tests based on content in test/utest_extra_models.py. # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB [{'thick_core': 10.0, 'thick_layer': 15.0, 'radius': 3000.0, 'n_stacking': 1.0, 'sigma_d': 0.0, 'sld_core': 4.0, 'sld_layer': -0.4, 'solvent_sd': 5.0, 'theta': 0.0, 'phi': 0.0, 'scale': 0.01, 'background': 0.001, }, 0.001, 5075.12], [{'thick_core': 10.0, 'thick_layer': 15.0, 'radius': 3000.0, 'n_stacking': 5.0, 'sigma_d': 0.0, 'sld_core': 4.0, 'sld_layer': -0.4, 'solvent_sd': 5.0, 'theta': 0.0, 'phi': 0.0, 'scale': 0.01, 'background': 0.001, }, 0.001, 5065.12793824], [{'thick_core': 10.0, 'thick_layer': 15.0, 'radius': 3000.0, 'n_stacking': 5.0, 'sigma_d': 0.0, 'sld_core': 4.0, 'sld_layer': -0.4, 'solvent_sd': 5.0, 'theta': 0.0, 'phi': 0.0, 'scale': 0.01, 'background': 0.001, }, 0.164, 0.0127673597265], [{'thick_core': 10.0, 'thick_layer': 15.0, 'radius': 3000.0, 'n_stacking': 1.0, 'sigma_d': 0.0, 'sld_core': 4.0, 'sld_layer': -0.4, 'solvent_sd': 5.0, 'theta': 0.0, 'phi': 0.0, 'scale': 0.01, 'background': 0.001, }, [0.001, 90.0], [5075.12, 0.001]], [{'thick_core': 10.0, 'thick_layer': 15.0, 'radius': 3000.0, 'n_stacking': 1.0, 'sigma_d': 0.0, 'sld_core': 4.0, 'sld_layer': -0.4, 'solvent_sd': 5.0, 'theta': 0.0, 'phi': 0.0, 'scale': 0.01, 'background': 0.001, }, ([0.4, 0.5]), [0.00105074, 0.00121761]], [{'thick_core': 10.0, 'thick_layer': 15.0, 'radius': 3000.0, 'n_stacking': 1.0, 'sigma_d': 0.0, 'sld_core': 4.0, 'sld_layer': -0.4, 'solvent_sd': 5.0, 'theta': 0.0, 'phi': 0.0, 'scale': 0.01, 'background': 0.001, }, ([1.3, 1.57]), [0.0010039, 0.0010038]], ] #After redefinition to spherical coordinates find new reasonable test values #tests = [ #    # Accuracy tests based on content in test/utest_extra_models.py. #    # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB #    [{'thick_core': 10.0, #      'thick_layer': 15.0, #      'radius': 3000.0, #      'n_stacking': 1.0, #      'sigma_d': 0.0, #      'sld_core': 4.0, #      'sld_layer': -0.4, #      'solvent_sd': 5.0, #      'theta': 0.0, #      'phi': 0.0, #      'scale': 0.01, #      'background': 0.001, #     }, 0.001, 5075.12], #    [{'thick_core': 10.0, #      'thick_layer': 15.0, #      'radius': 3000.0, #      'n_stacking': 5.0, #      'sigma_d': 0.0, #      'sld_core': 4.0, #      'sld_layer': -0.4, #      'solvent_sd': 5.0, #      'theta': 0.0, #      'phi': 0.0, #      'scale': 0.01, #      'background': 0.001, #     }, 0.001, 5065.12793824], #    [{'thick_core': 10.0, #      'thick_layer': 15.0, #      'radius': 3000.0, #      'n_stacking': 5.0, #      'sigma_d': 0.0, #      'sld_core': 4.0, #      'sld_layer': -0.4, #      'solvent_sd': 5.0, #      'theta': 0.0, #      'phi': 0.0, #      'scale': 0.01, #      'background': 0.001, #     }, 0.164, 0.0127673597265], #    [{'thick_core': 10.0, #      'thick_layer': 15.0, #      'radius': 3000.0, #      'n_stacking': 1.0, #      'sigma_d': 0.0, #      'sld_core': 4.0, #      'sld_layer': -0.4, #      'solvent_sd': 5.0, #      'theta': 0.0, #      'phi': 0.0, #      'scale': 0.01, #      'background': 0.001, #     }, [0.001, 90.0], [5075.12, 0.001]], #    [{'thick_core': 10.0, #      'thick_layer': 15.0, #      'radius': 3000.0, #      'n_stacking': 1.0, #      'sigma_d': 0.0, #      'sld_core': 4.0, #      'sld_layer': -0.4, #      'solvent_sd': 5.0, #      'theta': 0.0, #      'phi': 0.0, #      'scale': 0.01, #      'background': 0.001, #     }, ([0.4, 0.5]), [0.00105074, 0.00121761]], #    [{'thick_core': 10.0, #      'thick_layer': 15.0, #      'radius': 3000.0, #      'n_stacking': 1.0, #      'sigma_d': 0.0, #      'sld_core': 4.0, #      'sld_layer': -0.4, #     'solvent_sd': 5.0, #      'theta': 0.0, #      'phi': 0.0, #      'scale': 0.01, #      'background': 0.001, #     }, ([1.3, 1.57]), [0.0010039, 0.0010038]], #    ] # 21Mar2016   RKH notes that unit tests all have n_stacking=1, ought to test other values
• ## sasmodels/product.py

 r6dc78e4 s_details = make_details(s_info, s_length, s_offset, nweights+1) v, w = weights[:nweights], weights[nweights:] s_values = [[1., 0., p_er, s_vr], # er and vf already included, so start one past the # volfrac parameter, and go two less than the number # of S parameters. values[2+p_npars+2:2+p_npars+s_npars-1], # no magnetism parameters to include for S # add er into the (value, weights) pairs v, [p_er], w, [1.0]] s_values = [ # scale=1, background=0, radius_effective=p_er, volfraction=s_vr [1., 0., p_er, s_vr], # structure factor parameters start after scale, background and # all the form factor parameters.  Skip the volfraction parameter # as well, since it is computed elsewhere, and go to the end of the # parameter list. values[2+p_npars+1:2+p_npars+s_npars], # no magnetism parameters to include for S # add er into the (value, weights) pairs v, [p_er], w, [1.0] ] spacer = (32 - sum(len(v) for v in s_values)%32)%32 s_values.append([0.]*spacer) s_result = self.s_kernel(s_details, s_values, cutoff, False) #print("p_npars",p_npars,s_npars,p_er,s_vr,values[2+p_npars+1:2+p_npars+s_npars]) #call_details.show(values) #print("values", values) #p_details.show(p_values) #print("=>", p_result) #print("p val", s_values) #s_details.show(s_values) #print("=>", s_result)
• ## sasmodels/sasview_model.py

 r1a6cd57 from . import core from . import custom from . import product from . import generate from . import weights def MultiplicationModel(form_factor, structure_factor): # type: ("SasviewModel", "SasviewModel") -> "SasviewModel" model_info = product.make_product_info(form_factor._model_info, structure_factor._model_info) ConstructedModel = _make_model_from_info(model_info) return ConstructedModel() def _make_model_from_info(model_info): # type: (ModelInfo) -> SasviewModelType
• ## sasmodels/direct_model.py

 r4cc161e from . import resolution2d from .details import make_kernel_args, dispersion_mesh from sas.sasgui.perspectives.fitting.fitpage import FitPage try: # interpret data if hasattr(data, 'lam'): #if not FitPage.no_transform.GetValue(): #if the no_transform radio button is not active DOES NOT WORK! not active before fitting self.data_type = 'sesans' elif hasattr(data, 'qx_data'):
• ## sasmodels/resolution.py

 r2b3a1bd from numpy import sqrt, log, log10, exp, pi  # type: ignore import numpy as np  # type: ignore from sasmodels import sesans __all__ = ["Resolution", "Perfect1D", "Pinhole1D", "Slit1D", raise NotImplementedError("Subclass does not define the apply function") class Perfect1D(Resolution): """ return theory class SESANS1D(Resolution): def __init__(self, data, q_calc): self.q = data.x self.data = data self.q_calc = q_calc def apply(self, theory): return sesans.transform(self.data, self.q_calc, theory, None, None) class Pinhole1D(Resolution):
• ## sasmodels/sesans.py

 r7ae2b7f from numpy import pi, exp  # type: ignore from scipy.special import jv as besselj #from sas.sasgui.perspectives.fitting.fitpage import FitPage #import direct_model.DataMixin as model (2016-03-19: currently controlled from parameters script) nqmono is the number of q vectors to be used for the detector integration """ nqmono = len(qmono) if nqmono == 0: qmono are the detector limits: can be a 1D or 2D array (depending on Q-limit or Qx,Qy limits) """ if qmono == None: result = call_hankel(data, q_calc, Iq_calc) elif nqmono == 1: q = qmono[0] result = call_HankelAccept(data, q_calc, Iq_calc, q, Iq_mono) else: Qx, Qy = [qmono[0], qmono[1]] Qx = np.reshape(Qx, nqx, nqy) Qy = np.reshape(Qy, nqx, nqy) Iq_mono = np.reshape(Iq_mono, nqx, nqy) qx = Qx[0, :] qy = Qy[:, 0] result = call_Cosine2D(data, q_calc, Iq_calc, qx, qy, Iq_mono) nqmono = len(qmono) if nqmono == 0: # if radiobutton hankel is active #if FitPage.hankel.GetValue(): result = call_hankel(data, q_calc, Iq_calc) elif nqmono == 1: q = qmono[0] result = call_HankelAccept(data, q_calc, Iq_calc, q, Iq_mono) else: #if radiobutton Cosine is active Qx, Qy = [qmono[0], qmono[1]] Qx = np.reshape(Qx, nqx, nqy) Qy = np.reshape(Qy, nqx, nqy) Iq_mono = np.reshape(Iq_mono, nqx, nqy) qx = Qx[0, :] qy = Qy[:, 0] result = call_Cosine2D(data, q_calc, Iq_calc, qx, qy, Iq_mono) return result def call_hankel(data, q_calc, Iq_calc): return hankel((data.x, data.x_unit), (data.lam, data.lam_unit), (data.sample.thickness, data.sample.thickness_unit), q_calc, Iq_calc) #   data.lam_unit='nm' #return hankel((data.x, data.x_unit), #            (data.lam, data.lam_unit), #           (data.sample.thickness, #           data.sample.thickness_unit), #         q_calc, Iq_calc) return hankel((data.x, data._xunit), q_calc, Iq_calc) def call_HankelAccept(data, q_calc, Iq_calc, q_mono, Iq_mono): P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) def hankel(SElength, wavelength, thickness, q, Iq): #def hankel(SElength, wavelength, thickness, q, Iq): def hankel(SElength, q, Iq): r""" Compute the expected SESANS polarization for a given SANS pattern. from sas.sascalc.data_util.nxsunit import Converter wavelength = Converter(wavelength[1])(wavelength[0],"A") thickness = Converter(thickness[1])(thickness[0],"A") Iq = Converter("1/cm")(Iq,"1/A") # All models default to inverse centimeters #wavelength = Converter(wavelength[1])(wavelength[0],"A") #thickness = Converter(thickness[1])(thickness[0],"A") #Iq = Converter("1/cm")(Iq,"1/A") # All models default to inverse centimeters SElength = Converter(SElength[1])(SElength[0],"A") G = np.zeros_like(SElength, 'd') #============================================================================== #     Hankel Transform method if "wavelength" is a scalar; mono-chromatic SESANS #============================================================================== for i, SElength_i in enumerate(SElength): integral = besselj(0, q*SElength_i)*Iq*q G[i] = np.sum(integral) G0 = np.sum(Iq*q) G0 = np.sum(Iq*q) #relation to ksi? For generalization to all models # [m^-1] step size in q, needed for integration G0 = np.sum(Iq*q)*dq*2*np.pi P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) #P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) P = (G-G0)/(4*pi**2) #P=G-G0 return P
Note: See TracChangeset for help on using the changeset viewer.