RelativeOpNav.register

giant.relative_opnav.relnav_class:

classmethod RelativeOpNav.register(technique_class)[source]

This class method registers a new RelNav technique with the RelativeOpNav class.

This method is intended to be used as a decorator, therefore typical use would look like

@RelativeOpNav.register
class MyNewClass(RelNavEstimator):
    pass

When the module containing this code is imported, MyNewClass will be registered with the RelativeOpNav class. It is import to note here that registration must be done before creating an instance of RelativeOpNav, so ensure that at some point the module with the new technique is imported. Alternatively you can use this as a standalone function call

RelativeOpNav.register(MyNewClass)

before creating an instance of RelativeOpNav, but to do this you would have had to import the module containing the new technique anyway so the decorator method would have been fine as well.

Registering a technique does a number of things. First, it creates a new property that returns the instance of the class that defines the technique. This property will be assigned to either the class attribute technique of the class representing the new technique, or the defining module of the new technique.

Second, the new technique is registered so that one initializing the RelativeOpNav object, you can specify the technique name as a keyword argument to provide a pre-initialized version of the technique class, or you can specify the technique_name followed by _kwargs to specify the key word arguments to pass to the class at initialization.

Third, a new method is created called {technique}_estimate where {technique} is replaced by the technique name. This method, like the others named like it, will apply the technique to all images currently turned on in the camera for all targets and store the results.

There are a few ways that this registration is controlled. The first way you can control it is by specifying a name for the new technique as a class attribute of the class that implements the new technique. This attribute should be called technique and should be a string.

The second control is implemented through the class attribute observable_type. This attribute controls how the {technique}_estimate method is built and should be a string, a value from RelNavObservablesType, or a container of those values.. The type chooses how the types will be interpreted for the new technique. There are some common built in types that can be combined together for most RelNav observables ('CENTER-FINDING', 'LIMB', 'LANDMARK', 'RELATIVE-POSITION'). Setting these allows the RelativeOpNav class to automatically handle packaging the results from the estimation, so long as you followed the conventions laid out in the relative_opnav.estimators documentation. Alternatively, you can specify this to be 'CUSTOM' ('CUSTOM' cannot be an element in a container, it must be on its own), in which case the estimate method to use can be supplied using the relnav_estimator class attribute which should point to a function that takes a single argument, the current instance of the RelativeOpNav class. Typically however, if you have to make a custom estimator method then there is minimal benefit to registering the new technique with the RelNav class.

All of this assumes that the class describing the new technique is built according to the template provided by RelNavEstimator. For more details on building/registering a new technique refer to the relative_opnav.estimators documentation. This also assumes that the technique has not already been registered. If the technique has already been registered either a warning will be printed to screen, or an error raised (if the technique was registered with a different handler class first).

Raises:
  • ValueError – If the technique name is not a valid identifier

  • ValueError – If the technique has already been registered with a different class

  • ValueError – If a custom type is chosen but the relnav_estimator is None

Parameters:

technique_class (Type[RelNavEstimator]) –

Return type:

Type[RelNavEstimator]

Note

This does not modify the implementation of the RelNav technique class in any way, it modifies the RelativeOpNav class itself. The returned class object will be exactly the same as what was input.

Parameters:

technique_class (Type[RelNavEstimator]) – A class representing the new technique to use built according to the outline in relative_opnav.estimators.

Return type:

Type[RelNavEstimator]