File size: 2,269 Bytes
3789249
 
f1f232f
 
 
 
 
 
 
3789249
c691954
0ddbdab
c691954
0ddbdab
c691954
a8c16a6
301b050
0ddbdab
c691954
a8c16a6
c691954
a8c16a6
c691954
0ddbdab
c691954
301b050
c691954
0ddbdab
 
301b050
c691954
301b050
 
 
a8c16a6
c691954
301b050
a8c16a6
301b050
a8c16a6
c691954
301b050
c691954
301b050
 
c691954
301b050
 
 
 
 
 
c691954
a8c16a6
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
---
license: mit
language:
- en
- zh
metrics:
- accuracy
tags:
- climate
---

# OpenCastKit: an open-source solutions of global data-driven high-resolution weather forecasting

This is an open-source solutions of global data-driven high-resolution weather forecasting, implemented and improved by [High-Flyer AI](https://www.high-flyer.cn/). It can compare with the ECMWF Integrated Forecasting System (IFS).

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

Several cases:

![Typhoon track comparison](./pic/wind_small.gif)

![Water vapour comparison](./pic/precipitation_small.gif)

For more cases about FourCastNet/GraphCast 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

### FourCastNet

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/OpenCastKit/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('./weights/fourcastnet/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('./weights/fourcastnet/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).