Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add display method for unregulargrid
  • Loading branch information
AntSimi committed Apr 6, 2022
commit 131a7f75255c3db64d8464b8ba220df480a2c22d
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Fixed
Added
^^^^^

- Add display grid for unregular grid


[3.6.0] - 2022-01-12
--------------------
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
matplotlib
netCDF4
numba>=0.53
numpy<1.21
numpy<1.22
opencv-python
pint
polygon3
Expand Down
15 changes: 15 additions & 0 deletions src/py_eddy_tracker/dataset/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,21 @@ def load(self):

self.init_pos_interpolator()

def display(self, ax, name, factor=1, **kwargs):
"""
:param matplotlib.axes.Axes ax: matplotlib axes used to draw
:param str,array name: variable to display, could be an array
:param float factor: multiply grid by
:param dict kwargs: look at :py:meth:`matplotlib.axes.Axes.pcolormesh`

.. minigallery:: py_eddy_tracker.UnRegularGridDataset.display
"""
if "cmap" not in kwargs:
kwargs["cmap"] = "coolwarm"
data = self.grid(name) if isinstance(name, str) else name
print(self.x_c.shape, self.y_c.shape, data.shape)
return ax.pcolor(self.x_c, self.y_c, data * factor, **kwargs)

@property
def bounds(self):
"""Give bounds"""
Expand Down