Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor for gfs data #165

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion india_forecast_app/models/pvnet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,49 @@ def process_and_cache_nwp(nwp_config: NWPProcessAndCacheConfig):

# Hack to resolve some NWP data format differences between providers
elif nwp_config.source == "gfs":

if "NCEP-GFS" in ds.data_vars:

ds = ds.rename({"NCEP-GFS": "NOAA_GLOBAL"})

# rename variable names in the variable coordinate
# This is a renaming from GFS variables to what we use in the ML Model
# This change happened in the new nwp-consumer>=1.0.0
# Ideally we won't need this step in the future
variable_coords = ds.variable.values
rename = {'cloud_cover_high': 'hcc',
'cloud_cover_low': 'lcc',
'cloud_cover_medium': 'mcc',
'cloud_cover_total': 'tcc',
'snow_depth_gl': 'sdwe',
'direct_shortwave_radiation_flux_gl': 'sr',
'downward_longwave_radiation_flux_gl': 'dlwrf',
'downward_shortwave_radiation_flux_gl': 'dswrf',
'downward_ultraviolet_radiation_flux_gl': 'duvrs',
'temperature_sl': 't',
'total_precipitation_rate_gl': 'prate',
'visibility_sl': 'vis',
'wind_u_component_100m': 'u100',
'wind_u_component_10m': 'u10',
'wind_u_component_200m': 'u200',
'wind_v_component_100m': 'v100',
'wind_v_component_10m': 'v10',
'wind_v_component_200m': 'v200'}

for k, v in rename.items():
variable_coords[variable_coords == k] = v

# assign the new variable names
ds = ds.assign_coords(variable=variable_coords)

# change to list of data variables
# note we need this for ocf-datapipes, but not for ocf-data-sampler
data_var = ds[list(ds.data_vars.keys())[0]]
# # Use .to_dataset() to split the data variable based on 'variable' dim
ds = data_var.to_dataset(dim="variable")
ds = ds.rename({"t2m": "t"})

if "t2m" in ds.data_vars:
ds = ds.rename({"t2m": "t"})

if nwp_config.source == "mo_global":

Expand Down
Loading