Create some visualizations of the region#

Author: Andy Barrett

%pip install cmocean
Collecting cmocean
  Using cached cmocean-4.0.3-py3-none-any.whl.metadata (4.2 kB)
Requirement already satisfied: matplotlib in /srv/conda/envs/notebook/lib/python3.11/site-packages (from cmocean) (3.9.1)
Requirement already satisfied: numpy in /srv/conda/envs/notebook/lib/python3.11/site-packages (from cmocean) (1.26.4)
Requirement already satisfied: packaging in /srv/conda/envs/notebook/lib/python3.11/site-packages (from cmocean) (24.1)
Requirement already satisfied: contourpy>=1.0.1 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (1.2.1)
Requirement already satisfied: cycler>=0.10 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (4.53.1)
Requirement already satisfied: kiwisolver>=1.3.1 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (1.4.5)
Requirement already satisfied: pillow>=8 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (10.2.0)
Requirement already satisfied: pyparsing>=2.3.1 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (3.1.2)
Requirement already satisfied: python-dateutil>=2.7 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from matplotlib->cmocean) (2.8.2)
Requirement already satisfied: six>=1.5 in /srv/conda/envs/notebook/lib/python3.11/site-packages (from python-dateutil>=2.7->matplotlib->cmocean) (1.16.0)
Using cached cmocean-4.0.3-py3-none-any.whl (421 kB)
Installing collected packages: cmocean
Successfully installed cmocean-4.0.3
Note: you may need to restart the kernel to use updated packages.
import numpy as np

import xarray as xr
import hvplot.xarray

import cartopy.crs as ccrs
import cartopy.feature as cfeature

import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm, BoundaryNorm
import cmocean
ds = xr.open_zarr("~/shared/mind_the_chl_gap/IO.zarr")
ds
<xarray.Dataset> Size: 66GB
Dimensions:                       (time: 16071, lat: 177, lon: 241)
Coordinates:
  * lat                           (lat) float32 708B 32.0 31.75 ... -11.75 -12.0
  * lon                           (lon) float32 964B 42.0 42.25 ... 101.8 102.0
  * time                          (time) datetime64[ns] 129kB 1979-01-01 ... ...
