Skip to content
AntSimi edited this page Jul 3, 2020 · 5 revisions

How do I create my own tracking recipe?

You can create your own tracking procedure with inheritance of py_eddy_tracker.observations.EddiesObservations

To do this you simply create a new class in a python file

from py_eddy_tracker.observations.observation import EddiesObservations as Model

class MyTracking(Model):

   def mask_function(self, other, distance):
       """The role of this function, it's to reduce the number of case to investigate
       self : observation from timestamp t
       other : observation from the next timestamp
       distance : matrix of distance between self observation and other observation
       """
       # We keep only association under 150 km
       mask = distance < 150
       return mask

   @classmethod
   def cost_function(cls, *args, **kwargs):
       """This method will be call after mask_function
       args will contains : 
           observation from t which must be compare with observation from next timestep
       """
       # Compute intersection between two polygons and return ratio of intersection on area of first polygon
       values = cls.cost_function_common_area(*args, **kwargs)
       # 1 - poly_in.intersection(poly_out).area / poly_in.area
       # we mask tiny intersection
       m = values > .9
       values.mask += m
       return values

In order to use this new tracking method the new file must be in your PYTHONPATH, and you need to specify the following in your yaml file:

PATHS:
  # Files produces with EddyIdentification
  FILES_PATTERN: {files_in}
  SAVE_DIR: {output_path}

CLASS:
    MODULE: my_filename
    CLASS: MyTracking

Run this in the command line as: $ EddyTracking my_tracking.yaml

Common functions, which can be overwritten:

class MyTracking(Model):

    @staticmethod
    def propagate(previous_obs, current_obs, obs_to_extend, dead_track, nb_next, model):
        """
        In order to filled virtual obs (C)
        Args:
            previous_obs: previous obs from current (A)
            current_obs: previous obs from virtual (B)
        Returns:
            New position C = B + AB
        """

    def mask_function(self, other, distance):
        """In order to do a preselection on candidate to match, it must be lowcost

        Some basic geographic function are available:
             - shifted_ellipsoid_degrees_mask
             - fixed_ellipsoid_mask
        """

    def solve_function(self, cost_matrix):
        """Select match with the cost_matrix, in order to solve conflict
        return a list of match

        two function are already usable : solve_simultaneous, solve_first
        """

    def post_process_link(self, other, i_self, i_other):
        """Do some selection on the list of match
        When two self obs use the same other obs ? what did you do?
        """
Clone this wiki locally