ERA5_patchify / README.md
Forbu14's picture
Create README.md
1a11227 verified
---
license: cc-by-4.0
task_categories:
- tabular-regression
- image-to-image
tags:
- meteorology
- weather
- ERA5
- ECMWF
- reanalysis
- gridded-data
- patches
size_categories:
- 100K<n<1M
---
# ERA5 Patchified Dataset
Patches extracted from ECMWF ERA5 reanalysis on a 0.25° global grid, tiled into 128×128 non-overlapping patches with float16 normalized channels. Designed for ML training — use alongside [IFS HRES open data](https://huggingface.co/datasets/meteolibre-dev/weather_ifs_hres_128_0dot025) at inference time for a train-on-reanalysis / infer-on-forecast workflow.
## Data Structure
Files are stored as Parquet, named:
```
era5_{first_snapshot}_{region}_patches_{group_idx:04d}_{file_idx:04d}.parquet
```
### Columns
| Column | Type | Description |
|---|---|---|
| `ifs_data` | bytes | Raw float16 bytes of the (T, C, H, W) patch tensor |
| `ifs_shape` | list[int] | Shape tuple, e.g. `[3, 77, 128, 128]` |
| `ifs_dtype` | str | `"e"` (numpy half / float16) |
| `channel_names` | list[str] | Ordered channel names (see below) |
| `channel_offsets` | list[float] | Per-channel normalization offset |
| `channel_scales` | list[float] | Per-channel normalization scale |
| `elevation_data` | bytes | Float16 elevation patch (128, 128) |
| `elevation_shape` | list[int] | `(128, 128)` |
| `elevation_dtype` | str | `"e"` (float16) |
| `epsg` | int | CRS, always `4326` |
| `lon` | float | Center longitude of patch |
| `lat` | float | Center latitude of patch |
| `patch_x_idx` | int | X index in the regional grid |
| `patch_y_idx` | int | Y index in the regional grid |
| `region` | str | Region name (e.g. `europe`, `global`) |
| `snapshot_labels` | list[str] | ISO labels of the T snapshots |
| `time_spacing_hours` | int | Hours between snapshots (`6`) |
| `resolution` | float | Grid resolution in degrees (`0.25`) |
| `patch_size` | int | Spatial patch size (`128`) |
| `source` | str | Always `"era5"` |
### Recovering the Tensor
```python
import numpy as np
import pyarrow.parquet as pq
table = pq.read_table("era5_2024-06-01T0000Z_europe_patches_0000_0000.parquet")
row = table.slice(0, 1).to_pydict()
# Reconstruct tensor
tensor = np.frombuffer(row["ifs_data"][0], dtype=row["ifs_dtype"][0]).reshape(row["ifs_shape"][0])
# tensor shape: (T, C, 128, 128), float16
# De-normalize
for ci, (offset, scale) in enumerate(zip(row["channel_offsets"][0], row["channel_scales"][0])):
if scale != 0:
tensor[:, ci, :, :] = tensor[:, ci, :, :].astype(np.float32) * scale + offset
```
## Channels (77 total)
### Surface (13 channels)
| # | Name | Description | Unit | Offset | Scale |
|---|---|---|---|---|---|
| 1 | `mucape` | Convective available potential energy (surface-based) | J kg⁻¹ | 0 | 500 |
| 2 | `2t` | 2m temperature | K | 273.15 | 40 |
| 3 | `2d` | 2m dewpoint temperature | K | 273.15 | 30 |
| 4 | `10u` | 10m U wind component | m s⁻¹ | 0 | 30 |
| 5 | `10v` | 10m V wind component | m s⁻¹ | 0 | 30 |
| 6 | `100u` | 100m U wind component | m s⁻¹ | 0 | 40 |
| 7 | `100v` | 100m V wind component | m s⁻¹ | 0 | 40 |
| 8 | `tp` | Total precipitation | m | 0 | 0.05 |
| 9 | `sp` | Surface pressure | Pa | 101325 | 5000 |
| 10 | `msl` | Mean sea level pressure | Pa | 101325 | 5000 |
| 11 | `tcwv` | Total column water vapour | kg m⁻² | 0 | 50 |
| 12 | `tcc` | Total cloud cover | (0–1) | 0 | 1 |
| 13 | `lsm` | Land-sea mask | (0–1) | 0 | 1 |
### Pressure Levels × 8 variables = 64 channels
Levels: **1000, 925, 850, 700, 500, 300, 250, 200 hPa**
| # | Prefix | Description | Unit | Offset | Scale |
|---|---|---|---|---|---|
| 14–21 | `t_{level}` | Temperature | K | 273.15 | 50 |
| 22–29 | `u_{level}` | U wind component | m s⁻¹ | 0 | 60 |
| 30–37 | `v_{level}` | V wind component | m s⁻¹ | 0 | 60 |
| 38–45 | `q_{level}` | Specific humidity | kg kg⁻¹ | 0 | 0.02 |
| 46–53 | `w_{level}` | Vertical velocity | Pa s⁻¹ | 0 | 5 |
| 54–61 | `gh_{level}` | Geopotential height | m | 5000 | 30000 |
| 62–69 | `vo_{level}` | Relative vorticity | s⁻¹ | 0 | 5×10⁻⁴ |
| 70–77 | `r_{level}` | Relative humidity | % | 50 | 50 |
Full channel name example: `t_850` = temperature at 850 hPa.
## Normalization
Values are stored normalized as float16:
```
normalized = (raw_value - offset) / scale
```
Recover raw values with:
```
raw_value = normalized * scale + offset
```
Normalization constants are **identical to the IFS HRES dataset**, enabling seamless cross-training (train on ERA5, infer on IFS HRES) without re-normalization.
## Temporal Structure
Each patch contains **T consecutive analysis snapshots** spaced **6 hours** apart (cycles 00, 06, 12, 18 UTC). The default is T=3 (18h window).
Consecutive patch groups stride by T×6 hours for continuous temporal coverage with no gaps:
```
Group 1: 00z → 06z → 12z
Group 2: 18z → 00z(+1d) → 06z(+1d)
Group 3: 12z(+1d) → 18z(+1d) → 00z(+2d)
...
```
## Spatial Coverage
| Region | Bounding Box (lon_min, lat_min, lon_max, lat_max) |
|---|---|
| `global` | (-180, -90, 180, 90) |
| `europe` | (-30, 30, 45, 75) |
| `north_atlantic` | (-80, 20, 0, 70) |
| `north_america` | (-140, 15, -50, 75) |
| `asia` | (50, 0, 160, 75) |
Grid: 0.25° × 0.25° regular lat-lon (EPSG:4326). Patches are non-overlapping 128×128 grid cells (≈32° × 32° at 0.25° resolution).
## Comparison with IFS HRES Patchified Dataset
| | ERA5 (this dataset) | IFS HRES |
|---|---|---|
| **Type** | Reanalysis (best-estimate historical) | Operational analysis (near-real-time) |
| **Temporal range** | 1940 → present | Rolling 2–3 days only |
| **Latency** | ~5 days (ERA5T) / ~2 months (final) | Near real-time |
| **Resolution** | 0.25° | 0.25° (open data) / 0.08° (licensed) |
| **Consistency** | Reanalysis = physically consistent | Model upgrades cause breaks |
| **CAPE** | Surface-based CAPE | Most-unstable CAPE |
| **Channels** | 77 (no `tprate`) | 78 (includes `tprate`) |
| **Geopotential** | Height (m) after ÷9.80665 | Height (m) |
| **Normalization** | Same offsets/scales | Same offsets/scales |
**Recommended workflow**: Train on ERA5 (years of consistent data), infer on IFS HRES (real-time availability). The shared normalization and channel naming makes this a drop-in switch.
## Elevation
Each patch includes a 128×128 float16 elevation map derived from a global DEM, reprojected to the same 0.25° grid. Elevation is stored raw (meters above sea level), not normalized.
## Source
Data downloaded from the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu) via the `cdsapi` Python client.
- Surface: [`reanalysis-era5-single-levels`](https://cds.climate.copernicus.eu/datasets/reanalysis-era5-single-levels)
- Pressure levels: [`reanalysis-era5-pressure-levels`](https://cds.climate.copernicus.eu/datasets/reanalysis-era5-pressure-levels)
## License
CC-BY-4.0 — please attribute ECMWF / Copernicus Climate Change Service as the data source. See the [CDS terms of use](https://cds.climate.copernicus.eu/api/v2/terms/static/licence-to-use-copernicus-products.pdf) and [ERA5 licence](https://cds.climate.copernicus.eu/datasets/reanalysis-era5-single-levels/licence).