|
15 | 15 | from .misc import extract_community_names
|
16 | 16 | from .constants import LTL_NAMES
|
17 | 17 | from math import ceil
|
| 18 | +import numpy as np |
18 | 19 |
|
19 | 20 | plt.rcParams['text.usetex'] = False
|
20 | 21 |
|
@@ -88,17 +89,43 @@ def plot_oope_map(data, mesh, axis=None, draw_land=True, **kwargs):
|
88 | 89 | axis = plt.gca()
|
89 | 90 | lonf = mesh['glamf'].values
|
90 | 91 | latf = mesh['gphif'].values
|
91 |
| - var_to_plot = data.isel(x=slice(1, None), y=slice(1, None)) |
| 92 | + tmask = mesh['tmask'].isel(z=0).values |
| 93 | + var_to_plot_temp = data.values |
| 94 | + nlat_grid, nlon_grid = lonf.shape |
| 95 | + nlat_data, nlon_data = var_to_plot_temp.shape |
| 96 | + |
| 97 | + # If the data array does not have the save dimension as the grid, |
| 98 | + # i.e. new Nemo format, we reconstruct the zonal cyclicity |
| 99 | + if (nlon_data == nlon_grid - 2) & (nlat_data == nlat_grid - 1): |
| 100 | + # init an array of the same size as the grid except for |
| 101 | + # the northfold band (top row) |
| 102 | + var_to_plot = np.zeros((nlat_data, nlon_grid), dtype=float) |
| 103 | + |
| 104 | + # fill inner bound |
| 105 | + var_to_plot[:, 1:-1] = var_to_plot_temp |
| 106 | + |
| 107 | + # add cyclicity |
| 108 | + var_to_plot[:, 0] = var_to_plot[:, -2] |
| 109 | + var_to_plot[:, -1] = var_to_plot[:, 1] |
| 110 | + |
| 111 | + # Remove upper row |
| 112 | + lonf = lonf[:-1, :] |
| 113 | + latf = latf[:-1, :] |
| 114 | + tmask = tmask[:-1, :] |
| 115 | + |
| 116 | + else: |
| 117 | + var_to_plot = var_to_plot_temp |
| 118 | + |
| 119 | + var_to_plot = np.ma.masked_where(tmask == 0, var_to_plot) |
92 | 120 |
|
93 | 121 | if isinstance(axis, geoaxes.GeoAxesSubplot):
|
94 | 122 | projected = True
|
95 |
| - quadmesh = plt.pcolormesh(lonf, latf, var_to_plot, |
| 123 | + quadmesh = plt.pcolormesh(lonf, latf, var_to_plot[1:, 1:], |
96 | 124 | transform=PROJIN, **kwargs)
|
97 | 125 | else:
|
98 | 126 | projected = False
|
99 |
| - quadmesh = plt.pcolormesh(lonf, latf, var_to_plot, **kwargs) |
100 |
| - if projected: |
101 |
| - if draw_land: |
| 127 | + quadmesh = plt.pcolormesh(var_to_plot, **kwargs) |
| 128 | + if projected and draw_land: |
102 | 129 | axis.add_feature(cfeature.LAND, zorder=1000)
|
103 | 130 | axis.add_feature(cfeature.COASTLINE, zorder=1001)
|
104 | 131 |
|
|
0 commit comments