Skip to content

Commit e5fe4f7

Browse files
committed
Update: figures for TDR
1 parent 1058ba2 commit e5fe4f7

File tree

1 file changed

+103
-66
lines changed

1 file changed

+103
-66
lines changed

wqf/val/tdr.py

Lines changed: 103 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from argparse import ArgumentDefaultsHelpFormatter
99
from argparse import ArgumentParser
1010

11+
import dask.array as da
1112
import numpy as np
1213
import xarray as xr
1314
from matplotlib import colors as plc
@@ -16,6 +17,7 @@
1617
from wqf.interface.constants import DID_LON
1718
from wqf.interface.constants import DID_TIM
1819
from wqf.readerfactory import ReaderFactory
20+
from wqf.val.period import Period
1921
from wqf.val.plots import DensityPlot
2022
from wqf.val.plots import HistogramPlot
2123
from wqf.val.plots import ScenePlot
@@ -33,22 +35,22 @@ def chlorophyll_quantiles():
3335
"""
3436
ScenePlot().plot(
3537
chl_q_lo,
36-
title="quantile q = 0.005",
38+
title="Observations 2016 - 2020",
3739
fn="fig01",
38-
cbar_label=r"chlorophyll concentration (mg m$^{-3}$)",
40+
cbar_label=r"quantile $0.01$ of chlorophyll concentration (mg m$^{-3}$)",
3941
norm=plc.LogNorm(),
4042
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
41-
vmin=1.0,
43+
vmin=0.1,
4244
vmax=100.0,
4345
).clear()
4446
ScenePlot().plot(
4547
chl_q_hi,
46-
title="quantile q = 0.995",
48+
title="Observations 2016 - 2020",
4749
fn="fig02",
48-
cbar_label=r"chlorophyll concentration (mg m$^{-3}$)",
50+
cbar_label=r"quantile $0.99$ of chlorophyll concentration (mg m$^{-3}$)",
4951
norm=plc.LogNorm(),
5052
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
51-
vmin=1.0,
53+
vmin=0.1,
5254
vmax=100.0,
5355
).clear()
5456

@@ -62,42 +64,75 @@ def chlorophyll_mean_and_std():
6264
rid of cloud contamination, if we excluded the upper percentile of
6365
chlorophyll concentration values.
6466
"""
67+
trn = Period(2016, 2019).slice(cube.chl)
68+
val = Period(2020, 2020).slice(cube.chl)
69+
6570
ScenePlot().plot(
66-
cube.chl.mean(DID_TIM),
67-
title="mean",
68-
cbar_label=r"chlorophyll concentration (mg m$^{-3}$)",
71+
xr.where(trn < chl_q_hi, trn, np.nan).mean(DID_TIM),
72+
title="Observations 2016 - 2019",
73+
fn="fig03a",
74+
cbar_label=r"mean chlorophyll concentration (mg m$^{-3}$)",
6975
norm=plc.LogNorm(),
7076
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
71-
vmin=1.0,
77+
vmin=0.1,
7278
vmax=100.0,
7379
).clear()
7480
ScenePlot().plot(
75-
cube.chl.std(DID_TIM),
76-
title="standard deviation",
77-
cbar_label=r"chlorophyll concentration (mg m$^{-3}$)",
81+
xr.where(val < chl_q_hi, val, np.nan).mean(DID_TIM),
82+
title="Observations 2020",
83+
fn="fig03b",
84+
cbar_label=r"mean chlorophyll concentration (mg m$^{-3}$)",
7885
norm=plc.LogNorm(),
7986
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
80-
vmin=1.0,
87+
vmin=0.1,
8188
vmax=100.0,
8289
).clear()
90+
std = xr.where(trn < chl_q_hi, trn, np.nan).std(DID_TIM)
8391
ScenePlot().plot(
84-
xr.where(cube.chl < chl_q_hi, cube.chl, np.nan).mean(DID_TIM),
85-
title="mean",
86-
fn="fig03",
87-
cbar_label=r"chlorophyll concentration (mg m$^{-3}$)",
92+
std,
93+
title="Observations 2016 - 2019",
94+
fn="fig04a",
95+
cbar_label=r"std. dev. chlorophyll concentration (mg m$^{-3}$)",
8896
norm=plc.LogNorm(),
8997
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
90-
vmin=1.0,
98+
vmin=0.1,
9199
vmax=100.0,
92100
).clear()
101+
std = xr.where(val < chl_q_hi, val, np.nan).std(DID_TIM)
93102
ScenePlot().plot(
94-
xr.where(cube.chl < chl_q_hi, cube.chl, np.nan).std(DID_TIM),
95-
title="standard deviation",
96-
fn="fig04",
97-
cbar_label=r"chlorophyll concentration (mg m$^{-3}$)",
103+
std,
104+
title="Observations 2020",
105+
fn="fig04b",
106+
cbar_label=r"std. dev. chlorophyll concentration (mg m$^{-3}$)",
98107
norm=plc.LogNorm(),
99108
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
100-
vmin=1.0,
109+
vmin=0.1,
110+
vmax=100.0,
111+
).clear()
112+
dev = da.sqrt(0.5 * da.square(
113+
xr.where(trn < chl_q_hi, trn, np.nan).diff(DID_TIM)).mean(
114+
DID_TIM))
115+
ScenePlot().plot(
116+
dev,
117+
title="Observations 2016 - 2020",
118+
fn="fig05a",
119+
cbar_label=r"Allan dev. chlorophyll concentration (mg m$^{-3}$)",
120+
norm=plc.LogNorm(),
121+
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
122+
vmin=0.1,
123+
vmax=100.0,
124+
).clear()
125+
dev = da.sqrt(0.5 * da.square(
126+
xr.where(val < chl_q_hi, val, np.nan).diff(DID_TIM)).mean(
127+
DID_TIM))
128+
ScenePlot().plot(
129+
dev,
130+
title="Observations 2020",
131+
fn="fig05b",
132+
cbar_label=r"Allan dev. chlorophyll concentration (mg m$^{-3}$)",
133+
norm=plc.LogNorm(),
134+
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
135+
vmin=0.1,
101136
vmax=100.0,
102137
).clear()
103138

