Changeset 225bf94 in sasmodels for sasmodels/modelinfo.py
- Timestamp:
- Mar 13, 2019 12:26:42 PM (5 years ago)
- Children:
- 0c86b79
- Parents:
- 3b6567f (diff), d8eaa3d (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:
- Paul Kienzle <pkienzle@…> (03/13/19 12:26:42)
- git-committer:
- GitHub <noreply@…> (03/13/19 12:26:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
r3b6567f r225bf94 295 295 example, might be used to set the value of a shape parameter. 296 296 297 These values are set by :func:`make_parameter_table` and 297 Control parameters are used for variant models such as :ref:`rpa` which 298 have different cases with different parameters, as well as models 299 like :ref:`spherical_sld` with its user defined number of shells. 300 The control parameter should appear in the parameter table along with the 301 parameters it is is controlling. For variant models, use *[CASES]* in 302 place of the parameter limits Within the parameter definition table, 303 with case names such as:: 304 305 CASES = ["diblock copolymer", "triblock copolymer", ...] 306 307 This should give *limits=[[case1, case2, ...]]*, but the model loader 308 translates it to *limits=[0, len(CASES)-1]*, and adds *choices=CASES* to 309 the :class:`Parameter` definition. Note that models can use a list of 310 cases as a parameter without it being a control parameter. Either way, 311 the parameter is sent to the model evaluator as *float(choice_num)*, 312 where choices are numbered from 0. :meth:`ModelInfo.get_hidden_parameters` 313 will determine which parameers to display. 314 315 The class contructor should not be called directly, but instead the 316 parameter table is built using :func:`make_parameter_table` and 298 317 :func:`parse_parameter` therein. 299 318 """ … … 847 866 info.sesans = getattr(kernel_module, 'sesans', None) # type: ignore 848 867 info.random = getattr(kernel_module, 'random', None) 849 850 # multiplicity info851 control_pars = [p.id for p in parameters.kernel_parameters if p.is_control]852 default_control = control_pars[0] if control_pars else None853 info.control = getattr(kernel_module, 'control', default_control)854 868 info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 855 869 … … 874 888 info.opencl = getattr(kernel_module, 'opencl', not callable(info.Iq)) 875 889 info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 890 891 # Set control flag for explicitly set parameters, e.g., in the RPA model. 892 control = getattr(kernel_module, 'control', None) 893 if control is not None: 894 parameters[control].is_control = True 876 895 877 896 if callable(info.Iq) and parameters.has_2d: … … 924 943 #: *sphere*hardsphere* or *cylinder+sphere*. 925 944 composition = None # type: Optional[Tuple[str, List[ModelInfo]]] 926 #: Name of the control parameter for a variant model such as :ref:`rpa`.927 #: The *control* parameter should appear in the parameter table, with928 #: limits defined as *[CASES]*, for case names such as929 #: *CASES = ["diblock copolymer", "triblock copolymer", ...]*.930 #: This should give *limits=[[case1, case2, ...]]*, but the931 #: model loader translates this to *limits=[0, len(CASES)-1]*, and adds932 #: *choices=CASES* to the :class:`Parameter` definition. Note that933 #: models can use a list of cases as a parameter without it being a934 #: control parameter. Either way, the parameter is sent to the model935 #: evaluator as *float(choice_num)*, where choices are numbered from 0.936 #: See also :attr:`hidden`.937 control = None # type: str938 945 #: Different variants require different parameters. In order to show 939 946 #: just the parameters needed for the variant selected by :attr:`control`, … … 999 1006 #: C code, either defined as a string, or in the sources. 1000 1007 shell_volume = None # type: Union[None, str, Callable[[np.ndarray], float]] 1008 #: Computes the effective radius of the shape given the volume parameters. 1009 #: Only needed for models defined in python that can be used for 1010 #: monodisperse approximation for non-dilute solutions, P@S. The first 1011 #: argument is the integer effective radius mode, with default 0. 1012 effective_radius = None # type: Union[None, Callable[[int, np.ndarray], float]] 1001 1013 #: Returns *I(q, a, b, ...)* for parameters *a*, *b*, etc. defined 1002 1014 #: by the parameter table. *Iq* can be defined as a python function, or … … 1010 1022 #: will return *I(q, a, b, ...)*. Multiplicity parameters are sent as 1011 1023 #: pointers to doubles. Constants in floating point expressions should 1012 #: include the decimal point. See :mod:`generate` for more details. 1024 #: include the decimal point. See :mod:`generate` for more details. If 1025 #: *have_Fq* is True, then Iq should return an interleaved array of 1026 #: $[\sum F(q_1), \sum F^2(q_1), \ldots, \sum F(q_n), \sum F^2(q_n)]$. 1013 1027 Iq = None # type: Union[None, str, Callable[[np.ndarray], np.ndarray]] 1014 1028 #: Returns *I(qab, qc, a, b, ...)*. The interface follows :attr:`Iq`.
Note: See TracChangeset
for help on using the changeset viewer.