Skip to content

Commit 131a7f7

Browse files
committed
Add display method for unregulargrid
1 parent 334d4c1 commit 131a7f7

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Fixed
1919
Added
2020
^^^^^
2121

22+
- Add display grid for unregular grid
23+
2224

2325
[3.6.0] - 2022-01-12
2426
--------------------

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
matplotlib
22
netCDF4
33
numba>=0.53
4-
numpy<1.21
4+
numpy<1.22
55
opencv-python
66
pint
77
polygon3

src/py_eddy_tracker/dataset/grid.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,21 @@ def load(self):
10741074

10751075
self.init_pos_interpolator()
10761076

1077+
def display(self, ax, name, factor=1, **kwargs):
1078+
"""
1079+
:param matplotlib.axes.Axes ax: matplotlib axes used to draw
1080+
:param str,array name: variable to display, could be an array
1081+
:param float factor: multiply grid by
1082+
:param dict kwargs: look at :py:meth:`matplotlib.axes.Axes.pcolormesh`
1083+
1084+
.. minigallery:: py_eddy_tracker.UnRegularGridDataset.display
1085+
"""
1086+
if "cmap" not in kwargs:
1087+
kwargs["cmap"] = "coolwarm"
1088+
data = self.grid(name) if isinstance(name, str) else name
1089+
print(self.x_c.shape, self.y_c.shape, data.shape)
1090+
return ax.pcolor(self.x_c, self.y_c, data * factor, **kwargs)
1091+
10771092
@property
10781093
def bounds(self):
10791094
"""Give bounds"""

0 commit comments

Comments
 (0)