@@ -117,9 +152,8 @@ def chlorophyll_variability():
117152
),
118153
),
119154
xlabel="day of year",
120-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
121-
title="mean CHL vs day of year",
122-
fn="fig05",
155+
ylabel=r"mean chlorophyll concentration (mg m$^{-3}$)",
156+
fn="fig08",
123157
bins=(50, 50),
124158
cbar_label="number count",
125159
density=False,
@@ -149,25 +183,37 @@ def number_of_chlorophyll_observations_from_space():
149183
chlorophyll concentration can be well described by an exponential
150184
distribution with a mean value of about 1.0 mg m-3.
151185
"""
152-
chl_count = cube.chl.count(dim="time") / cube.chl.shape[0]
153-
chl_count = xr.where(chl_count == 0, np.nan, 1.0 * chl_count)
186+
trn = Period(2016, 2019).slice(cube.chl)
187+
val = Period(2020, 2020).slice(cube.chl)
188+
trn_count = trn.count(dim="time") / trn.shape[0]
189+
trn_count = xr.where(trn_count == 0, np.nan, 1.0 * trn_count)
190+
val_count = val.count(dim="time") / val.shape[0]
191+
val_count = xr.where(val_count == 0, np.nan, 1.0 * val_count)
154192

155193
ScenePlot().plot(
156-
chl_count,
157-
title="number of observations",
158-
fn="fig06",
159-
cbar_label=r"number of observations (day$^{-1}$)",
194+
trn_count,
195+
title="Observations 2016 - 2019",
196+
fn="fig09a",
197+
cbar_label=r"frequency of observations (day$^{-1}$)",
160198
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
161-
vmin=0.1,
162-
vmax=0.5,
199+
vmin=0.0,
200+
vmax=1.0,
201+
).clear()
202+
ScenePlot().plot(
203+
val_count,
204+
title="Observations 2020",
205+
fn="fig09b",
206+
cbar_label=r"frequency of observations (day$^{-1}$)",
207+
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
208+
vmin=0.0,
209+
vmax=1.0,
163210
).clear()
164211
HistogramPlot().plot(
165212
cube.chl,
166213
xlabel=r"chlorophyll concentration (mg m$^{-3}$)",
167214
ylabel="number count",
168215
ylim=(100, 100000000),
169-
title="number distribution",
170-
fn="fig07",
216+
fn="fig10",
171217
bins=25,
172218
log=True,
173219
hist_range=(0.0, 100.0),
@@ -191,17 +237,15 @@ def depth_of_sea_floor():
191237
"""
192238
ScenePlot().plot(
193239
cube.deptho,
194-
title="sea floor depth",
195-
fn="fig08",
196-
cbar_label="depth (m)",
240+
fn="fig11",
241+
cbar_label="sea floor depth below geoid (m)",
197242
xlocs=(1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0),
198243
).clear()
199244
DensityPlot().plot(
200245
(cube.deptho, cube.chl.mean(DID_TIM)),
201-
xlabel="depth (m)",
202-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
203-
title="mean CHL vs sea floor depth",
204-
fn="fig09",
246+
xlabel="sea floor depth below geoid (m)",
247+
ylabel=r"mean chlorophyll concentration (mg m$^{-3}$)",
248+
fn="fig12",
205249
bins=(50, 50),
206250
cbar_label="number count",
207251
density=False,
@@ -210,10 +254,9 @@ def depth_of_sea_floor():
210254
).clear()
211255
DensityPlot().plot(
212256
(cube.deptho, cube.chl.std(DID_TIM)),
213-
xlabel="depth (m)",
214-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
215-
title="standard deviation CHL vs sea floor depth",
216-
fn="fig10",
257+
xlabel="sea floor depth below geoid (m)",
258+
ylabel=r"std. dev. of chlorophyll concentration (mg m$^{-3}$)",
259+
fn="fig13",
217260
bins=(50, 50),
218261
cbar_label="number count",
219262
density=False,
@@ -235,9 +278,8 @@ def examples_of_statistical_correlations():
235278
DensityPlot().plot(
236279
(cube.mdt, cube.chl.mean(DID_TIM)),
237280
xlabel="mean dynamic topography (m)",
238-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
239-
title="mean CHL vs mean dynamic topography",
240-
fn="fig11",
281+
ylabel=r"mean chlorophyll concentration (mg m$^{-3}$)",
282+
fn="fig14",
241283
bins=(50, 50),
242284
cbar_label="number count",
243285
density=False,
@@ -247,9 +289,8 @@ def examples_of_statistical_correlations():
247289
DensityPlot().plot(
248290
(cube.sst.mean(DID_TIM), cube.chl.mean(DID_TIM)),
249291
xlabel="sea surface temperature (K)",
250-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
251-
title="mean CHL vs mean SST",
252-
fn="fig12",
292+
ylabel=r"mean chlorophyll concentration (mg m$^{-3}$)",
293+
fn="fig15",
253294
bins=(50, 50),
254295
cbar_label="number count",
255296
density=False,
@@ -259,9 +300,8 @@ def examples_of_statistical_correlations():
259300
DensityPlot().plot(
260301
(cube.sst.std(DID_TIM), cube.chl.mean(DID_TIM)),
261302
xlabel="sea surface temperature (K)",
262-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
263-
title="mean CHL vs standard deviation SST",
264-
fn="fig13",
303+
ylabel=r"std. dev. of chlorophyll concentration (mg m$^{-3}$)",
304+
fn="fig16",
265305
bins=(50, 50),
266306
cbar_label="number count",
267307
density=False,
@@ -271,9 +311,8 @@ def examples_of_statistical_correlations():
271311
DensityPlot().plot(
272312
(cube.so.mean(DID_TIM), cube.chl.mean(DID_TIM)),
273313
xlabel="surface salinity (10-3)",
274-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
275-
title="mean CHL vs mean surface salinity",
276-
fn="fig14",
314+
ylabel=r"mean chlorophyll concentration (mg m$^{-3}$)",
315+
fn="fig17",
277316
bins=(50, 50),
278317
cbar_label="number count",
279318
density=False,
@@ -283,9 +322,8 @@ def examples_of_statistical_correlations():
283322
DensityPlot().plot(
284323
(cube.mlotst.mean(DID_TIM), cube.chl.mean(DID_TIM)),
285324
xlabel="mixed layer thickness (m)",
286-
ylabel=r"chlorophyll concentration (mg m$^{-3}$)",
287-
title="mean CHL vs mean mixed layer thickness",
288-
fn="fig15",
325+
ylabel=r"mean chlorophyll concentration (mg m$^{-3}$)",
326+
fn="fig18",
289327
bins=(50, 50),
290328
cbar_label="number count",
291329
density=False,
@@ -294,10 +332,9 @@ def examples_of_statistical_correlations():
294332
).clear()
295333
DensityPlot().plot(
296334
(cube.mlotst.mean(DID_TIM), cube.deptho),
297-
xlabel="sea floor depth (m)",
335+
xlabel="sea floor depth below geoid (m)",
298336
ylabel="mixed layer thickness (m)",
299-
title="mean mixed layer thickness vs sea floor depth",
300-
fn="fig16",
337+
fn="fig19",
301338
bins=(50, 50),
302339
cbar_label="number count",
303340
density=False,

0 commit comments

Comments
 (0)