Skip to content

Commit f47b64c

Browse files
committed
new analyses
1 parent 99eca8c commit f47b64c

File tree

3 files changed

+172
-148
lines changed

3 files changed

+172
-148
lines changed

src/02-analysis/03-Ro_restratification.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,25 @@
1212
# --- Loading data
1313
#####
1414

15-
yslice = slice(-130, 130)
16-
17-
ds = xr.open_dataset("../../data/raw/output_submesoscale.nc")
18-
ds = ds.assign_coords(time=ds.time.astype("float")*1e-9/86400)
19-
ds = ds.assign_coords(xC=ds.xC*1e-3, yC=ds.yC*1e-3)
20-
submeso = ds.sel(yC=yslice)
21-
22-
23-
ds = xr.open_dataset("../../data/raw/output_coarse_mle.nc")
24-
ds = ds.assign_coords(time=ds.time.astype("float")*1e-9/86400)
25-
ds = ds.assign_coords(xC=ds.xC*1e-3, yC=ds.yC*1e-3)
26-
coarse = ds.sel(yC=yslice)
2715

16+
yslice = slice(-130, 130)
2817

18+
data = dict(
19+
submesoscale = dict(label="1 km"),
20+
coarse_mle = dict(label="10 km\n(MLE)"),
21+
coarse_averaging = dict(label="10 km\n(averaging)")
22+
)
2923

30-
ds = xr.open_dataset("../../data/raw/output_coarse_no_mle.nc")
31-
ds = ds.assign_coords(time=ds.time.astype("float")*1e-9/86400)
32-
ds = ds.assign_coords(xC=ds.xC*1e-3, yC=ds.yC*1e-3)
33-
coarse_no_mle = ds.sel(yC=yslice)
24+
sinking = True
3425

26+
sinking_text = "" if sinking else "_nosinking"
27+
for k in tqdm(data):
3528

29+
ds = xr.open_dataset(f"../../data/raw/output_{k}{sinking_text}.nc").sel(time=slice(None,None,3))
30+
ds = ds.assign_coords(time=ds.time.astype("float")*1e-9/86400)
31+
ds = ds.assign_coords(xC=ds.xC*1e-3, yC=ds.yC*1e-3)
32+
data[k]["D"] = ds.sel(yC=yslice)
3633

37-
data = dict(
38-
submeso=dict(D=submeso, label="1 km"),
39-
coarse_no_mle=dict(D=coarse_no_mle, label="10 km\n(no MLE)"),
40-
coarse=dict(D=coarse, label="10 km"),
41-
)
4234

4335

4436

@@ -62,7 +54,7 @@
6254

6355
for col,k in enumerate(data):
6456
if "coarse" in k:
65-
ax[0,col].axhspan(0,coarse.time.min(), facecolor="w", edgecolor="0.7", hatch="//")
57+
ax[0,col].axhspan(0,60, facecolor="w", edgecolor="0.7", hatch="//")
6658
D = data[k]["D"]
6759
a = ax[0,col]
6860
H = histogram(D.Ro.sel(zC=slice(zmin,0)), bins=bins, dim=["xC", "yC", "zC"])
@@ -77,7 +69,7 @@
7769

7870

7971
a = ax[1,col]
80-
H = histogram(D.Ro.sel(time=ti), bins=bins, dim=["xC", "yC"])
72+
H = histogram(D.Ro.sel(time=ti,method="nearest"), bins=bins, dim=["xC", "yC"])
8173
H = H/H.sum("Ro_bin")
8274
H.plot(ax=a, **kw["pdf"])
8375
ct = (H/H.sum("Ro_bin")).cumsum("Ro_bin").plot.contour(ax=a, **kw["cdf"])
@@ -92,7 +84,7 @@
9284
letters = "a b c d".split()
9385
_ = [a.set(title=f"{letter})"+60*" ") for a,letter in zip(np.ravel(ax),letters)]
9486

95-
fig.savefig("../../reports/figures/Ro_pdf.png", facecolor="w", dpi=300, bbox_inches="tight")
87+
fig.savefig(f"../../reports/figures/Ro_pdf{sinking_text}.png", facecolor="w", dpi=300, bbox_inches="tight")
9688

9789
# --- MLD and N2
9890
#####
@@ -124,8 +116,7 @@
124116
text.set_path_effects([path_effects.Stroke(linewidth=2, foreground='w'),
125117
path_effects.Normal()])
126118

127-
if k=="coarse":
128-
a.axvspan(0,coarse.time.min(), facecolor="w", edgecolor="0.7", hatch="//")
119+
a.axvspan(0,60, facecolor="w", edgecolor="0.7", hatch="//",zorder=0)
129120

130121
p = "N2"
131122
a = ax[row,1]
@@ -139,9 +130,9 @@
139130
text.set_path_effects([path_effects.Stroke(linewidth=2, foreground='w'),
140131
path_effects.Normal()])
141132
ax[row,1].set(ylim=[data[k]["D"].sel(zC=slice(zmin,0)).zC.min(),0])
142-
if k=="coarse":
143-
a.axvspan(0,coarse.time.min(), facecolor="w", edgecolor="0.7", hatch="//")
144133

134+
a.axvspan(0,60, facecolor="w", edgecolor="0.7", hatch="//",zorder=0)
135+
145136
fig.colorbar(C1, ax=ax[:,0], orientation="horizontal", label="mld [m]", ticks=[-210,-160,-110,-60,-10,0])
146137
fig.colorbar(C2, ax=ax[:,1], orientation="horizontal", label="N$^2$ [s$^{-1}$]")
147138

@@ -151,4 +142,4 @@
151142
letters = "a b c d".split()
152143
_ = [a.set(title=f"{letter})"+70*" ") for a,letter in zip(np.ravel(ax),letters)]
153144

154-
fig.savefig("../../reports/figures/mld_n2.png", facecolor="w", dpi=300, bbox_inches="tight")
145+
fig.savefig(f"../../reports/figures/mld_n2{sinking_text}.png", facecolor="w", dpi=300, bbox_inches="tight")

0 commit comments

Comments
 (0)