Skip to content

Commit

Permalink
Merge pull request #121 from openclimatefix/issue/no-satellie-option
Browse files Browse the repository at this point in the history
Issue/no satellie option
  • Loading branch information
peterdudfield authored Aug 18, 2024
2 parents 7b9f046 + 4821823 commit 7d0e308
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 9 additions & 4 deletions pvnet_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
# If summation_model_name is set to None, a simple sum is computed instead
"summation": {
"name": "openclimatefix/pvnet_v2_summation",
"version": "ffac655f9650b81865d96023baa15839f3ce26ec",
"version": os.getenv('PVNET_V2_SUMMATION_VERSION',
"ffac655f9650b81865d96023baa15839f3ce26ec"),
},
# Whether to use the adjuster for this model - for pvnet_v2 is set by environmental variable
"use_adjuster": os.getenv("USE_ADJUSTER", "true").lower() == "true",
Expand Down Expand Up @@ -219,7 +220,8 @@ def app(
- NWP_UKV_ZARR_PATH
- NWP_ECMWF_ZARR_PATH
- SATELLITE_ZARR_PATH
- PVNET_V2_VERSION, default is a version above
- PVNET_V2_VERSION, pvnet version, default is a version above
- PVNET_V2_SUMMATION_VERSION, the pvnet version, default is above
- DOWNLOAD_SATELLITE, option to get satelite data. defaults to true
Args:
t0 (datetime): Datetime at which forecast is made
Expand All @@ -238,6 +240,9 @@ def app(
dask.config.set(scheduler="single-threaded")

day_ahead_model_used = os.getenv("DAY_AHEAD_MODEL", "false").lower() == "true"
use_satellite = os.getenv("USE_SATELLITE", "true").lower() == "true"
logger.info(f"Using satellite data: {use_satellite}")
logger.info(f"Using day ahead model: {day_ahead_model_used}")

if day_ahead_model_used:
logger.info(f"Using day ahead PVNet model")
Expand Down Expand Up @@ -294,7 +299,7 @@ def app(
gsp_id_to_loc = GSPLocationLookup(ds_gsp.x_osgb, ds_gsp.y_osgb)

# Download satellite data
if os.getenv("DOWNLOAD_SATELLITE", "true").lower() == "true":
if use_satellite:
logger.info("Downloading satellite data")
download_all_sat_data()

Expand Down Expand Up @@ -360,7 +365,7 @@ def app(
raise Exception(f"No models were compatible with the available input data.")

# Find the config with satellite delay suitable for all models running
common_config = find_min_satellite_delay_config(data_config_filenames)
common_config = find_min_satellite_delay_config(data_config_filenames, use_satellite=use_satellite)

# Save the commmon config
common_config_path = f"{temp_dir.name}/common_config_path.yaml"
Expand Down
8 changes: 7 additions & 1 deletion pvnet_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ def populate_data_config_sources(input_path, output_path):
save_yaml_config(config, output_path)


def find_min_satellite_delay_config(config_paths):
def find_min_satellite_delay_config(config_paths, use_satellite: bool = False):
"""Find the config with the minimum satallite delay across from list of config paths"""

logger.info(f"Finding minimum satellite delay config from {config_paths}")

# Load all the configs
configs = [load_yaml_config(config_path) for config_path in config_paths]
if not use_satellite:
logger.info("Not using satellite data, so returning first config")
return configs[0]

min_sat_delay = np.inf

Expand Down

0 comments on commit 7d0e308

Please sign in to comment.