|
1 | 1 | from numpy import arange, array, nan, ones, zeros
|
2 | 2 |
|
3 |
| -from py_eddy_tracker.generic import cumsum_by_track, simplify |
| 3 | +from py_eddy_tracker.generic import cumsum_by_track, simplify, wrap_longitude |
4 | 4 |
|
5 | 5 |
|
6 | 6 | def test_simplify():
|
@@ -30,3 +30,22 @@ def test_cumsum_by_track():
|
30 | 30 | a = ones(10, dtype="i4") * 2
|
31 | 31 | track = array([1, 1, 2, 2, 2, 2, 44, 44, 44, 48])
|
32 | 32 | assert (cumsum_by_track(a, track) == [2, 4, 2, 4, 6, 8, 2, 4, 6, 2]).all()
|
| 33 | + |
| 34 | + |
| 35 | +def test_wrapping(): |
| 36 | + y = x = arange(-5,5, dtype='f4') |
| 37 | + x_, _ = wrap_longitude(x, y, ref=-10) |
| 38 | + assert (x_ == x).all() |
| 39 | + x_, _ = wrap_longitude(x, y, ref=1) |
| 40 | + assert x.size == x_.size |
| 41 | + assert (x_[6:] == x[6:]).all() |
| 42 | + assert (x_[:6] == x[:6] + 360).all() |
| 43 | + x_, _ = wrap_longitude(x, y, ref=1, cut=True) |
| 44 | + assert x.size + 3 == x_.size |
| 45 | + assert (x_[6 + 3:] == x[6:]).all() |
| 46 | + assert (x_[:7] == x[:7] + 360).all() |
| 47 | + |
| 48 | + # FIXME Need evolution in wrap_longitude |
| 49 | + # x %= 360 |
| 50 | + # x_, _ = wrap_longitude(x, y, ref=-10, cut=True) |
| 51 | + # assert x.size == x_.size |
0 commit comments