Gridded & climate data
NetCDF, GRIB and Zarr grids with a time axis: opening, subsetting, averaging and regridding them with xarray.
Climate and reanalysis data arrives as a labelled array: a few variables over latitude, longitude and time, in NetCDF, GRIB or Zarr. xarray gives it names, so you subset by coordinate value rather than by position, and reductions carry their dimension names with them.
The traps are quiet ones. Selecting by position when you meant by label returns an array of exactly the right shape. A variable packed into sixteen bits with a scale factor reads correctly through one library and not through another, and a derived field written with its parent’s encoding silently overflows. A mean over latitude and longitude without cos-latitude weighting over-counts the poles, and the answer still looks reasonable.
Below: the concepts cover the formats, the packing and what a regrid actually computes; the how-to guides open, subset, average and regrid; and the fixes are the values that come back wrong and the maps that come out shifted.
🧭 Start with the concepts
The ideas the how-to guides below assume you already have.
- NetCDF and Gridded Data Explained: Dimensions, Variables and Attributes
- CF Conventions Explained: How a NetCDF File Says What Its Numbers Mean
- 0–360 or −180–180: Longitude Conventions in Gridded Data Explained
- Regridding Explained: Bilinear, Conservative and Nearest for Gridded Data
- GRIB, NetCDF or Zarr: Choosing a Format for Gridded Data
- Sea level rise data explained
Show every concept in this topic
- Growing degree days explained
- Solar Irradiance Explained
- Wind Resource Explained
- Air Pollution Meteorology Explained
- Sea-Ice Extent vs Area Explained
- Weather Model Resolution Explained
- Wind Vectors Explained
- Reanalysis vs Weather Station Data, Explained
- Climate Normals Explained: What "Normal" Weather Means
⚙️ Then do the task
Step-by-step walkthroughs with code you can copy and adapt.
- How to Open a NetCDF File in Python with xarray
- How to Select a Time Range and Location from an xarray Dataset
- How to Clip a NetCDF Grid to a Polygon in Python
- How to Convert NetCDF to GeoTIFF in Python
- How to Resample a Gridded Time Series to Monthly or Annual Values
- How to Calculate a Climatology and Anomalies with xarray
Show every how-to guide in this topic
- How to Take an Area-Weighted Mean over a Latitude–Longitude Grid
- How to Extract a Time Series per Polygon from a NetCDF Grid
- How to Read GRIB Weather Forecast Data in Python
- How to Open Hundreds of NetCDF Files as One Dataset
- How to subset an ocean model NetCDF by depth and time
- How to calculate growing degree days from gridded weather
- How to extract climate covariates at occurrence points
- How to Model PV Output with pvlib
- How to Estimate Wind Speed at Hub Height in Python
- How to Make a Pollution Rose in Python
- How to Compare CAMS Air Quality with Monitoring Stations in Python
- How to Compare Air Temperature with Land Surface Temperature in Python
- How to Count Heatwave Days in Python
- How to Analyse a Sea-Ice Extent Time Series in Python
- How to Read MRMS Rainfall Estimates from GRIB2 in Python
- How to Calculate Fire Weather Indices in Python
- How to Download GFS Wind Data From AWS in Python
- How to Calculate Wind Speed and Direction From U and V in Python
- How to Read HRRR Wind Data in Python
- How to Calculate Vorticity and Divergence From Wind in Python
- How to Calculate a Wind Climatology in Python
- How to Map the Jet Stream in Python
- How to Relate Daily Crime to Temperature in Python
- How to Detect Marine Heatwaves in Python
- How to Compute an El Niño Index from Sea Surface Temperature in Python
- How to Map Sea Surface Temperature Trends in Python
- How to Compute the Global Mean Sea Surface Temperature in Python
- How to Map the Seasonal Cycle of Sea Surface Temperature in Python
- How to Get ERA5 Reanalysis Data in Python
- How to Calculate Temperature Anomalies in Python
- How to Calculate Climate Normals in Python
🔧 When it breaks
The errors this topic produces, with the cause explained rather than just the command.
- Fixing xarray's "Did Not Find a Match in Any of xarray's Installed Backends"
- Fixing NetCDF Values That Look Wrong: scale_factor, _FillValue and Units
- Fixing a NetCDF Map That Is Shifted, Flipped or Split at 180°
- Fixing open_mfdataset That Is Slow, Hangs or Will Not Combine
- Fixing cftime and Out-of-Bounds Datetime Errors in xarray
- Wind Speed at 10 m Used as Hub Height
Show every fix in this topic
- Sea-Ice Extent Numbers Disagree
- GRIB File Won't Open with cfgrib: Fixing the Common Errors
- Why Are My Wind Directions Off by 180 Degrees?
- Fixing Sea Surface Temperature Anomalies That Disagree Between Sources
- Fixing Global SST Means That Ignore Cell Area
- Fixing ERA5 Temperatures in Kelvin and Precipitation in Metres
Learning paths through this topic
A curated route rather than a list — the guides in the order that builds on itself.
Related topics
Subjects that keep coming up alongside this one, most overlap first.