All posts

Climate Risk Commons 1.1: faster, lighter, and models that say what they were calibrated on

crc-sdk and crc-framework 1.1: evaluations up to 80 times faster with a sixth of the scratch disk, built-in damage models that state what they were calibrated on, more source data accepted, and DuckDB 2 support.

TL;DR: crc-sdk and crc-framework 1.1 are out: pip install --upgrade crc-sdk. Same results, much less waiting: checking a site against a local dataset takes 0.07 seconds instead of 5.6, and reading a whole global variable takes 14 seconds instead of 38 with a sixth of the scratch disk. We also sat down (virtually, ofc) with our science team and wrote down exactly what each built-in damage model was calibrated on, so the models now refuse data that was measured differently.

1.0 was correct, just not fast enough

1.0 was about making a number explain itself. Once people started using it on real portfolios, the feedback was consistent: the answers were right, and they took too long. One site against a local file spent almost six seconds decoding curves it would never use. A full read of one CRC Open hazard variable wrote 3 GB of scratch files just to check that no row appeared twice.

None of that was the maths. It was the plumbing around it, so that is where 1.1 went.

Old way: do everything, then filter

New way: only the work the question needs

The numbers

Same workloads, same outputs, measured on the same laptop/runtime. Results, metadata and reports were compared with the previous version on every change.

Workload SDK 1.0 SDK 1.1
One site, local Dataset file 5.6 s 0.07 s
Small area, local Dataset file 6.3 s 0.7 s
First CRC Open read in a process 3.5 s 0.68 s
1,000 sites, local file 21 s 12.9 s
10,000 sites, local file 147 s 92 s
One CRC Open variable, worldwide 38 s 14 s
Scratch disk for that read 3.1 GB 0.48 GB

And one under the hood: deciding which rows belong to the series you selected went from 227 ms to 2.7 ms per 65,536-row batch, because every key is now one integer code and one vectorized membership test.

The framework did its part too. In crc-framework 1.0.1, probability laws are built and queried natively, without a round trip through JSON or Python lists, and long arrays are evaluated across CPU threads with results identical to a single thread.

Models that say what they were calibrated on

A damage function is only valid for the data it was fitted on. A frost-day curve fitted on days below 0 °C should not be fed days below −2 °C, and a wind curve fitted on 10-minute sustained winds should not be fed gusts. 1.0 already refused to bind a model whose calibration facts were unknown, which was honest but meant most built-in models could not be used on data at all.

So we asked the people who built them. With RiskThinking's climate science team, crc-framework 1.1 now records the definitions behind seven models: frost days and freeze-thaw cycles (0 °C, counted per year), maximum daily precipitation (one-day totals), cyclone wind (10-minute sustained), maximum daily wind (no averaging), SPEI (monthly) and cooling degree days (18 °C base). Data that declares the same definitions binds; data that doesn't is refused with a message saying which fact differs.

Two models changed meaning:

More usable data, found by the community

Every data fix in this release started as an issue from Yuri (@shlyakh), who has been running the SDK against real sources and writing up exactly where it fell short:

Yuri also contributed four fixes that shipped in 1.0.1: NEX reads report selected years the source does not publish, JRC reads report an area outside the product's extent, NEX resources record the CMIP6 licence written in each file, and GHCNh hourly files are attributed to NOAA NCEI, the actual publisher. That is the kind of report that makes a release: a real source, the exact symptom, and how many models or station-years it affected.

Your DuckDB, your choice

The SDK now works with DuckDB 1.4 through 2.x, and new installs get 2.x. It only uses what behaves the same on both, with tests on each, so you get the speed of whichever version you install and the same results either way. To stay on 1.x, pin it next to the SDK: pip install --upgrade crc-sdk "duckdb<2".

DuckDB 2 does change two things you may touch directly:

The DuckDB guide lists each change and how to keep 1.x behaviour.

What 1.1 doesn't do

Upgrading

pip install --upgrade "crc-sdk>=1.1,<2"
npm install @climateriskcommons/crc-framework@1.1

No code changes are needed unless you use the fire-weather or hot-days models. The details are in the crc-sdk 1.1.0 and crc-framework 1.1.0 release notes.

Final remark

Thanks to Andrew (@awiebe42), Rithwik (@rkodamana) and Reshma (@reshmasoman) on the climate science team for answering a long thread of very specific questions, and to Yuri (@shlyakh) for the reports and fixes that helped widen data usability.

Tell us what is still slow on Discord.

The software is AGPL-3.0-or-later. CRC Open data is CC BY-NC 4.0, a separate licence.