Return x, y grid-coordinates of trajectory based on starting point. Integrate both forward and backward in time from starting point in grid coordinates. Integration is terminated when a trajectory reaches a domain boundary or when it crosses into an already occupied
(x0, y0)
| 432 | return -dxi, -dyi |
| 433 | |
| 434 | def integrate(x0, y0): |
| 435 | """Return x, y grid-coordinates of trajectory based on starting point. |
| 436 | |
| 437 | Integrate both forward and backward in time from starting point in |
| 438 | grid coordinates. |
| 439 | |
| 440 | Integration is terminated when a trajectory reaches a domain boundary |
| 441 | or when it crosses into an already occupied cell in the StreamMask. The |
| 442 | resulting trajectory is None if it is shorter than `minlength`. |
| 443 | """ |
| 444 | |
| 445 | stotal, x_traj, y_traj = 0., [], [] |
| 446 | |
| 447 | try: |
| 448 | dmap.start_trajectory(x0, y0) |
| 449 | except InvalidIndexError: |
| 450 | return None |
| 451 | if integration_direction in ['both', 'backward']: |
| 452 | s, xt, yt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength) |
| 453 | stotal += s |
| 454 | x_traj += xt[::-1] |
| 455 | y_traj += yt[::-1] |
| 456 | |
| 457 | if integration_direction in ['both', 'forward']: |
| 458 | dmap.reset_start_point(x0, y0) |
| 459 | s, xt, yt = _integrate_rk12(x0, y0, dmap, forward_time, maxlength) |
| 460 | if len(x_traj) > 0: |
| 461 | xt = xt[1:] |
| 462 | yt = yt[1:] |
| 463 | stotal += s |
| 464 | x_traj += xt |
| 465 | y_traj += yt |
| 466 | |
| 467 | if stotal > minlength: |
| 468 | return x_traj, y_traj |
| 469 | else: # reject short trajectories |
| 470 | dmap.undo_trajectory() |
| 471 | return None |
| 472 | |
| 473 | return integrate |
| 474 |
no test coverage detected