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
(x0, y0, broken_streamlines=True, integration_max_step_scale=1.0,
integration_max_error_scale=1.0)
| 515 | return -dxi, -dyi |
| 516 | |
| 517 | def integrate(x0, y0, broken_streamlines=True, integration_max_step_scale=1.0, |
| 518 | integration_max_error_scale=1.0): |
| 519 | """ |
| 520 | Return x, y grid-coordinates of trajectory based on starting point. |
| 521 | |
| 522 | Integrate both forward and backward in time from starting point in |
| 523 | grid coordinates. |
| 524 | |
| 525 | Integration is terminated when a trajectory reaches a domain boundary |
| 526 | or when it crosses into an already occupied cell in the StreamMask. The |
| 527 | resulting trajectory is None if it is shorter than `minlength`. |
| 528 | """ |
| 529 | |
| 530 | stotal, xy_traj = 0., [] |
| 531 | |
| 532 | try: |
| 533 | dmap.start_trajectory(x0, y0, broken_streamlines) |
| 534 | except InvalidIndexError: |
| 535 | return None |
| 536 | if integration_direction in ['both', 'backward']: |
| 537 | s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength, |
| 538 | broken_streamlines, |
| 539 | integration_max_step_scale, |
| 540 | integration_max_error_scale) |
| 541 | stotal += s |
| 542 | xy_traj += xyt[::-1] |
| 543 | |
| 544 | if integration_direction in ['both', 'forward']: |
| 545 | dmap.reset_start_point(x0, y0) |
| 546 | s, xyt = _integrate_rk12(x0, y0, dmap, forward_time, maxlength, |
| 547 | broken_streamlines, |
| 548 | integration_max_step_scale, |
| 549 | integration_max_error_scale) |
| 550 | stotal += s |
| 551 | xy_traj += xyt[1:] |
| 552 | |
| 553 | if stotal > minlength: |
| 554 | return np.broadcast_arrays(xy_traj, np.empty((1, 2)))[0] |
| 555 | else: # reject short trajectories |
| 556 | dmap.undo_trajectory() |
| 557 | return None |
| 558 | |
| 559 | return integrate |
| 560 |
no test coverage detected
searching dependent graphs…