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.

Sea Surface Temperature data from MESACLIP historical run

Access the MESACLIP Oceanic and Atmospheric Data

Required Packages

Please ensure the following packages are installed before proceeding.

CategoryPackagePurpose
Data Access & AnalysiskerchunkRead the virtualized-zarr format data
xarrayLazy loading and array manipulation
VisualizationmatplotlibGeneral-purpose plotting
foliumpython interface to generate the leaflet map

Step 1 - Read the data in the ARCO format

The original data are stored in NetCDF files, organized by ensemble member, model component (ocn, atm, etc.), temporal frequency (day_1, month_1), and variable-specific files. Accessing one variable across the full time range may require opening roughly 10–20 files, and accessing two variables may require 20–40 files. This can be time-consuming, even when using xarray.open_mfdataset. In addition, when subsetting data, xarray must inspect the NetCDF structure to locate chunk positions.
With ARCO (virtualized Zarr), chunk byte ranges are pre-indexed in JSON/dictionary references. This provides modest speedups for local access and much faster response for remote access (for example, via HTTP requests).

Step 2 - Locate the Dataset

The dataset is freely available on the NCAR GDEX portal and is stored on NCAR’s Campaign storage. This notebook demonstrates two access methods:

  • NCAR HPC — direct Campaign Storage access for users on NCAR’s HPC systems

  • Remote — internet-based access for users outside of NCAR

Step 3 - Open the Data

xr.open_dataset integrates well with the Python kerchunk engine, making it straightforward to open a reference file such as .json or .parq. In this workflow, the dataset is stored as a single kerchunk reference file that combines all variables and the full time range for a given ensemble member, model component, and temporal frequency. As a result, users only need to open one reference file to access all available variables and time slices from the original model output.

Notebook process memory usage: 0.04 GB (RSS)
Notebook process memory usage: 2.65 GB (RSS)
67.092546539654 TB

Step 4 - Focus on a Single Time Slice

Next, load only a single time slice of one variable to demonstrate selective data access. This step shows that, although the full dataset is very large, only the requested subset is brought into memory when .load() is called.

In the following example, the notebook selects sea surface temperature (SST) at one time index and loads that 2D field into memory for analysis and plotting. After that, memory usage is checked again to show the additional cost of loading just this subset rather than the full dataset.

This illustrates a key advantage of the kerchunk-based ARCO workflow: data can remain lazily referenced until a specific variable and time slice are explicitly requested.

Notebook process memory usage: 8.88 GB (RSS)
Loading...
<Figure size 640x480 with 2 Axes>
Notebook process memory usage: 9.39 GB (RSS)

Step 5 - Remap the data using regrid weight file

Preprocessed by NCAR scientist, Frederic Castruccio, the file that one needs to load to perform the regridding of the ocean data from

Apply the Regridding

Call remap_pop to project SST from the native curvilinear POP grid (2400 × 3600 nlat/nlon) onto a regular 1° × 1° lat/lon grid using the precomputed ESMF bilinear weights. The %%time magic records the wall-clock time of the operation. Because the remapping is a single sparse matrix multiplication, it completes in well under a second even for a global 2D field. The result is stored in dso, an xarray.Dataset with standard lat and lon coordinates, ready for plotting or further analysis.

CPU times: user 154 ms, sys: 63.9 ms, total: 218 ms
Wall time: 234 ms
/glade/derecho/scratch/chiaweih/tmp/ipykernel_12482/782792240.py:73: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.
  dims[it] = dso.dims[it]
<Figure size 640x480 with 2 Axes>

Step 6 - Visualize the Regridded Data on an Interactive Map

6a — Reorder Longitudes from [0°, 360°) to [−180°, 180°)

Folium and rioxarray both expect longitudes in the standard geographic convention of [−180°, 180°]. The ESMF regridding output inherits the POP grid’s [0°, 360°) convention. This cell converts to the signed convention by shifting each longitude value with (lon + 180) % 360 - 180, then calls sortby("lon") to restore monotonic ordering — a requirement for correct raster rendering.

6b — Reproject to Web Mercator (EPSG:3857)

Folium’s tile layers use the Web Mercator projection (EPSG:3857), the same projection used by Google Maps and OpenStreetMap. To overlay a raster image accurately on those tiles, the data must be warped from its native WGS84 geographic coordinates (EPSG:4326) into Web Mercator before being passed to Folium.

This cell uses rioxarray to:

  1. Detect the spatial dimension names (lon/lat).

  2. Declare the original CRS as EPSG:4326 with .write_crs().

  3. Reproject the SST field to EPSG:3857 with .reproject(), preserving the original output grid shape.

original CRS: EPSG:4326

6c — Build and Display the Folium Interactive Map

This cell assembles the interactive Leaflet map using folium and branca. The steps are:

  1. Colormap — a matplotlib colormap (RdBu_r) is applied to the normalized SST values (clipped to [varmin, varmax]) to produce an RGBA image array.

  2. Base map — a folium.Map is created centered on the data domain with a light CartoDB Positron tile layer.

  3. Image overlay — the RGBA array is added as a folium.raster_layers.ImageOverlay. mercator_project=False because the data is already in Web Mercator; origin="upper" ensures rows are drawn from the top of the bounding box downward.

  4. Color bar legend — a branca.LinearColormap is added to the map with the variable name as its caption.

  5. Title — an HTML <h1> element is injected into the map root to display the dataset label.

Run the next cell (fm) to render the interactive map inline.

<branca.element.Element at 0x7fe84b08d990>
Loading...