Skip to content

Commit 4b1f449

Browse files
committed
Add options to speed up tracking
1 parent f2ab857 commit 4b1f449

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/py_eddy_tracker/featured_tracking/area_tracker.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77

88
class AreaTracker(Model):
9+
10+
@classmethod
11+
def needed_variable(cls):
12+
vars = ['longitude', 'latitude']
13+
vars.extend(cls.intern(False, public_label=True))
14+
return vars
15+
916
def tracking(self, other):
1017
shape = (self.shape[0], other.shape[0])
1118
i, j, c = self.match(other, intern=False)

src/py_eddy_tracker/observations/observation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ def __getitem__(self, attr):
282282
return self.observations[attr]
283283
raise KeyError("%s unknown" % attr)
284284

285+
@classmethod
286+
def needed_variable(cls):
287+
return None
288+
285289
@classmethod
286290
def obs_dimension(cls, handler):
287291
for candidate in ("obs", "Nobs", "observation", "i"):

src/py_eddy_tracker/tracking.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,16 @@ def track(self):
363363
self.reset_dataset_cache()
364364
first_dataset, flg_virtual = self.load_state()
365365

366-
self.swap_dataset(self.datasets[first_dataset - 1])
366+
kwargs = dict()
367+
needed_variable = self.class_method.needed_variable()
368+
if needed_variable is not None:
369+
kwargs['include_vars'] = needed_variable
370+
self.swap_dataset(self.datasets[first_dataset - 1], **kwargs)
367371
# We begin with second file, first one is in previous
368372
for file_name in self.datasets[first_dataset:]:
369-
self.swap_dataset(file_name)
370-
logger.info('%s match with previous state', file_name)
371-
logger.debug('%d obs to match', len(self.current_obs))
373+
self.swap_dataset(file_name, **kwargs)
374+
logger.info("%s match with previous state", file_name)
375+
logger.debug("%d obs to match", len(self.current_obs))
372376

373377
nb_real_obs = len(self.previous_obs)
374378
if flg_virtual:

0 commit comments

Comments
 (0)