curryer.correction.parameters ============================= .. py:module:: curryer.correction.parameters .. autoapi-nested-parse:: Parameter set generation for the correction pipeline. This module provides :func:`load_param_sets`, which generates parameter sets for correction analysis. Three search strategies are supported: ``RANDOM`` (default) Monte Carlo random walk. Each parameter is sampled from a normal distribution centered on ``current_value`` with the configured ``sigma``, clipped to ``bounds``. Controlled by ``seed`` and ``n_iterations``. ``GRID_SEARCH`` Deterministic cartesian-product sweep. ``grid_points_per_param`` evenly-spaced offset values are produced for each parameter (spanning its full ``bounds`` range) and the cartesian product of all per-parameter grids is enumerated. ``n_iterations`` is ignored for this strategy. ``SINGLE_OFFSET`` Deterministic single-parameter sweep. Each parameter is varied independently across ``n_iterations`` evenly-spaced values while all other parameters are held at their nominal ``current_value``. Supported parameter types: - ``CONSTANT_KERNEL`` – 3-D attitude corrections (roll, pitch, yaw) stored as a ``pandas.DataFrame`` with ``ugps``, ``angle_x``, ``angle_y``, ``angle_z``. - ``OFFSET_KERNEL`` – single-axis angle bias (float, in radians). - ``OFFSET_TIME`` – timing correction (float, in seconds). Attributes ---------- .. autoapisummary:: curryer.correction.parameters.logger curryer.correction.parameters._UGPS_EPOCH_END Functions --------- .. autoapisummary:: curryer.correction.parameters._arcsec_to_rad curryer.correction.parameters._bounds_to_rad curryer.correction.parameters._val_to_rad curryer.correction.parameters._val_to_seconds curryer.correction.parameters._bounds_to_seconds curryer.correction.parameters._make_ck_dataframe curryer.correction.parameters._scalar_current_value curryer.correction.parameters._get_nominal_value curryer.correction.parameters._get_grid_values curryer.correction.parameters._generate_random curryer.correction.parameters._generate_grid_search curryer.correction.parameters._generate_single_offset curryer.correction.parameters._log_param_set_summary curryer.correction.parameters.load_param_sets Module Contents --------------- .. py:data:: logger .. py:data:: _UGPS_EPOCH_END :value: 2209075218000000 .. py:function:: _arcsec_to_rad(value: float) -> float Convert arcseconds to radians. .. py:function:: _bounds_to_rad(bounds: list[float], units: str | None) -> list[float] .. py:function:: _val_to_rad(value: float, units: str | None) -> float .. py:function:: _val_to_seconds(value: float, units: str | None) -> float .. py:function:: _bounds_to_seconds(bounds: list[float], units: str | None) -> list[float] .. py:function:: _make_ck_dataframe(angle_vals: list[float]) -> pandas.DataFrame Wrap ``[angle_x, angle_y, angle_z]`` (radians) into the pipeline DataFrame format. .. py:function:: _scalar_current_value(param: curryer.correction.config.ParameterConfig) -> float Return ``param.spec.current_value`` as a scalar float. :raises TypeError: If ``current_value`` is not a scalar numeric type. This helps surface misconfigured parameters early instead of silently coercing them to 0.0. .. py:function:: _get_nominal_value(param: curryer.correction.config.ParameterConfig) -> Any Return the un-perturbed, unit-converted value for *param*. For ``CONSTANT_KERNEL``, returns a :class:`~pandas.DataFrame` with angles equal to the ``current_value`` in radians. For ``OFFSET_KERNEL`` / ``OFFSET_TIME``, returns a float in radians / seconds respectively. .. py:function:: _get_grid_values(param: curryer.correction.config.ParameterConfig, n_points: int) -> list[Any] Return *n_points* evenly-spaced sampled values for *param*. Offsets are linearly spaced over ``[bounds[0], bounds[1]]`` (in the parameter's native units before conversion) and added to the converted ``current_value``. For ``CONSTANT_KERNEL`` the scalar offset is applied uniformly to all three rotation axes. :param param: Parameter specification. :type param: ParameterConfig :param n_points: Number of evenly-spaced points (>= 2). :type n_points: int :returns: List of *n_points* values; each element matches what the pipeline expects for that parameter type (DataFrame or float). :rtype: list .. py:function:: _generate_random(sweep: curryer.correction.config.Sweep) -> list[list[tuple[curryer.correction.config.ParameterConfig, Any]]] Generate random parameter sets – exact current behaviour preserved. .. py:function:: _generate_grid_search(sweep: curryer.correction.config.Sweep) -> list[list[tuple[curryer.correction.config.ParameterConfig, Any]]] Generate parameter sets via deterministic cartesian-product grid sweep. Produces ``grid_points_per_param ^ len(parameters)`` parameter sets. ``n_iterations`` is not used for this strategy. :raises ValueError: If the total number of parameter sets would exceed ``sweep.max_grid_sets``. Increase ``max_grid_sets`` deliberately, reduce ``grid_points_per_param`` or the number of parameters, or use ``SearchStrategy.SINGLE_OFFSET`` instead. .. py:function:: _generate_single_offset(sweep: curryer.correction.config.Sweep) -> list[list[tuple[curryer.correction.config.ParameterConfig, Any]]] Generate parameter sets by sweeping one parameter at a time. For each parameter in ``sweep.parameters``: - ``n_iterations`` evenly-spaced values are generated spanning the parameter's full ``bounds`` offset range. - All other parameters are held at their nominal ``current_value``. Total parameter sets produced: ``len(parameters) × n_iterations``. .. py:function:: _log_param_set_summary(output: list[list[tuple[curryer.correction.config.ParameterConfig, Any]]]) -> None Log a structured summary of the generated parameter sets. High-level counts are always emitted at INFO. The full per-set detail (angles / offsets for every set) is emitted at DEBUG only, so large GRID_SEARCH / SINGLE_OFFSET sweeps do not flood the INFO log. .. py:function:: load_param_sets(sweep: curryer.correction.config.Sweep) -> list[list[tuple[curryer.correction.config.ParameterConfig, Any]]] Generate parameter sets for correction iterations. Dispatches to the appropriate generator based on ``sweep.search_strategy``: - :attr:`~SearchStrategy.RANDOM` – Monte Carlo random walk (default). - :attr:`~SearchStrategy.GRID_SEARCH` – deterministic cartesian-product sweep across ``grid_points_per_param`` evenly-spaced values per parameter. - :attr:`~SearchStrategy.SINGLE_OFFSET` – deterministic single-parameter sweep; each parameter is varied independently while others stay at nominal. :param sweep: The parameter-variation experiment: parameters, search strategy, and sampling settings. :type sweep: Sweep :returns: Outer list: one element per parameter set (iteration). Inner list: one ``(ParameterConfig, sampled_value)`` pair per parameter. ``sampled_value`` is a :class:`~pandas.DataFrame` for ``CONSTANT_KERNEL`` and a ``float`` for ``OFFSET_KERNEL`` / ``OFFSET_TIME``. :rtype: list[list[tuple[ParameterConfig, Any]]]