File size: 2,691 Bytes
3789249
 
f1f232f
 
 
 
 
 
 
3789249
c691954
301b050
c691954
301b050
c691954
301b050
 
 
c691954
f1f232f
c691954
301b050
c691954
f1f232f
c691954
301b050
c691954
301b050
c691954
301b050
c691954
301b050
 
 
 
c691954
301b050
 
 
 
c691954
301b050
c691954
301b050
 
c691954
301b050
 
 
 
 
 
c691954
301b050
c691954
 
301b050
c691954
301b050
 
c691954
301b050
 
c691954
301b050
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
license: mit
language:
- en
- zh
metrics:
- accuracy
tags:
- climate
---

# FourCastNet: a global data-driven high-resolution weather model

This is a global data-driven high-resolution weather model implemented, trained and open sourced by [High-Flyer AI](https://www.high-flyer.cn/en/). It is the first AI weather model, which can compare with the ECMWF Integrated Forecasting System (IFS).

See also: [Github repository](https://github.com/HFAiLab/FourCastNet) and [High-flyer AI's blog](https://www.high-flyer.cn/blog/fourcastnet/)

Typhoon track prediction:

![](https://github.com/HFAiLab/FourCastNet/blob/master/img/wind_small.gif)

Water vapour prediction:

![](https://github.com/HFAiLab/FourCastNet/blob/master/img/precipitation_small.gif)

For more cases about FourCastNet prediction, please have a look at [HF-Earth](https://www.high-flyer.cn/hf-earth/), a daily updated demo released by [High-Flyer AI](https://www.high-flyer.cn/en/).

## Inference

You can load the weights `backbone.pt` and `precipitation.pt` to generate weather predictions, as shown in the following pseudocode. The complete code is released at `./infer2img.py`.

```python
import xarray as xr
import cartopy.crs as ccrs
from afnonet import AFNONet   # download the code from https://github.com/HFAiLab/FourCastNet/blob/master/model/afnonet.py

backbone_model = AFNONet(img_size=[720, 1440], in_chans=20, out_chans=20, norm_layer=partial(nn.LayerNorm, eps=1e-6))
backbone_model.load('./backbone.pt')
precip_model = AFNONet(img_size=[720, 1440], in_chans=20, out_chans=1, norm_layer=partial(nn.LayerNorm, eps=1e-6))
precip_model.load('./precipitation.pt')

input_x = get_data('2023-01-01 00:00:00')

pred_x = backbone_model(input_x)    # input Xt, output Xt+1
pred_p = precip_model(pred_x)       # input Xt+1, output Pt+1

plot_data = xr.Dataset([pred_x, pred_p])
ax = plt.axes(projection=ccrs.PlateCarree())
plot_data.plot(ax=ax, transform=ccrs.PlateCarree(), add_colorbar=False, add_labels=False, rasterized=True)
ax.coastlines(resolution='110m')
plt.savefig('img.png')
```

FourCastNet can predict 7 surface variables, plus 5 atmospheric variables at each of 3 or 4 pressure levels, for 21 variables total. The details of these variables follow the [paper](https://arxiv.org/abs/2202.11214).


## Description of Files

`backbone.pt` 
+ the weights of backbone model, 191MB, which is trained on 20 atmospheric variables from `1979-01` to `2022-12`.

`precipitation.pt`
+ the weights of precipitation model, 187MB, which is trained on the variable `total_precipitation` from `1979-01` to `2022-12`.

`infer2img.py`
+ Case code: load the above two weights to generate images of global weather prediction.