Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SOFRESH Sea Surface Salinity

ESA
import xarray as xr
import matplotlib.pyplot as plt
url = 'https://s3.waw4-1.cloudferro.com/EarthCODE/OSCAssets/polar_cube_datasets/so-fresh/sofresh.zarr/'
ds = xr.open_zarr(url)
ds
Loading...
da = ds['sss']
subset = da.sel(
    time=["2011-02-01", "2016-01-01", "2021-01-01"],
    method="nearest"
)
vmin = subset.min(skipna=True).values
vmax = subset.max(skipna=True).values

fig, axes = plt.subplots(
    nrows=1,
    ncols=3,
    figsize=(18, 6),
    constrained_layout=True
)

for ax, t in zip(axes, subset.time):
    plot_data = da.sel(time=t)

    im = ax.pcolormesh(
        ds["x"],
        ds["y"],
        plot_data,
        shading="auto",
        vmin=vmin,
        vmax=vmax,
        cmap="viridis"
    )

    ax.set_title(f"SSS\n{t.dt.strftime('%Y-%m-%d %H:%M').item()}")
    ax.set_xlabel("x [m]")
    ax.set_ylabel("y [m]")
    ax.set_aspect("equal")

# shared colorbar
cbar = fig.colorbar(im, ax=axes, orientation="vertical", shrink=0.8)
cbar.set_label("Sea Surface Salinity")

plt.show()
<Figure size 1800x600 with 4 Axes>