Skip to content

Commit e94012a

Browse files
committed
Save cost association
1 parent 24520cd commit e94012a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/py_eddy_tracker/tracking.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def merge(self, until=-1, raw_data=True):
616616
# Set type of eddy with first file
617617
eddies.sign_type = self.current_obs.sign_type
618618
# Fields to copy
619-
fields = self.current_obs.obs.dtype.descr
619+
fields = self.current_obs.obs.dtype.names
620620

621621
# To know if the track start
622622
first_obs_save_in_tracks = zeros(self.i_current_by_tracks.shape, dtype=bool_)
@@ -639,10 +639,9 @@ def merge(self, until=-1, raw_data=True):
639639
index_in = self[i]["in"][m_first_obs]
640640
# Copy all variable
641641
for field in fields:
642-
var = field[0]
643-
if var == "cost_association":
642+
if field == "cost_association":
644643
continue
645-
eddies[var][index_final[m_first_obs]] = self.previous_obs[var][
644+
eddies[field][index_final[m_first_obs]] = self.previous_obs[field][
646645
index_in
647646
]
648647
# Increment
@@ -666,13 +665,11 @@ def merge(self, until=-1, raw_data=True):
666665
# Index in the current file
667666
index_current = self[i]["out"]
668667

668+
if "cost_association" in eddies.obs.dtype.names:
669+
eddies["cost_association"][index_final - 1] = self[i]["cost_value"]
669670
# Copy all variable
670671
for field in fields:
671-
var = field[0]
672-
if var == "cost_association":
673-
eddies[var][index_final - 1] = self[i]["cost_value"]
674-
else:
675-
eddies[var][index_final] = self.current_obs[var][index_current]
672+
eddies[field][index_final] = self.current_obs[field][index_current]
676673

677674
# Add increment for each index used
678675
self.i_current_by_tracks[i_id] += 1

0 commit comments

Comments
 (0)