|
8 | 8 | from numba import njit
|
9 | 9 | from numpy import arange, array, bincount, empty, ones, uint32, unique
|
10 | 10 |
|
11 |
| -from ..generic import build_index |
| 11 | +from ..generic import build_index, wrap_longitude |
12 | 12 | from ..poly import bbox_intersection, vertice_overlap
|
13 | 13 | from .observation import EddiesObservations
|
14 | 14 | from .tracking import TrackEddiesObservations
|
@@ -232,16 +232,84 @@ def scatter_timeline(self, ax, name, factor=1, event=True, **kwargs):
|
232 | 232 | return mappables
|
233 | 233 |
|
234 | 234 | def insert_virtual(self):
|
| 235 | + # TODO |
235 | 236 | pass
|
236 | 237 |
|
237 | 238 | def merging_event(self):
|
238 |
| - pass |
| 239 | + indices = list() |
| 240 | + for i, b0, b1 in self.iter_on("segment"): |
| 241 | + nb = i.stop - i.start |
| 242 | + if nb == 0: |
| 243 | + continue |
| 244 | + i_n = self.next_obs[i.stop - 1] |
| 245 | + if i_n != -1: |
| 246 | + indices.append(i.stop - 1) |
| 247 | + indices = list(set(indices)) |
| 248 | + nb = len(indices) |
| 249 | + new = EddiesObservations( |
| 250 | + nb, |
| 251 | + track_extra_variables=self.track_extra_variables, |
| 252 | + track_array_variables=self.track_array_variables, |
| 253 | + array_variables=self.array_variables, |
| 254 | + only_variables=self.only_variables, |
| 255 | + raw_data=self.raw_data, |
| 256 | + ) |
| 257 | + |
| 258 | + for k in new.obs.dtype.names: |
| 259 | + new[k][:] = self[k][indices] |
| 260 | + new.sign_type = self.sign_type |
| 261 | + return new |
239 | 262 |
|
240 | 263 | def spliting_event(self):
|
241 |
| - pass |
| 264 | + indices = list() |
| 265 | + for i, b0, b1 in self.iter_on("segment"): |
| 266 | + nb = i.stop - i.start |
| 267 | + if nb == 0: |
| 268 | + continue |
| 269 | + i_p = self.previous_obs[i.start] |
| 270 | + if i_p != -1: |
| 271 | + indices.append(i.start) |
| 272 | + indices = list(set(indices)) |
| 273 | + nb = len(indices) |
| 274 | + new = EddiesObservations( |
| 275 | + nb, |
| 276 | + track_extra_variables=self.track_extra_variables, |
| 277 | + track_array_variables=self.track_array_variables, |
| 278 | + array_variables=self.array_variables, |
| 279 | + only_variables=self.only_variables, |
| 280 | + raw_data=self.raw_data, |
| 281 | + ) |
| 282 | + |
| 283 | + for k in new.obs.dtype.names: |
| 284 | + new[k][:] = self[k][indices] |
| 285 | + new.sign_type = self.sign_type |
| 286 | + return new |
242 | 287 |
|
243 | 288 | def fully_connected(self):
|
244 | 289 | self.only_one_network()
|
| 290 | + # TODO |
| 291 | + |
| 292 | + def plot(self, ax, ref=None, **kwargs): |
| 293 | + """ |
| 294 | + This function will draw path of each trajectory |
| 295 | +
|
| 296 | + :param matplotlib.axes.Axes ax: ax to draw |
| 297 | + :param float,int ref: if defined, all coordinates will be wrapped with ref like west boundary |
| 298 | + :param dict kwargs: keyword arguments for Axes.plot |
| 299 | + :return: a list of matplotlib mappables |
| 300 | + """ |
| 301 | + mappables = list() |
| 302 | + if "label" in kwargs: |
| 303 | + kwargs["label"] = self.format_label(kwargs["label"]) |
| 304 | + for i, b0, b1 in self.iter_on("segment"): |
| 305 | + nb = i.stop - i.start |
| 306 | + if nb == 0: |
| 307 | + continue |
| 308 | + x, y = self.lon[i], self.lat[i] |
| 309 | + if ref is not None: |
| 310 | + x, y = wrap_longitude(x, y, ref, cut=True) |
| 311 | + mappables.append(ax.plot(x, y, **kwargs)[0]) |
| 312 | + return mappables |
245 | 313 |
|
246 | 314 | def remove_dead_branch(self, nobs=3):
|
247 | 315 | """"""
|
|
0 commit comments