Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
dfulu committed Dec 13, 2023
1 parent e2a079c commit a268e91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions pvnet_app/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@

def download_sat_data():
"""Download the sat data"""

# Clean out old files
os.system(f"rm -r {sat_path} {sat_5_path} {sat_15_path}")

fs = fsspec.open(os.environ["SATELLITE_ZARR_PATH"]).fs
fs.get(os.environ["SATELLITE_ZARR_PATH"], "sat_5_min.zarr.zip")
os.system(f"rm -r {sat_5_path} {sat_15_path} {sat_path}")

os.system(f"unzip sat_5_min.zarr.zip -d {sat_5_path}")

# Also download 15-minute satellite if it exists
sat_latest_15 = os.environ["SATELLITE_ZARR_PATH"].replace("sat.zarr", "sat_15.zarr")
if fs.exists(sat_latest_15):
sat_15_dl_path = os.environ["SATELLITE_ZARR_PATH"].replace("sat.zarr", "sat_15.zarr")
if fs.exists(sat_15_dl_path):
logger.info("Downloading 15-minute satellite data")
fs.get(sat_latest_15, sat_15_path)
fs.get(sat_15_dl_path, "sat_15_min.zarr.zip")
os.system(f"unzip sat_15_min.zarr.zip -d {sat_15_path}")


Expand Down
2 changes: 1 addition & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _test_app(db_session, nwp_data, sat_5_data, sat_15_data, gsp_yields_and_syst

# Maybe save the 15-minute data too
if sat_15_data is not None:
temp_sat_path = f"{tmpdirname}/sat_15.zarr.zip"
temp_sat_path = os.environ["SATELLITE_ZARR_PATH"].replace("sat.zarr", "sat_15.zarr")
store = zarr.storage.ZipStore(temp_sat_path, mode="x")
sat_15_data.to_zarr(store)
store.close()
Expand Down

0 comments on commit a268e91

Please sign in to comment.