Skip to content

Commit 08c553a

Browse files
committed
update the plotting function
1 parent b4a84f7 commit 08c553a

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

apecosm/mplot.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .misc import extract_community_names
1616
from .constants import LTL_NAMES
1717
from math import ceil
18+
import numpy as np
1819

1920
plt.rcParams['text.usetex'] = False
2021

@@ -88,17 +89,43 @@ def plot_oope_map(data, mesh, axis=None, draw_land=True, **kwargs):
8889
axis = plt.gca()
8990
lonf = mesh['glamf'].values
9091
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)
92120

93121
if isinstance(axis, geoaxes.GeoAxesSubplot):
94122
projected = True
95-
quadmesh = plt.pcolormesh(lonf, latf, var_to_plot,
123+
quadmesh = plt.pcolormesh(lonf, latf, var_to_plot[1:, 1:],
96124
transform=PROJIN, **kwargs)
97125
else:
98126
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:
102129
axis.add_feature(cfeature.LAND, zorder=1000)
103130
axis.add_feature(cfeature.COASTLINE, zorder=1001)
104131

doc/data_extract.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ function:
136136
spatial_mean_phy2
137137
138138
This function will first vertically **integrate** the LTL biomass
139-
(converting from :math:`mmol/m3` into :math:`mmol/m2`). Then
139+
(converting from :math:`mmol/m3` into :math:`mmol/m2`, term in
140+
brackets in :eq:`pisces_mean`). Then
140141
the horizontal **average** is computed. This choice has been made to
141142
be consistent with Apecosm outputs. Indeed, OOPE is provided as a vertically
142143
integrated biomass. Therefore, vertical integration need to be performed

0 commit comments

Comments
 (0)