From 0643efaaf94e44589cb03249c908b3fc0d225054 Mon Sep 17 00:00:00 2001 From: James Fulton Date: Wed, 25 Oct 2023 16:03:27 +0000 Subject: [PATCH 1/2] hot fix for multiple spatial coords --- pvnet_app/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pvnet_app/app.py b/pvnet_app/app.py index 5d707f3..0d7537b 100644 --- a/pvnet_app/app.py +++ b/pvnet_app/app.py @@ -286,7 +286,12 @@ def app( # Download nwp data logger.info("Downloading nwp data") fs = fsspec.open(os.environ["NWP_ZARR_PATH"]).fs - fs.get(os.environ["NWP_ZARR_PATH"], "nwp.zarr", recursive=True) + + # Hot fix as datapipes can't handle both lat-lon and osgb on same coord + fs.get(os.environ["NWP_ZARR_PATH"], "raw_nwp.zarr", recursive=True) + ds_nwp = xr.open_zarr("raw_nwp.zarr") + ds_nwp.drop_vars(("latitude", "longitude")).to_zarr("nwp.zarr") + del ds_nwp # --------------------------------------------------------------------------- # 2. Set up data loader From a3d4efb3794a01f218be4172084c94de90a9c95c Mon Sep 17 00:00:00 2001 From: James Fulton Date: Wed, 25 Oct 2023 16:25:15 +0000 Subject: [PATCH 2/2] fix --- pvnet_app/app.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pvnet_app/app.py b/pvnet_app/app.py index 0d7537b..10fc4bf 100644 --- a/pvnet_app/app.py +++ b/pvnet_app/app.py @@ -286,13 +286,20 @@ def app( # Download nwp data logger.info("Downloading nwp data") fs = fsspec.open(os.environ["NWP_ZARR_PATH"]).fs + fs.get(os.environ["NWP_ZARR_PATH"], "nwp.zarr", recursive=True) + ################ # Hot fix as datapipes can't handle both lat-lon and osgb on same coord - fs.get(os.environ["NWP_ZARR_PATH"], "raw_nwp.zarr", recursive=True) - ds_nwp = xr.open_zarr("raw_nwp.zarr") - ds_nwp.drop_vars(("latitude", "longitude")).to_zarr("nwp.zarr") + ds_nwp = xr.open_zarr("nwp.zarr").compute() + if "latitude" in ds_nwp: + ds_nwp = ds_nwp.drop_vars(("latitude", "longitude")) + ds_nwp["variable"] = ds_nwp.variable.astype(str) + os.system("rm -r nwp.zarr") + ds_nwp.to_zarr("nwp.zarr") + del ds_nwp - + ################ + # --------------------------------------------------------------------------- # 2. Set up data loader logger.info("Creating DataLoader")