Custom Identification
=====================

The starting template for use. If you want to identify areas and track them via overlap, you can use `overlap_example` instead.

We provide some template files, which we recommend as a starting point for your own identification strategy. If you want to add your own identification (and tracking) strategy to the framework, you need to:

- Copy over the template folder and rename it and the files accordingly. If you implement a tracking method, which relys on pairwise comparison of objects from consecutive timesteps, you can use the `template_object_compare`
- In the `__init__.py`, rename the class name to your identification strategy.
- In the `*.proto` file, define the variables each of the detected objects should have. They follow the `protobuf protocol <https://developers.google.com/protocol-buffers/docs/proto>`_. The template file also provides a useful example. proto-files are compiled automatically on running the identification.
- In the `identification.py` (`tracking.py`), implement your identification (tracking) strategy. See the template again for a useful example. There are a few methods:
    - `__init__` gets called from the run script, so the user can set parameters for the algorithm here.
    - `precompute` is called once for the entire data set. The data set can be altered here (temporally and spatially). Also if the strategy should return an additional field (`DataArray`), it should be initialized here as shown in the template.
    - In `identify` goes your identification technique. This method is called in parallel, and should return a list of objects. See the template and the docstrings for more information. It returns the provided subset (which can be modified in terms of values), and a list of objects. New (empty) objects can be obtained using `o = self.get_new_object(id=obj_id)`, returning an object `o` with the set ID `o.id` and the object properties defined via the protobuf description at `o.properties`.
    - `postprocess` is called once for the entire data set after identification. The data set and the object description can be changed here.


Template class
--------------

.. autoclass:: enstools.feature.identification.template.IdentificationTemplate