Skip to content

Commit

Permalink
if nwp data already there, then dont process
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Nov 26, 2024
1 parent e50f9c7 commit 2ee377f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions india_forecast_app/models/pvnet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@ def _prepare_data_sources(self):
# Remove local cached zarr if already exists
for nwp_source_file_path, nwp_path in zip(nwp_source_file_paths, nwp_paths, strict=False):
# Process/cache remote zarr locally
shutil.rmtree(nwp_path, ignore_errors=True)
process_and_cache_nwp(nwp_source_file_path, nwp_path)
if use_satellite:
shutil.rmtree(satellite_path, ignore_errors=True)
download_satellite_data(satellite_source_file_path)

if self.asset_type == "wind":
Expand Down
7 changes: 6 additions & 1 deletion india_forecast_app/models/pvnet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ def populate_data_config_sources(input_path, output_path):
def process_and_cache_nwp(source_nwp_path: str, dest_nwp_path: str):
"""Reads zarr file, renames t variable to t2m and saves zarr to new destination"""

log.info(f"Processing and caching NWP data for {source_nwp_path}")
log.info(f"Processing and caching NWP data for {source_nwp_path}, "
f"and saving to {dest_nwp_path}")

if os.path.exists(dest_nwp_path):
log.info(f"File already exists at {dest_nwp_path}")
return

# Load dataset from source
ds = xr.open_zarr(source_nwp_path)
Expand Down

0 comments on commit 2ee377f

Please sign in to comment.