@@ -112,7 +112,7 @@ def store_correspondance(self, i_previous, i_current, nb_real_obs):
112
112
# Set an id for each match
113
113
correspondance ['id' ] = self .id_generator (nb_match )
114
114
self .append (correspondance )
115
- return
115
+ return True
116
116
117
117
# We set all id to UINT32_MAX
118
118
id_previous = ones (len (self .previous_obs ),
@@ -123,6 +123,33 @@ def store_correspondance(self, i_previous, i_current, nb_real_obs):
123
123
# track it before
124
124
correspondance ['id' ] = id_previous [correspondance ['in' ]]
125
125
126
+ # We set correspondance data for virtual obs : ID/LENGTH
127
+ if self .previous2_obs is not None and self .virtual :
128
+ nb_rebirth = correspondance ['virtual' ].sum ()
129
+ if nb_rebirth != 0 :
130
+ logging .debug ('%d re-birth due to prolongation with'
131
+ ' virtual observations' , nb_rebirth )
132
+ ## Set id for virtual
133
+ # get correspondance mask using virtual obs
134
+ m_virtual = correspondance ['virtual' ]
135
+ # index of virtual in virtual obs
136
+ i_virtual = correspondance ['in' ][m_virtual ] - nb_real_obs
137
+ correspondance ['id' ][m_virtual ] = \
138
+ self .virtual_obs ['track' ][i_virtual ]
139
+ correspondance ['virtual_length' ][m_virtual ] = \
140
+ self .virtual_obs ['segment_size' ][i_virtual ]
141
+
142
+ # new_id is equal to UINT32_MAX we must add a new ones
143
+ # we count the number of new
144
+ mask_new_id = correspondance ['id' ] == self .UINT32_MAX
145
+ nb_new_tracks = mask_new_id .sum ()
146
+ logging .debug ('%d birth in this step' , nb_new_tracks )
147
+ # Set new id
148
+ correspondance ['id' ][mask_new_id ] = self .id_generator (nb_new_tracks )
149
+
150
+ self .append (correspondance )
151
+
152
+ return False
126
153
127
154
def id_generator (self , nb_id ):
128
155
"""Generation id and incrementation
@@ -134,14 +161,14 @@ def id_generator(self, nb_id):
134
161
def recense_dead_id_to_extend (self ):
135
162
"""Recense dead id to extend in virtual observation
136
163
"""
137
- nb_virtual_extend = 0
138
164
# List previous id which are not use in the next step
139
165
dead_id = setdiff1d (self [- 2 ]['id' ], self [- 1 ]['id' ])
140
166
nb_dead = dead_id .shape [0 ]
141
167
logging .debug ('%d death of real obs in this step' , nb_dead )
142
168
if not self .virtual :
143
169
return
144
- #
170
+ # get id already dead from few time
171
+ nb_virtual_extend = 0
145
172
if self .virtual_obs is not None :
146
173
virtual_dead_id = setdiff1d (self .virtual_obs ['track' ],
147
174
self [- 1 ]['id' ])
@@ -192,7 +219,6 @@ def recense_dead_id_to_extend(self):
192
219
def track (self ):
193
220
"""Run tracking
194
221
"""
195
- START = True
196
222
FLG_VIRTUAL = False
197
223
self .reset_dataset_cache ()
198
224
self .swap_dataset (self .datasets [0 ])
@@ -210,54 +236,10 @@ def track(self):
210
236
self .previous_obs = self .previous_obs .merge (self .virtual_obs )
211
237
212
238
i_previous , i_current = self .previous_obs .tracking (self .current_obs )
213
- nb_match = i_previous .shape [0 ]
214
239
215
- #~ self.store_correspondance(i_previous, i_current, nb_real_obs)
216
- correspondance = array (i_previous , dtype = self .correspondance_dtype )
217
- correspondance ['out' ] = i_current
218
-
219
- if self .virtual :
220
- correspondance ['virtual' ] = i_previous >= nb_real_obs
221
-
222
- if START :
223
- START = False
224
- # Set an id for each match
225
- correspondance ['id' ] = self .id_generator (nb_match )
226
- self .append (correspondance )
240
+ if self .store_correspondance (i_previous , i_current , nb_real_obs ):
227
241
continue
228
242
229
- # We set all id to UINT32_MAX
230
- id_previous = ones (len (self .previous_obs ), dtype = self .ID_DTYPE ) * self .UINT32_MAX
231
- # We get old id for previously eddies tracked
232
- previous_id = self [- 1 ]['id' ]
233
- id_previous [self [- 1 ]['out' ]] = previous_id
234
- correspondance ['id' ] = id_previous [correspondance ['in' ]]
235
-
236
- # We set correspondance data for virtual obs : ID/LENGTH
237
- if FLG_VIRTUAL :
238
- nb_rebirth = correspondance ['virtual' ].sum ()
239
- if nb_rebirth != 0 :
240
- logging .debug ('%d re-birth due to prolongation with'
241
- ' virtual observations' , nb_rebirth )
242
- # Set id for virtual
243
- m_virtual = correspondance ['virtual' ]
244
- # index of virtual in virtual obs
245
- i_virtual = correspondance ['in' ][m_virtual ] - nb_real_obs
246
- correspondance ['id' ][m_virtual ] = \
247
- self .virtual_obs ['track' ][i_virtual ]
248
- correspondance ['virtual_length' ][m_virtual ] = \
249
- self .virtual_obs ['segment_size' ][i_virtual ]
250
-
251
- # new_id is equal to UINT32_MAX we must add a new ones
252
- # we count the number of new
253
- mask_new_id = correspondance ['id' ] == self .UINT32_MAX
254
- nb_new_tracks = mask_new_id .sum ()
255
- logging .debug ('%d birth in this step' , nb_new_tracks )
256
- # Set new id
257
- correspondance ['id' ][mask_new_id ] = self .id_generator (nb_new_tracks )
258
-
259
- self .append (correspondance )
260
-
261
243
self .recense_dead_id_to_extend ()
262
244
263
245
if self .virtual :
0 commit comments