From 98b50820fe9a44a0533f3ebe2edf16ef81f0cb1a Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Tue, 7 Jan 2025 15:58:09 +0000 Subject: [PATCH 1/2] remove new pv model --- india_forecast_app/models/all_models.yaml | 12 ++++++------ tests/models/test_pydantic_models.py | 2 +- tests/test_app.py | 14 +++++++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/india_forecast_app/models/all_models.yaml b/india_forecast_app/models/all_models.yaml index cf6538b..d093005 100644 --- a/india_forecast_app/models/all_models.yaml +++ b/india_forecast_app/models/all_models.yaml @@ -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 diff --git a/tests/models/test_pydantic_models.py b/tests/models/test_pydantic_models.py index 818a646..3f23330 100644 --- a/tests/models/test_pydantic_models.py +++ b/tests/models/test_pydantic_models.py @@ -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(): diff --git a/tests/test_app.py b/tests/test_app.py index 8347a07..436c2c9 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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 @@ -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 From 7a8e7bd8b9f538a48ca6c7650621ac1d4bcac1ac Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Tue, 7 Jan 2025 15:59:02 +0000 Subject: [PATCH 2/2] rename HRES-IFS_india --- india_forecast_app/models/pvnet/utils.py | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/india_forecast_app/models/pvnet/utils.py b/india_forecast_app/models/pvnet/utils.py index f367edf..7c42f35 100644 --- a/india_forecast_app/models/pvnet/utils.py +++ b/india_forecast_app/models/pvnet/utils.py @@ -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 = []