source: sasmodels/explore/check1d.py @ 4f5afc9

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 4f5afc9 was 1e867a4, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

check1d doesn't make sense with -2d, so strip it from args

  • Property mode set to 100755
File size: 1.9 KB
Line 
1#!/usr/bin/env python
2"""
3Evaluate the scattering for a shape using spherical integration over the entire
4surface in theta-phi polar coordinates, and compare it to the 1D scattering
5pattern for that shape.
6
7Parameters are the same as sascomp.  Unlike the -sphere option in sascomp,
8the evaluation is restricted to a single radial line for performance reasons,
9with angle set by -angle=alpha in the qx-qy plane.
10"""
11
12from __future__ import print_function, division
13
14import sys, os
15sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
16
17import numpy as np
18
19from sasmodels import compare, data
20
21def main(angle=0, steps=76):
22    # Parse the options using the parser in sasmodels.compare.  -angle
23    # is an additional parameter that is parsed separately., with -sphere=n and -angle=a as additional arguments
24    # Pull out angle ans
25    argv = []
26    for arg in sys.argv[1:]:
27        if arg.startswith('-sphere='):
28            steps = int(arg[8:])
29        elif arg.startswith('-angle='):
30            angle = float(arg[7:])
31        elif arg != "-2d":
32            argv.append(arg)
33    opts = compare.parse_opts(argv)
34
35    # Create a 2D radial slice
36    qr = opts['data'].x
37    qx, qy = qr*np.cos(np.radians(angle)), qr*np.sin(np.radians(angle))
38    radial_data = data.Data2D(x=qx, y=qy)
39    radial_data.radial = True  # let plotter know it is actual 1D
40
41    # Create an engine to evaluate it
42    comp = compare.make_engine(opts['info'][0], radial_data,
43                               opts['engine'][0], opts['cutoff'][0])
44    opts['engines'] = [opts['engines'][0], comp]
45
46    # Set the integration parameters to the half sphere
47    compare.set_spherical_integration_parameters(opts, steps)
48
49    # Set the random seed
50    if opts['seed'] > -1:
51        print("Randomize using -random=%i"%opts['seed'])
52        np.random.seed(opts['seed'])
53
54    # Run the comparison
55    compare.compare(opts, maxdim=np.inf)
56
57if __name__ == "__main__":
58    main(angle=0)
Note: See TracBrowser for help on using the repository browser.