Skip to content

METcalcpy

METcalcpy is a stand-alone Python package that re-implements the statistical calculations used across the METplus tools. It is not a graphical tool you click through — it is a library of reusable functions for aggregating statistics, equalizing events, computing bootstrap confidence intervals, interpolating vertically, and producing specialized indices. By centralizing this math, it lets METviewer, METexpress, METplotpy, and METplus all compute statistics the same way.

The Model Evaluation Tools (MET) verification system writes its results as plain ASCII statistics files. Several downstream tools then need to take those numbers, combine them across cases, and turn them into plots, dashboards, and reports. Historically each of those tools carried its own copy of the statistics math. METcalcpy exists to remove that duplication: it is “a stand-alone package and a Python version of the statistics calculation functionality” shared across the ecosystem.

Because it is a library rather than an application, you generally do not run METcalcpy directly to look at a result. Instead, other tools import it — for example a plotting package calls a METcalcpy aggregation function to compute the numbers it then draws. The payoff is consistency: when two tools report the same statistic, they get the same answer because they ran the same code.

Think of METcalcpy as the middle stage of a pipeline. MET produces the raw verification output; METcalcpy turns that into aggregated statistics with confidence intervals and significance; and the presentation tools render those numbers for a human. The diagram below traces that path.

METcalcpy in the verification pipeline MET verification output (matched pairs and partial sums) flows into METcalcpy functions for aggregation, event equalization, bootstrap confidence intervals, and significance. The aggregated statistics are then consumed by METplotpy, METviewer, and METexpress. MET OUTPUT METcalcpy FUNCTIONS CONSUMERS Matched pairs (MPR) Partial sums Line-type stats (e.g. ECNT) METcalcpy Aggregate (agg_stat) Event equalization Bootstrap confidence intervals Significance & indices METplotpy METviewer METexpress aggregated statistics
Figure 1. MET writes matched pairs and partial sums; METcalcpy aggregates them, equalizes events, attaches bootstrap confidence intervals and significance, and hands the result to the presentation tools.

METcalcpy bundles a number of distinct utilities. The table below summarizes the main statistics-and-diagnostics capability areas from its User’s Guide, each of which has its own module or set of functions. It is a curated selection, not the full feature list — supporting facilities such as the package’s integrated logging are documented in the source but omitted here.

CapabilityWhat it does
AggregationComputes aggregated statistics and confidence intervals from reformatted MET stat output. Implemented in agg_stat.py via the AggStat class.
Event equalizationOptional step (the event_equal flag) that keeps only cases present across all series being compared, so aggregated statistics are computed over a common, fair sample.
Bootstrapping & CIsResampling-based confidence intervals, including circular block bootstrap, controlled by parameters such as alpha, num_iterations, and random_seed.
Vertical interpolationPressure-to-height conversion for TC-RMW data via vertical_interp.py, interpolating fields from pressure to target height levels.
Difficulty IndexQuantifies how hard a forecast decision is, given an ensemble, around a threshold (e.g. wind speed or significant wave height) as a function of space and time.
Write MPRWrites matched forecast–observation pairs to a .stat file in MET’s Matched Pair (MPR) format via write_mpr_file(...), computing the observation-input and total-observation values the MPR line format requires.
Land-surface diagnosticsThe metcalcpy.diagnostics.land_surface module: convective triggering potential (calc_ctp), low-level humidity index (calc_humidity_index), and the terrestrial coupling index (calc_tci).

Two areas are large enough to warrant their own pages. Start here if you want the mechanics rather than the overview.

The metcalcpy.diagnostics.land_surface module provides three coupling diagnostics drawn from the land–atmosphere interaction literature. They are reference implementations: each is a function you call with profiles or fields and that returns a single diagnostic value (or a gridded field).

calc_ctp — Convective Triggering Potential — Computes CTP, defined as R_d ∫ (T_env − T_MALR) d ln p integrated over a pressure layer above the surface — a measure of low-level atmospheric instability relevant to convection initiation. Takes pressure (hPa) and temperature (K) profiles, with layer offsets defaulting to 100 hPa (bottom) and 300 hPa (top) below the start pressure. Returns a float. After Findell & Eltahir (2003), J. Hydrometeorology.

calc_humidity_index — Low-level Humidity Index (HI) — Computes HI_low = (T − D)950 hPa + (T − D)850 hPa: the sum of temperature-minus-dewpoint differences at two low levels, indicating how moist the boundary layer is. Takes pressure (hPa), temperature (K), and dewpoint (K) inputs. Returns a float. Also after Findell & Eltahir (2003).

calc_tci — Terrestrial Coupling Index (TCI) — Measures the coupling between soil moisture and surface heat flux. Takes soil_data (the moisture variable) and sfc_flux_data (the latent-heat-flux variable) as xarray DataArrays or pandas Series, with a skipna flag. Returns a gridded DataArray (for xarray inputs) or a single float (for Series inputs). After Dirmeyer (2011), Geophys. Res. Lett..

METcalcpy is a dependency, not a destination. It is imported by the tools that present and plot verification results, and it is part of the broader METplus orchestration story.


A derived, human-readable re-presentation — not official documentation. Sources: METcalcpy User’s Guide — Overview