Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit a20036d

Browse files
Sukhil PatelSukhil Patel
authored andcommitted
Update constants and when they are used for GFS
1 parent 497d180 commit a20036d

File tree

2 files changed

+80
-12
lines changed

2 files changed

+80
-12
lines changed

ocf_datapipes/training/pvnet_site.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Create the training/validation datapipe for training the PVNet Model"""
22

33
import logging
4+
from functools import partial
45
from datetime import datetime, timedelta
56
from typing import List, Optional
67

@@ -237,12 +238,18 @@ def construct_sliced_data_pipeline(
237238
roi_width_pixels=conf_nwp[nwp_key].nwp_image_size_pixels_width,
238239
)
239240
# Coarsen the data, if it is separated by 0.05 degrees each
240-
nwp_datapipe = nwp_datapipe.map(potentially_coarsen)
241+
potentially_coarsen_partial = partial(
242+
potentially_coarsen, coarsen_to_deg=conf_nwp[nwp_key].coarsen_to_degrees
243+
)
244+
nwp_datapipe = nwp_datapipe.map(potentially_coarsen_partial)
241245
# Somewhat hacky way for India specifically, need different mean/std for ECMWF data
242246
if conf_nwp[nwp_key].nwp_provider in ["ecmwf"]:
243247
normalize_provider = "ecmwf_india"
248+
elif conf_nwp[nwp_key].nwp_provider in ["gfs"]:
249+
normalize_provider = "gfs_india"
244250
else:
245251
normalize_provider = conf_nwp[nwp_key].nwp_provider
252+
246253
nwp_datapipes_dict[nwp_key] = nwp_datapipe.normalize(
247254
mean=NWP_MEANS[normalize_provider],
248255
std=NWP_STDS[normalize_provider],

ocf_datapipes/utils/consts.py

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ def __getitem__(self, key):
3939
NWP_PROVIDERS = [
4040
"ukv",
4141
"gfs",
42+
"gfs_india",
4243
"icon-eu",
4344
"icon-global",
4445
"ecmwf",
4546
"ecmwf_india",
4647
"excarta",
4748
"merra2",
4849
"merra2_uk",
49-
"mo_global",
50+
"mo_global"
5051
]
5152

5253
# ------ UKV
@@ -132,17 +133,32 @@ def __getitem__(self, key):
132133
UKV_STD = _to_data_array(UKV_STD)
133134
UKV_MEAN = _to_data_array(UKV_MEAN)
134135

135-
# These were calculated from 200 random init times (step 0s) from the MO global data
136+
# --- MO Global
137+
136138
MO_GLOBAL_INDIA_MEAN = {
137-
"temperature_sl": 298.2,
138-
"wind_u_component_10m": 0.5732,
139-
"wind_v_component_10m": -0.2831,
139+
"temperature_sl": 295.34392488,
140+
"wind_u_component_10m": 0.83223102,
141+
"wind_v_component_10m": 0.0802083,
142+
"downward_shortwave_radiation_flux_gl": 225.54222068,
143+
"cloud_cover_high": 0.34935897,
144+
"cloud_cover_low": 0.096081,
145+
"cloud_cover_medium": 0.13878676,
146+
"relative_humidity_sl": 69.59633137,
147+
"snow_depth_gl": 3.45158744,
148+
"visibility_sl": 23181.81547681,
140149
}
141150

142-
MO_GLOBAL_INDIA_STD = {
143-
"temperature_sl": 8.473,
144-
"wind_u_component_10m": 2.599,
145-
"wind_v_component_10m": 2.016,
151+
MO_GLOBAL_INDIA_STD = {
152+
"temperature_sl": 12.26983825,
153+
"wind_u_component_10m": 3.45169835,
154+
"wind_v_component_10m": 2.9825603,
155+
"downward_shortwave_radiation_flux_gl": 303.85182864,
156+
"cloud_cover_high": 0.40563507,
157+
"cloud_cover_low": 0.18374192,
158+
"cloud_cover_medium": 0.25972151,
159+
"relative_humidity_sl": 21.00264399,
160+
"snow_depth_gl": 30.19116501,
161+
"visibility_sl": 5385.35839715,
146162
}
147163

148164

@@ -197,6 +213,48 @@ def __getitem__(self, key):
197213
GFS_MEAN = _to_data_array(GFS_MEAN)
198214

199215

216+
# ------ GFS
217+
GFS_INDIA_STD_DICT = {
218+
"t": 14.93798,
219+
"prate": 5.965701e-05,
220+
"u10": 3.4826114,
221+
"v10": 3.167296,
222+
"u100":4.140226,
223+
"v100":3.984121,
224+
"dlwrf": 79.30329,
225+
"dswrf": 325.58582,
226+
"hcc": 39.91955,
227+
"lcc": 23.208075,
228+
"mcc": 33.283035,
229+
"r": 25.545837,
230+
"sde": 0.10192183,
231+
"tcc": 42.583195,
232+
"vis": 3491.437
233+
}
234+
GFS_INDIA_MEAN_DICT = {
235+
"t": 298.27713,
236+
"prate": 1.7736e-05,
237+
"u10": 1.5782778,
238+
"v10": 0.09856875,
239+
"u100":1.4558668,
240+
"v100":-0.28256148,
241+
"dlwrf": 356.57776,
242+
"dswrf": 284.358,
243+
"hcc": 26.965801,
244+
"lcc": 9.2288,
245+
"mcc": 17.2132,
246+
"r": 38.2474,
247+
"sde": 0.02070413,
248+
"tcc": 36.962795,
249+
"vis": 23386.936
250+
}
251+
252+
253+
GFS_INDIA_VARIABLE_NAMES = tuple(GFS_INDIA_MEAN_DICT.keys())
254+
GFS_INDIA_STD = _to_data_array(GFS_INDIA_STD_DICT)
255+
GFS_INDIA_MEAN = _to_data_array(GFS_INDIA_MEAN_DICT)
256+
257+
200258
# ------ ECMWF
201259
# These were calculated from 100 random init times of UK data from 2020-2023
202260
ECMWF_STD = {
@@ -369,6 +427,7 @@ def __getitem__(self, key):
369427
NWP_VARIABLE_NAMES = NWPStatDict(
370428
ukv=UKV_VARIABLE_NAMES,
371429
gfs=GFS_VARIABLE_NAMES,
430+
gfs_india=GFS_INDIA_VARIABLE_NAMES,
372431
ecmwf=ECMWF_VARIABLE_NAMES,
373432
ecmwf_india=INDIA_ECMWF_VARIABLE_NAMES,
374433
excarta=EXCARTA_VARIABLE_NAMES,
@@ -379,22 +438,24 @@ def __getitem__(self, key):
379438
NWP_STDS = NWPStatDict(
380439
ukv=UKV_STD,
381440
gfs=GFS_STD,
441+
gfs_india=GFS_INDIA_STD,
382442
ecmwf=ECMWF_STD,
383443
ecmwf_india=INDIA_ECMWF_STD,
384444
excarta=EXCARTA_STD,
385445
merra2=MERRA2_STD,
386446
merra2_uk=UK_MERRA2_STD,
387-
mo_global=MO_GLOBAL_INDIA_STD,
447+
mo_global=MO_GLOBAL_INDIA_STD
388448
)
389449
NWP_MEANS = NWPStatDict(
390450
ukv=UKV_MEAN,
391451
gfs=GFS_MEAN,
452+
gfs_india=GFS_INDIA_MEAN,
392453
ecmwf=ECMWF_MEAN,
393454
ecmwf_india=INDIA_ECMWF_MEAN,
394455
excarta=EXCARTA_MEAN,
395456
merra2=MERRA2_MEAN,
396457
merra2_uk=UK_MERRA2_MEAN,
397-
mo_global=MO_GLOBAL_INDIA_MEAN,
458+
mo_global=MO_GLOBAL_INDIA_MEAN
398459
)
399460

400461
# --------------------------- SATELLITE ------------------------------

0 commit comments

Comments
 (0)