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.

Scikit

Authors
Affiliations
University at Albany (SUNY)
Univerity of California, Berkeley
University of Miami
University of California, San Diego
University at Albany (SUNY)
Tuskegee University
University at Albany (SUNY)

Overview

Within this notebook, we will cover:

  1. How to filter continuous SLP data do identify features of interest.

  2. How to use scikit-image’s label() function to identify coherent objects within the SLP field

  3. How to overlay Precipitation and SLP minima locations for each time steps.

  4. How to track identified ETCs through successive time steps.

Prerequisites

ConceptsImportanceNotes
xarrayNecessary
matplotlibNecessary
scikit-imageUsefulMostly the the label function
CartopyUseful
IPythonUsefulFor inline animation
  • Time to learn: 45 minutes

Import Packages

Let’s go through the basic steps to identify SLP features

Open the dataset using xarray

We have a small subset of hourly ERA5 Reanalysis dataset for Sea Level Pressure and Precipitation for 2022 November 1. The precipitation dataset is only available for Northern Hemisphere.

We select for only Northern Hemisphere for Sea Level Pressure dataset as well to associate the SLP features with precipitation

We make use of a set of parameters for identifying the SLP feature objects and tracking overlaps through time.

Define relevant set of parameters

Three values control what counts as a feature and how features are linked through time. We set them once here so the rest of the notebook stays readable.

  1. threshold - ERA5 reports sea-level pressure in pascals, so this is 1005 hPa. Grid cells below this value are flagged as part of a low. Everything at or above it is background.

  2. min_area- The smallest feature we keep, measured in grid cells. Below threshold blobs smaller than 20 cells are treated as noise and dropped. Since we haven’t smoothed the field yet, this is what stops single-cell specks from being counted as a feature.

  3. min_overlap - The matching rule for tracking. A feature at one timestep is identified with a feature at the next when they share at least 20% overlap. Below that level, they’re treated as separate features. Lower values follow faster moving systems but risk false links and higher values require a feature to barely move between steps.

Get the latitude and longitude 2d meshgrid for plotting

To plot SLP and precipitation with contourf() or contour(), we first create 2D latitude–longitude grids.

We do this separately because the two datasets have different grid sizes:

SLP : 1° × 1°
Precipitation : 0.25° × 0.25° (Only over northern Hemisphere)

So each variable needs its own plotting latitude-longitude grid

Select low SLP features less than a threshold using scikit-image label function

The detect_features() function identifies low-pressure objects in a single SLP field. First, it creates a mask of all grid points where SLP is less than or equal to the chosen threshold. These grid points are treated as candidate low-pressure regions. The function then uses connected-component labeling to group neighboring grid points into separate features. Because connectivity=2 is used, grid cells that touch along edges or corners are considered connected. After the initial labeling, very small features are removed using the min_area limit, so noisy or insignificant patches are not included. Finally, the remaining features are labeled again to produce a clean label map, where 0 represents the background and each positive integer represents a separate low-pressure feature.

Let’s look at the labelled feature plotted for one time step

Let’s take a look at the labelled feature at time = 0 which at 2022 November 1 00:00 UTC along with precipitation overlay.

We call the detect_features() function with the parameters set above

We define the scales for plotting here

Lets plot the figure with SLP features and precipitation overlayed

<Figure size 1000x700 with 3 Axes>

This plot shows sea-level pressure (SLP) and precipitation for one time step. The SLP field is shown as a filled background using a BrBG brown to blue-green color scale, with lower pressure in brown and higher pressure in blue green. The magenta contours mark the detected low-pressure SLP features using the 1000 hPa threshold. Precipitation is overlaid in greyscale, with weaker precipitation shown in darker shades and stronger precipitation shown in lighter shades. Each detected feature is annotated with its feature_ID.

The main point of the plot is that some precipitation features are embedded within broad low-pressure SLP objects. This is visible over parts of North America and Europe, where precipitation appears within or near the detected SLP features. However, not all precipitation is captured by these SLP-defined objects. Some precipitation systems occur outside the detected low-pressure regions, especially in subtropical areas such as near Japan and over the Northern Hemisphere subtropical Atlantic.

Lets add the SLP minimum for each identified feature

We identify candidate cyclone centers by applying a local minimum filter to the SLP field. A grid point is tagged as a local minimum if its SLP value is equal to the minimum value within a surrounding 5 × 5 grid-cell window. Longitude is treated as cyclic, while latitude uses nearest-edge padding.m

<Figure size 1000x700 with 3 Axes>

Let’s track SLP Features Over Time

We track the labelled SLP features from one time step to the next. Each detected feature is converted into a mask and compared with the masks from the previous time step. If a current feature overlaps strongly enough with a previous feature, it is treated as the same object and keeps the same track_id. If the overlap is too small, the feature is treated as a new object and is assigned a new track_id. For each time step, the code stores the feature ID, centroid location, and mask, which can later be used for plotting, animation, or further analysis of how the low-pressure systems move.

Let’s look at the animation of the SLP features with precipitation overlayed

Loading...

This animation shows the evolution of SLP and precipitation through time using the overlap tracking method. The numeric annotations help follow individual systems across successive times, including cases where the detected object appears as nested within the larger low SLP features.

Summary

In this recipe, we identify low sea level pressure (SLP) features globally and track them through time. We use scikit-image.measure label() to detect coherent low-pressure objects. We track tracking identified features between time steps using spatial overlap percentage and made visualization for one time step and a hourly animation for duration of 1 day. We add precipitation and SLP minima location overlayed on these SLP feature tracks.

What’s next?

  1. Adding smoothing or noise filtering before feature detection.

  2. Comparing this contour-based method with scikit-image and scipy object-labeling approaches.

  3. Extracting region properties such as area, centroid, perimeter, and intensity.

  4. Testing sensitivity to different SLP thresholds.

  5. Adding explicit split and merge detection during tracking.