Graph Machine Learning
AnemoI
English
hcookie129 commited on
Commit
2b404fc
·
verified ·
1 Parent(s): 3eb31a0

feat/add_ensemble_initial_conditions (#4)

Browse files

- Update notebook (c59b9a2b95ecf8eaba405288c1489f0372553937)

Files changed (1) hide show
  1. run_AIFS_ENS_v1.ipynb +22 -11
run_AIFS_ENS_v1.ipynb CHANGED
@@ -58,12 +58,13 @@
58
  },
59
  {
60
  "cell_type": "code",
61
- "execution_count": 3,
62
  "id": "a6cdc784-68cb-4e27-b52a-36e82d994e2f",
63
  "metadata": {},
64
  "outputs": [],
65
  "source": [
66
- "PARAM_SFC = [\"10u\", \"10v\", \"2d\", \"2t\", \"msl\", \"skt\", \"sp\", \"tcw\", \"lsm\", \"z\", \"slor\", \"sdor\"]\n",
 
67
  "PARAM_SOIL =[\"sot\"]\n",
68
  "PARAM_PL = [\"gh\", \"t\", \"u\", \"v\", \"w\", \"q\"]\n",
69
  "LEVELS = [1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 50]\n",
@@ -107,16 +108,20 @@
107
  },
108
  {
109
  "cell_type": "code",
110
- "execution_count": 5,
111
  "id": "062a8a99-ddb0-43e9-aa28-5b1f926ed8a2",
112
  "metadata": {},
113
  "outputs": [],
114
  "source": [
115
- "def get_open_data(param, levelist=[]):\n",
116
  " fields = defaultdict(list)\n",
117
  " # Get the data for the current date and the previous date\n",
118
  " for date in [DATE - datetime.timedelta(hours=6), DATE]:\n",
119
- " data = ekd.from_source(\"ecmwf-open-data\", date=date, param=param, levelist=levelist)\n",
 
 
 
 
120
  " for f in data:\n",
121
  " # Open data is between -180 and 180, we need to shift it to 0-360\n",
122
  " assert f.to_numpy().shape == (721,1440)\n",
@@ -139,7 +144,11 @@
139
  "id": "6d2b0711-f477-48a6-afaf-99fab48b7024",
140
  "metadata": {},
141
  "source": [
142
- "## Get Input Fields"
 
 
 
 
143
  ]
144
  },
145
  {
@@ -149,7 +158,8 @@
149
  "metadata": {},
150
  "outputs": [],
151
  "source": [
152
- "fields = {}"
 
153
  ]
154
  },
155
  {
@@ -162,7 +172,7 @@
162
  },
163
  {
164
  "cell_type": "code",
165
- "execution_count": 7,
166
  "id": "26b43fc6-b41a-4626-8907-01fa2b3231a9",
167
  "metadata": {},
168
  "outputs": [
@@ -175,7 +185,8 @@
175
  }
176
  ],
177
  "source": [
178
- "fields.update(get_open_data(param=PARAM_SFC))"
 
179
  ]
180
  },
181
  {
@@ -193,7 +204,7 @@
193
  }
194
  ],
195
  "source": [
196
- "soil=get_open_data(param=PARAM_SOIL,levelist=SOIL_LEVELS)"
197
  ]
198
  },
199
  {
@@ -240,7 +251,7 @@
240
  }
241
  ],
242
  "source": [
243
- "fields.update(get_open_data(param=PARAM_PL, levelist=LEVELS))"
244
  ]
245
  },
246
  {
 
58
  },
59
  {
60
  "cell_type": "code",
61
+ "execution_count": null,
62
  "id": "a6cdc784-68cb-4e27-b52a-36e82d994e2f",
63
  "metadata": {},
64
  "outputs": [],
65
  "source": [
66
+ "PARAM_SFC = [\"10u\", \"10v\", \"2d\", \"2t\", \"msl\", \"skt\", \"sp\", \"tcw\"]\n",
67
+ "PARAM_SFC_FC = [\"lsm\", \"z\", \"slor\", \"sdor\"]\n",
68
  "PARAM_SOIL =[\"sot\"]\n",
69
  "PARAM_PL = [\"gh\", \"t\", \"u\", \"v\", \"w\", \"q\"]\n",
70
  "LEVELS = [1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 50]\n",
 
108
  },
109
  {
110
  "cell_type": "code",
111
+ "execution_count": null,
112
  "id": "062a8a99-ddb0-43e9-aa28-5b1f926ed8a2",
113
  "metadata": {},
114
  "outputs": [],
115
  "source": [
116
+ "def get_open_data(param, levelist=[], number = None):\n",
117
  " fields = defaultdict(list)\n",
118
  " # Get the data for the current date and the previous date\n",
119
  " for date in [DATE - datetime.timedelta(hours=6), DATE]:\n",
120
+ " if number is None:\n",
121
+ " data = ekd.from_source(\"ecmwf-open-data\", date=date, param=param, levelist=levelist)\n",
122
+ " else:\n",
123
+ " data = ekd.from_source(\"ecmwf-open-data\", date=date, param=param, levelist=levelist, number=[number], stream='enfo')\n",
124
+ " \n",
125
  " for f in data:\n",
126
  " # Open data is between -180 and 180, we need to shift it to 0-360\n",
127
  " assert f.to_numpy().shape == (721,1440)\n",
 
144
  "id": "6d2b0711-f477-48a6-afaf-99fab48b7024",
145
  "metadata": {},
146
  "source": [
147
+ "## Get Input Fields\n",
148
+ "\n",
149
+ "> Here we make a single forecast, from the control initial condition of the ensemble. In operations, this model is run 51 times, once from the control and 50 more times from slightly different initial conditions. \n",
150
+ "\n",
151
+ "To get different ensemble initial conditions from the ifs pertubation, set `number` to an ensemble number, between 1-50.\n"
152
  ]
153
  },
154
  {
 
158
  "metadata": {},
159
  "outputs": [],
160
  "source": [
161
+ "fields = {}\n",
162
+ "number = None"
163
  ]
164
  },
165
  {
 
172
  },
173
  {
174
  "cell_type": "code",
175
+ "execution_count": null,
176
  "id": "26b43fc6-b41a-4626-8907-01fa2b3231a9",
177
  "metadata": {},
178
  "outputs": [
 
185
  }
186
  ],
187
  "source": [
188
+ "fields.update(get_open_data(param=PARAM_SFC, number=number))\n",
189
+ "fields.update(get_open_data(param=PARAM_SFC_FC)) # Add constant surface fields, retrieved from fc"
190
  ]
191
  },
192
  {
 
204
  }
205
  ],
206
  "source": [
207
+ "soil=get_open_data(param=PARAM_SOIL,levelist=SOIL_LEVELS, number=number)"
208
  ]
209
  },
210
  {
 
251
  }
252
  ],
253
  "source": [
254
+ "fields.update(get_open_data(param=PARAM_PL, levelist=LEVELS, number=number))"
255
  ]
256
  },
257
  {