Skip to content

Commit 2fee0f6

Browse files
authored
JOSS manuscript (#265)
Manuscript for submission to JOSS.
1 parent d928293 commit 2fee0f6

File tree

13 files changed

+1590
-1
lines changed

13 files changed

+1590
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ src/virtualship/_version_setup.py
179179

180180
.vscode/
181181
.DS_Store
182+
183+
184+
# some files created during paper (JOSS) writing
185+
docs/paper/**/*.txt

docs/paper/figure1.png

2.48 MB
Loading

docs/paper/figure1.py

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# %%
2+
3+
import cartopy.crs as ccrs
4+
import matplotlib.gridspec as gridspec
5+
import matplotlib.image as mpimg
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
import xarray as xr
9+
from plotting_functions import (
10+
_ctd_distance_along_expedition,
11+
plot_adcp,
12+
plot_ctd,
13+
plot_drifters,
14+
)
15+
16+
SAMPLE_DIR = "sample_expedition/"
17+
CONFIG = "expedition.yaml"
18+
EXPEDITION = "MY_EXPEDITION"
19+
20+
# %%
21+
22+
# VirtualShip output
23+
ctd_ds = xr.open_dataset(f"{SAMPLE_DIR}{EXPEDITION}/results/ctd.zarr")
24+
ctd_bgc_ds = xr.open_dataset(f"{SAMPLE_DIR}{EXPEDITION}/results/ctd_bgc.zarr")
25+
drifter_ds = xr.open_dataset(f"{SAMPLE_DIR}{EXPEDITION}/results/drifter.zarr")
26+
adcp_ds = xr.open_dataset(f"{SAMPLE_DIR}{EXPEDITION}/results/adcp.zarr")
27+
28+
29+
# %%
30+
31+
# plot
32+
33+
PROJ = ccrs.PlateCarree()
34+
35+
waypoint_distances = np.unique(_ctd_distance_along_expedition(ctd_ds)["distance"])
36+
37+
38+
def add_waypoint_markers(ax, distances, offset=15, marker_size=70):
39+
ax.scatter(
40+
(distances / 1000),
41+
np.zeros_like(distances) - offset,
42+
marker="v",
43+
color="black",
44+
edgecolors="white",
45+
s=marker_size,
46+
clip_on=False,
47+
)
48+
49+
50+
def add_title(ax, title, fontsize=13, y0=1.03):
51+
"""Add title."""
52+
ax.text(
53+
0,
54+
y0,
55+
title,
56+
ha="left",
57+
va="bottom",
58+
transform=ax.transAxes,
59+
fontsize=fontsize,
60+
)
61+
62+
63+
# fig
64+
fig = plt.figure(figsize=(9, 13), dpi=300)
65+
66+
# custom layout
67+
gs = gridspec.GridSpec(3, 2, height_ratios=[1.5, 1, 1])
68+
ax0 = fig.add_subplot(gs[0, :])
69+
ax1 = fig.add_subplot(gs[1, 0])
70+
ax2 = fig.add_subplot(gs[1, 1], projection=PROJ)
71+
ax3 = fig.add_subplot(gs[2, 0])
72+
ax4 = fig.add_subplot(gs[2, 1])
73+
74+
# overview image
75+
add_title(ax0, r"$\bf{a}$" + ") MFP expedition overview", y0=1.01)
76+
img = mpimg.imread(f"{SAMPLE_DIR}expedition_overview.png")
77+
ax0.imshow(img)
78+
ax0.axis("off")
79+
80+
# adcp
81+
add_title(ax1, r"$\bf{b}$" + ") ADCP (flow speed)")
82+
ax1.set_ylabel("Depth (m)")
83+
ax1.set_xlabel("Distance (km)")
84+
plot_adcp(adcp_ds, ax1)
85+
add_waypoint_markers(ax1, waypoint_distances)
86+
87+
# drifters
88+
add_title(ax2, r"$\bf{c}$" + ") Surface drifters")
89+
plot_drifters(
90+
drifter_ds,
91+
ax2,
92+
vmin=drifter_ds.temperature.min(),
93+
vmax=drifter_ds.temperature.max(),
94+
)
95+
96+
# CTD (temperature)
97+
add_title(ax3, r"$\bf{d}$" + ") CTD (temperature)")
98+
ax3.set_ylabel("Depth (m)")
99+
ax3.set_xlabel("Distance (km)")
100+
_, _distances_regular, _var_masked = plot_ctd(
101+
ctd_ds,
102+
ax3,
103+
plot_variable="temperature",
104+
vmin=ctd_ds.temperature.min(),
105+
vmax=ctd_ds.temperature.max(),
106+
)
107+
108+
ctd_wp_distances = _distances_regular[np.nansum(_var_masked, axis=1) > 0]
109+
add_waypoint_markers(ax3, ctd_wp_distances, offset=45, marker_size=60)
110+
111+
# CTD (oxygen)
112+
add_title(ax4, r"$\bf{e}$" + ") CTD (oxygen)")
113+
ax4.set_xlabel("Distance (km)")
114+
plot_ctd(
115+
ctd_bgc_ds, ax4, plot_variable="oxygen", vmin=0, vmax=ctd_bgc_ds.o2.max()
116+
) # vmin tailored to mark red as approximate oxygen minimum zone (~ 45 mmol/m-3)
117+
add_waypoint_markers(ax4, ctd_wp_distances, offset=45, marker_size=60)
118+
119+
120+
plt.tight_layout()
121+
plt.show()
122+
123+
fig.savefig("figure1.png", dpi=300, bbox_inches="tight")
124+
125+
# %%

docs/paper/jats/figure1.png

2.48 MB
Loading

0 commit comments

Comments
 (0)