Skip to content

Tag distributions as suitable for shape vs. orientation parameters #757

Description

@pkienzle

The lognormal and schulz distributions are only defined for distribution width relative to the distribution parameter. These will fail for orientation parameters, which define the distribution as jitter centered on zero then rotated to the specified orientation value.

lognormal and schulz distributions don't make physical sense for orientation parameters. Instead, we should have a separate set of distributions suitable for orientation parameters (e.g., uniform and cyclic gaussian #221) and raise an error if the wrong distribution type is selected. Sasview should only present valid distributions for shape vs. orientation parameters.

The current error trace is shown below. Checking the distribution type matches the parameter type would make the source of the problem clearer to the user, though in practice if the user interface doesn't allow a bad selection then the problem will never arise.

$ python -m sasmodels.compare ellipsoid -2d theta_pd=0.5 theta_pd_n=35 theta_pd_type=lognormal -pars         
scale: 1
background: 0.001
sld: 4
sld_solvent: 1
radius_polar: 20
radius_equatorial: 400
theta: 60 +/- 0.5  (35 points in [-3,3] sigma lognormal)
phi: 60
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File ".../sasmodels/compare.py", line 1800, in <module>
    main(*sys.argv[1:])
    ~~~~^^^^^^^^^^^^^^^
  File ".../sasmodels/compare.py", line 1797, in main
    compare(opts)
    ~~~~~~~^^^^^^
  File ".../sasmodels/compare.py", line 771, in compare
    result = run_models(opts, verbose=True)
  File ".../sasmodels/compare.py", line 860, in run_models
    base_raw, base_time = time_calculation(base, base_pars, base_n)
                          ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../sasmodels/compare.py", line 660, in time_calculation
    value = calculator(**pars)
  File ".../sasmodels/direct_model.py", line 373, in __call__
    return self._calc_theory(pars, cutoff=self.cutoff)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../sasmodels/direct_model.py", line 338, in _calc_theory
    Iq_calc = call_kernel(self._kernel, pars, cutoff=cutoff)
  File ".../sasmodels/direct_model.py", line 55, in call_kernel
    mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono)
  File ".../sasmodels/direct_model.py", line 118, in get_mesh
    mesh = [_pop_par_weights(p, values, active(p.name))
            ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../sasmodels/direct_model.py", line 150, in _pop_par_weights
    pd = weights.get_weights(distribution, npts, width, nsigma,
                            value, limits, relative)
  File ".../sasmodels/weights.py", line 290, in get_weights
    v, w = obj.get_weights(value, limits[0], limits[1], relative)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../sasmodels/weights.py", line 71, in get_weights
    x, px = self._weights(center, sigma, lb, ub)
            ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File ".../sasmodels/weights.py", line 147, in _weights
    sig = np.fabs(sigma/center)
                  ~~~~~^~~~~~~
ZeroDivisionError: float division by zero

type

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions