# Use case: Climate DT ocean surface over the North Atlantic Earth Data Hub offers an innovative and super-efficient way to access data. Here we present how to access the Destination Earth Digital Twin for Climate Change Adaptation (Climate DT) ocean data and combine three variables on a single map of the North Atlantic: the sea surface temperature, the sea ice concentration and the sea surface height. Note that we will be using the IFS-NEMO daily ocean dataset of the SSP3-7.0 scenario at high resolution, which contains several global 2D ocean variables. The notebook comprises the following steps: 1. access the data, opening the dataset and choosing the day, the area and the map projection, 2. select the data, keeping only the day and the area of interest, 3. plot the ocean surface, downloading only the data needed for the map. #### NOTE To run this notebook locally, follow the setup instructions in the [GitHub repository](https://github.com/bopen/edh-learning). ## Setup the environment **If you haven’t done it already, follow the** [Getting started notebook](https://earthdatahub.destine.eu/docs/notebooks/edh-learning/00-getting-started.md) **to setup your environment and DestinE credentials.** **Note:** the Climate DT datasets require upgraded access. See the [Earth Data Hub documentation](https://earthdatahub.destine.eu/docs/data-access.html#upgraded-access) to find out how to apply. This notebook also needs the optional map dependency *cartopy*. If you are using `uv` as in the README, start Jupyter Lab with `uv run --frozen --extra maps jupyter lab`. ```python import cartopy.crs as ccrs import matplotlib.pyplot as plt import numpy as np import xarray as xr from matplotlib.colors import LightSource ``` ## Access the Climate DT data ### Open the dataset We open the dataset using the code snippet found on its dataset page in the [Earth Data Hub catalogue](https://earthdatahub.destine.eu/collections/climate-dt-2/datasets/IFS-NEMO-SSP3-7.0-o2d-daily-high). The following assumes you set up your EDH API key in your *netrc* file. Opening the dataset only reads its metadata, so it is fast even if the dataset is very large. ```python url = "https://api.earthdatahub.destine.eu/climate-dt-2/IFS-NEMO-SSP3-7.0-o2d-daily-high-v0.zarr" ds = xr.open_dataset( url, storage_options={"client_kwargs": {"trust_env": True}}, chunks={}, engine="zarr", ) ds ``` ```text Size: 21TB Dimensions: (time: 12784, latitude: 4096, longitude: 8193) Coordinates: * time (time) datetime64[ns] 102kB 2015-01-01 ... 2049-12-31 * latitude (latitude) float64 33kB -90.0 -89.96 -89.91 ... 89.96 90.0 * longitude (longitude) float64 66kB -180.0 -180.0 -179.9 ... 180.0 180.0 Data variables: avg_hc300m (time, latitude, longitude) float32 2TB dask.array avg_hc700m (time, latitude, longitude) float32 2TB dask.array avg_hcbtm (time, latitude, longitude) float32 2TB dask.array avg_siconc (time, latitude, longitude) float32 2TB dask.array avg_sithick (time, latitude, longitude) float32 2TB dask.array avg_siue (time, latitude, longitude) float32 2TB dask.array avg_sivn (time, latitude, longitude) float32 2TB dask.array avg_sivol (time, latitude, longitude) float32 2TB dask.array avg_snvol (time, latitude, longitude) float32 2TB dask.array avg_sos (time, latitude, longitude) float32 2TB dask.array avg_tos (time, latitude, longitude) float32 2TB dask.array avg_zos (time, latitude, longitude) float32 2TB dask.array Attributes: GRIB_edition: 2 GRIB_centre: ecmf GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts GRIB_subCentre: 1003 Conventions: CF-1.7 institution: European Centre for Medium-Range Weather Forecasts ``` ### Choose what to plot We define: - the day of interest, - the area of interest, the North Atlantic, - the map projection, a Lambert conformal conic projection. ```python time = "2015-01-01" aoi_selection = {"longitude": slice(-80, 0), "latitude": slice(20, 70)} projection = ccrs.LambertConformal( central_longitude=-40, central_latitude=45, standard_parallels=(30, 60) ) ``` ### Select the data The best practice is to select only the area and the time period you need. All operations are lazy, that is they are not applied to the whole dataset, but are just recorded for later use. Data is only downloaded when requested, in our case when plotting, and only the chunks covering the selection are downloaded. ```python ds = ds.sel(time=time, **aoi_selection) ds ``` ```text Size: 99MB Dimensions: (latitude: 1138, longitude: 1821) Coordinates: * latitude (latitude) float64 9kB 20.02 20.07 20.11 ... 69.91 69.96 70.0 * longitude (longitude) float64 15kB -79.98 -79.94 -79.89 ... -0.04395 0.0 time datetime64[ns] 8B 2015-01-01 Data variables: avg_hc300m (latitude, longitude) float32 8MB dask.array avg_hc700m (latitude, longitude) float32 8MB dask.array avg_hcbtm (latitude, longitude) float32 8MB dask.array avg_siconc (latitude, longitude) float32 8MB dask.array avg_sithick (latitude, longitude) float32 8MB dask.array avg_siue (latitude, longitude) float32 8MB dask.array avg_sivn (latitude, longitude) float32 8MB dask.array avg_sivol (latitude, longitude) float32 8MB dask.array avg_snvol (latitude, longitude) float32 8MB dask.array avg_sos (latitude, longitude) float32 8MB dask.array avg_tos (latitude, longitude) float32 8MB dask.array avg_zos (latitude, longitude) float32 8MB dask.array Attributes: GRIB_edition: 2 GRIB_centre: ecmf GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts GRIB_subCentre: 1003 Conventions: CF-1.7 institution: European Centre for Medium-Range Weather Forecasts ``` We use three variables: - `avg_tos`, the daily mean sea surface temperature, - `avg_siconc`, the daily mean sea ice concentration, a fraction between 0 and 1, - `avg_zos`, the daily mean sea surface height, whose small variations are related to ocean currents and eddies. ```python sst = ds["avg_tos"] siconc = ds["avg_siconc"] ssh = ds["avg_zos"] ``` ## Plot the ocean surface We draw four layers with `imshow`, from bottom to top: 1. the land, with cartopy’s default background image, 2. the sea surface temperature, 3. the sea ice, as white with transparency given by the concentration: no ice is fully transparent, full coverage is opaque, 4. the sea surface height, as a hillshade, that is a shading as if the surface were lit from the side, so that its small variations highlight the currents and eddies. **This operation is the slow one, as this is when the data is actually downloaded.** ```python lon, lat = ds["longitude"].values, ds["latitude"].values extent = [lon[0], lon[-1], lat[0], lat[-1]] # W, E, S, N kwargs = {"extent": extent, "transform": ccrs.PlateCarree(), "origin": "lower"} fig, ax = plt.subplots(figsize=(8, 6), subplot_kw={"projection": projection}) ax.set_extent(extent, crs=ccrs.PlateCarree()) # 1. Land ax.stock_img() # 2. Sea surface temperature sst.plot.imshow(ax=ax, robust=True, cmap="coolwarm", **kwargs) # 3. Sea ice ice_rgba = np.ones((*siconc.shape, 4)) ice_rgba[..., 3] = siconc.fillna(0).clip(0, 1) ax.imshow(ice_rgba, **kwargs) # 4. Sea surface height light_source = LightSource() ssh_shade = light_source.hillshade(ssh.fillna(0).values, vert_exag=100) ax.imshow(ssh_shade, alpha=0.25, cmap="Greys", **kwargs) ax.set_title(f"Climate DT IFS-NEMO SSP3-7.0, {time}"); ``` ![image](https://earthdatahub.destine.eu/docs/_images/notebooks_edh-learning_40-use-case-climatedt-ocean_12_0.png) ## Go further - change `time` to any other day of the dataset, e.g. a day in September, when the sea ice extent is at its minimum, - look at another region, adapting `aoi_selection` and `projection`, - make an animation by plotting a sequence of days, one frame each. We suggest using local caching, as explained in the [local cache notebook](https://earthdatahub.destine.eu/docs/notebooks/edh-learning/60-best-practice-local-cache-era5-small-area.md), so that data chunks read multiple times are downloaded only once.