CustomParameter#
- class CustomParameter(name: str, dimension: int = 1, units: Units | None = None, default=None, physical_type: str | None = None, partial=None, dynamics=None, partial_dynamics_by_param=None, partial_dynamics_by_position=None, partial_dynamics_by_velocity=None, step=None, register: bool = True)#
Bases:
objectDeclaration of a user-defined solve-for parameter of a custom force model.
A
CustomParameteris the script-side counterpart of the built-in estimable parameters (eta_srp,gm,a_fogm, …): it names a new component that may be added to aStateArray, estimated by the orbit-determination filters, and read back inside the acceleration function of aCustomDynamicModel— all from a user script, with no change to the library source.Constructing the object registers name with
register_custom_parameter(), so the parameter passes state-vector validation from that point on.Two flavours are supported:
static (
dynamics=None, the default) — a constant to be estimated, e.g. a drag coefficient. The filter needs only \(\partial \mathbf{a} / \partial p\).dynamic (
dynamicssupplied) — a parameter with its own equation of motion \(\dot p = f(\mathbf r, \mathbf v, p, t)\), integrated along with the state. The filter additionally needs \(\partial \dot p / \partial p\), \(\partial \dot p / \partial \mathbf r\) and \(\partial \dot p / \partial \mathbf v\).
Every Jacobian defaults to a central finite difference of the corresponding user function, so a working setup needs no hand-derived partials; supply the analytic callables when accuracy or speed matters.
- Parameters:
- namestr
State-component name, e.g.
"drag_cd". Must be a plain identifier and must not collide with a built-in component name.- dimensionint, optional
Number of scalar elements. Defaults to 1.
- unitsUnits, optional
Units of the parameter itself. Used for the state-vector physical-type check and to label the partial derivatives.
None(default) means dimensionless / unchecked.- defaultfloat or array_like, optional
Fallback value used when the parameter is absent from the propagated state (i.e. when the model runs without estimating it). Defaults to zeros.
- physical_typestr, optional
Unit-dimension name enforced on the state entry (e.g.
"Acceleration"). Defaults toNone, which skips the check.- partialcallable, optional
\(\partial \mathbf{a} / \partial p\), returning a
(3, dimension)array. Defaults to a finite difference of the model’s acceleration.- dynamicscallable, optional
\(\dot p\), returning a
(dimension,)array. Supplying it makes the parameter dynamic; it must then be added to the state withdynamics="dynamic".- partial_dynamics_by_paramcallable, optional
\(\partial \dot p / \partial p\), returning
(dimension, dimension). Defaults to a finite difference ofdynamics.- partial_dynamics_by_positioncallable, optional
\(\partial \dot p / \partial \mathbf r\), returning
(dimension, 3). Defaults to a finite difference ofdynamics.- partial_dynamics_by_velocitycallable, optional
\(\partial \dot p / \partial \mathbf v\), returning
(dimension, 3). Defaults to a finite difference ofdynamics.- stepfloat or array_like, optional
Absolute finite-difference step used for this parameter. Defaults to
1e-6 * max(|p|, 1)evaluated at each call.- registerbool, optional
Register the name with
StateDefinitionon construction. Defaults toTrue.
- Attributes:
acceleration_partial_unitsUnits of \(\partial \mathbf a / \partial p\).
defaultFallback value used when the parameter is absent from the state.
dimensionNumber of scalar elements of this parameter.
dynamicsUser callable returning \(\dot p\), or
Nonewhen static.is_dynamicTruewhen the parameter carries its own equation of motion.nameState-component name of this parameter.
partialUser callable returning \(\partial \mathbf a / \partial p\), or
None.partial_dynamics_by_paramUser callable returning \(\partial \dot p / \partial p\), or
None.partial_dynamics_by_positionUser callable returning \(\partial \dot p / \partial \mathbf r\), or
None.partial_dynamics_by_velocityUser callable returning \(\partial \dot p / \partial \mathbf v\), or
None.rate_unitsUnits of \(\dot p\).
unitsUnits of the parameter value, or
Nonewhen dimensionless.
Methods
finite_difference_step(values)Return the per-element finite-difference step for values.
rate_partial_units(with_respect_to)Units of a Jacobian of \(\dot p\) w.r.t.
resolve(current_state, spice_id)Read this parameter's current value out of the propagated state.
See also
scarabaeus.CustomDynamicModelForce model that consumes these parameters.
scarabaeus.StateDefinitionState builder; see
custom_param.
Notes
All user callables are called with keyword arguments drawn from the evaluation context; declare only the ones you need. See
CustomDynamicModelfor the available names.Examples
A drag coefficient estimated as a constant:
import scarabaeus as scb cd = scb.CustomParameter("drag_cd", default=2.2)
An exponentially decaying empirical scale factor:
tau = 3600.0 k = scb.CustomParameter( "emp_scale", default=1.0, dynamics=lambda params: -params["emp_scale"] / tau, )
- finite_difference_step(values: ndarray) ndarray#
Return the per-element finite-difference step for values.
- Parameters:
- valuesnumpy.ndarray
Current parameter value.
- Returns:
- numpy.ndarray
Absolute step size for each element. Uses the explicit
stepgiven at construction, otherwise a relative step of1e-6 * max(|p|, 1).
- rate_partial_units(with_respect_to: str) Units#
Units of a Jacobian of \(\dot p\) w.r.t. position or velocity.
- Parameters:
- with_respect_tostr
"position"or"velocity".
- Returns:
- Units
Units of the requested Jacobian block.
- resolve(current_state: dict, spice_id) ndarray#
Read this parameter’s current value out of the propagated state.
- Parameters:
- current_statedict
State mapping
(name, spice_id) -> valueshanded to the force models on every right-hand-side evaluation.- spice_idint or None
SPICE ID of the body owning the parameter.
- Returns:
- numpy.ndarray
The estimated value when present in the state, otherwise
default.
- property dynamics#
User callable returning \(\dot p\), or
Nonewhen static.
- property partial#
User callable returning \(\partial \mathbf a / \partial p\), or
None.
- property partial_dynamics_by_param#
User callable returning \(\partial \dot p / \partial p\), or
None.
- property partial_dynamics_by_position#
User callable returning \(\partial \dot p / \partial \mathbf r\), or
None.
- property partial_dynamics_by_velocity#
User callable returning \(\partial \dot p / \partial \mathbf v\), or
None.
- exception DimensionError#
Bases:
ValueErrorRaised when a supplied value does not match the declared dimension.