Data variables: (12/27)
    CHL                           (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    CHL_cmes-cloud                (time, lat, lon) uint8 686MB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    CHL_cmes-gapfree              (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    CHL_cmes-land                 (lat, lon) uint8 43kB dask.array<chunksize=(177, 241), meta=np.ndarray>
    CHL_cmes-level3               (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    CHL_cmes_flags-gapfree        (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    ...                            ...
    ug_curr                       (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    v_curr                        (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    v_wind                        (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    vg_curr                       (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    wind_dir                      (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
    wind_speed                    (time, lat, lon) float32 3GB dask.array<chunksize=(100, 177, 241), meta=np.ndarray>
Attributes: (12/92)
    Conventions:                     CF-1.8, ACDD-1.3
    DPM_reference:                   GC-UD-ACRI-PUG
    IODD_reference:                  GC-UD-ACRI-PUG
    acknowledgement:                 The Licensees will ensure that original ...
    citation:                        The Licensees will ensure that original ...
    cmems_product_id:                OCEANCOLOUR_GLO_BGC_L3_MY_009_103
    ...                              ...
    time_coverage_end:               2024-04-18T02:58:23Z
    time_coverage_resolution:        P1D
    time_coverage_start:             2024-04-16T21:12:05Z
    title:                           cmems_obs-oc_glo_bgc-plankton_my_l3-mult...
    westernmost_longitude:           -180.0
    westernmost_valid_longitude:     -180.0
ds.lat.size * ds.lon.size
42657

Plot bathymetry#

projection = ccrs.Stereographic(central_longitude=75., central_latitude=10.)
ax = ds.topo.plot(transform=ccrs.PlateCarree(), 
                                     subplot_kws=dict(projection=projection),
                                     cmap=cmocean.cm.topo)
ax.axes.coastlines()
<cartopy.mpl.feature_artist.FeatureArtist at 0x7fdac2ef1bd0>
../_images/c1c1a803a651a88a50f6d4e3aab96c92758f21fa672d3b24be09185b6cb71a4f.png

Plot climatology of cloud cover by month#

A first klugey effort

idx = (ds.CHL.isnull().sum(dim=["lat","lon"]) < (ds.lat.size * ds.lon.size)).compute()
ds = ds.sel(time=ds.time[idx])
ds.CHL.isnull().sum(dim=["lat","lon"]).plot(marker='o', ls="")
[<matplotlib.lines.Line2D at 0x7fdacc8411d0>]
../_images/f3637e1acf1ed67d1d1b6e5e7bc5603a6420e4731b80742f03ca7b0e24e56912.png
chl_count = ds.CHL.isnull().groupby(ds.time.dt.month).sum() / ds.CHL.groupby(ds.time.dt.month).count()
bounds = [0.001, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]  #np.arange(0,1.1,0.1)
norm = BoundaryNorm(bounds, ncolors=256, clip=True)
p = chl_count.plot(
    col="month", 
    col_wrap=3, 
    norm=norm, 
    cmap="plasma",
    transform=ccrs.PlateCarree(),
    subplot_kws=dict(
        projection=projection,
    ),
    cbar_kwargs=dict(
        orientation="horizontal", 
        spacing="proportional", 
        extend="neither"),
    )
#[ax.axes.add_feature(cfeature.LAND) for ax in p.axs.flat];
[ax.axes.coastlines() for ax in p.axs.flat];
p.fig.subplots_adjust(bottom=0.2)
# plt.tight_layout()
../_images/e1689b0d25ea5e9ee3928a41724f1d12859b225aa73c5fddefd4d3589c61f67e.png

Plot climatologies#

  • Winds

  • SST

  • CHL

  • Currents

ds_mon = ds.resample({"time":'MS'}).mean()
ds_clm = ds_mon.groupby(ds_mon.time.dt.month).mean()
ds_clm
<xarray.Dataset> Size: 61MB
Dimensions:                       (month: 12, lat: 177, lon: 241)
Coordinates:
  * lat                           (lat) float32 708B 32.0 31.75 ... -11.75 -12.0
  * lon                           (lon) float32 964B 42.0 42.25 ... 101.8 102.0
  * month                         (month) int64 96B 1 2 3 4 5 6 7 8 9 10 11 12
Data variables: (12/27)
    CHL                           (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    CHL_cmes-cloud                (month, lat, lon) float64 4MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    CHL_cmes-gapfree              (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    CHL_cmes-level3               (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    CHL_cmes_flags-gapfree        (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    CHL_cmes_flags-level3         (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    ...                            ...
    v_wind                        (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    vg_curr                       (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    wind_dir                      (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    wind_speed                    (month, lat, lon) float32 2MB dask.array<chunksize=(3, 177, 241), meta=np.ndarray>
    CHL_cmes-land                 (month, lat, lon) float64 4MB dask.array<chunksize=(12, 177, 241), meta=np.ndarray>
    topo                          (month, lat, lon) float64 4MB dask.array<chunksize=(12, 177, 241), meta=np.ndarray>
Attributes: (12/92)
    Conventions:                     CF-1.8, ACDD-1.3
    DPM_reference:                   GC-UD-ACRI-PUG
    IODD_reference:                  GC-UD-ACRI-PUG
    acknowledgement:                 The Licensees will ensure that original ...
    citation:                        The Licensees will ensure that original ...
    cmems_product_id:                OCEANCOLOUR_GLO_BGC_L3_MY_009_103
    ...                              ...
    time_coverage_end:               2024-04-18T02:58:23Z
    time_coverage_resolution:        P1D
    time_coverage_start:             2024-04-16T21:12:05Z
    title:                           cmems_obs-oc_glo_bgc-plankton_my_l3-mult...
    westernmost_longitude:           -180.0
    westernmost_valid_longitude:     -180.0

Chlorophyl#

norm = LogNorm(vmin=0.00001, vmax=15., clip=True)
ds_clm["CHL_cmes-gapfree"].plot(col="month", col_wrap=4, norm=norm, cmap=cmocean.cm.algae)
<xarray.plot.facetgrid.FacetGrid at 0x7fdac04dffd0>
../_images/ff4d848298846890e6f67bd7cb80a7ae710826d2e9cc9560b9b308f3271dee7d.png

SST#

ds_clm.sst.plot(col="month", col_wrap=4, cmap=cmocean.cm.thermal)
<xarray.plot.facetgrid.FacetGrid at 0x7fdac0a9b090>
../_images/77a716810221f64ebba173fc384db65a10a744b59b3218e0c40fd13656ef403a.png
ds_clm.v_curr.max().values
array(1.5294565, dtype=float32)
every=8
p = ds_clm.isel(lon=slice(None,None,every), lat=slice(None,None,every)).plot.quiver(x="lon", y="lat", 
            u="u_curr", v="v_curr", 
            hue="curr_speed",
            cmap=cmocean.cm.speed, 
            scale=2, 
            subplot_kws={"projection": projection},
            transform=ccrs.PlateCarree(), 
            cbar_kwargs={"orientation": "horizontal", },
            col="month", col_wrap=4)

[ax.axes.coastlines() for ax in p.axs.flat];
../_images/520dc21356a39e56bdb35052dec27b3b07135cfbd6fa9bd7edf2ded57ae30624.png
ds_clm["CHL_cmes-gapfree"].hvplot(groupby="month", cnorm="log")