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

Issue/new ecmwf #163

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions india_forecast_app/models/all_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ models:
version: d71104620f0b0bdd3eeb63cafecd2a49032ae0f7
client: ruvnl
asset_type: pv
- name: pvnet_india_ecmwf_mo_gfs
type: pvnet
id: openclimatefix/pvnet_india
version: 7a179d1f8349d99cb2a30a48e5be17d59b6f2b16
client: ruvnl
asset_type: pv
# - name: pvnet_india_ecmwf_mo_gfs
# type: pvnet
# id: openclimatefix/pvnet_india
# version: 7a179d1f8349d99cb2a30a48e5be17d59b6f2b16
# client: ruvnl
# asset_type: pv
# Ad client solar
- name: pvnet_ad_sites
type: pvnet
Expand Down
35 changes: 35 additions & 0 deletions india_forecast_app/models/pvnet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,41 @@ def process_and_cache_nwp(nwp_config: NWPProcessAndCacheConfig):
ds[v].encoding.clear()

if nwp_config.source == "ecmwf":

if "HRES-IFS_india" in ds.data_vars:
# rename from HRES-IFS_india to ECMWF_INDIA
ds = ds.rename({"HRES-IFS_india": "ECMWF_INDIA"})

# rename variable names in the variable coordinate
# This is a renaming from ECMWF 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': 'sde',
'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)

# Rename t variable to t2m
variables = list(ds.variable.values)
new_variables = []
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def test_get_all_models():
"""Test for getting all models"""
models = get_all_models()
assert len(models.models) == 11
assert len(models.models) == 10


def test_get_all_models_client():
Expand Down
14 changes: 9 additions & 5 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ def test_app(
result = run_click_script(app, args)
assert result.exit_code == 0

n = 5

if write_to_db:
assert db_session.query(ForecastSQL).count() == init_n_forecasts + 6 * 2
assert db_session.query(ForecastValueSQL).count() == init_n_forecast_values + (6 * 2 * 192)
assert db_session.query(MLModelSQL).count() == 6 * 2
assert db_session.query(ForecastSQL).count() == init_n_forecasts + n * 2
assert db_session.query(ForecastValueSQL).count() == init_n_forecast_values + (n * 2 * 192)
assert db_session.query(MLModelSQL).count() == n * 2
else:
assert db_session.query(ForecastSQL).count() == init_n_forecasts
assert db_session.query(ForecastValueSQL).count() == init_n_forecast_values
Expand All @@ -183,8 +185,10 @@ def test_app_no_pv_data(
result = run_click_script(app, args)
assert result.exit_code == 0

assert db_session.query(ForecastSQL).count() == init_n_forecasts + 2 * 6
assert db_session.query(ForecastValueSQL).count() == init_n_forecast_values + (2 * 6 * 192)
n = 5

assert db_session.query(ForecastSQL).count() == init_n_forecasts + 2 * n
assert db_session.query(ForecastValueSQL).count() == init_n_forecast_values + (2 * n * 192)


@pytest.mark.requires_hf_token
Expand Down
Loading