From ca22dde6d4a7d8a64f7e69098a1251d677f65b12 Mon Sep 17 00:00:00 2001 From: Chris Rowe Date: Thu, 31 Oct 2024 20:29:27 -0400 Subject: [PATCH] Load data from file before releasing from context --- city_metrix/layers/era_5_hottest_day.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/city_metrix/layers/era_5_hottest_day.py b/city_metrix/layers/era_5_hottest_day.py index 3ec9f1c..ed4ef04 100644 --- a/city_metrix/layers/era_5_hottest_day.py +++ b/city_metrix/layers/era_5_hottest_day.py @@ -100,9 +100,9 @@ def hourly_mean_temperature(image): # Subset times for the day times = [valid_time.astype('datetime64[s]').astype(datetime).replace(tzinfo=pytz.UTC) for valid_time in dataarray['valid_time'].values] indices = [i for i, value in enumerate(times) if value in utc_times] - subset_dataarray = dataarray.isel(valid_time=indices) + subset_dataarray = dataarray.isel(valid_time=indices).load() - dataarray_list.append(subset_dataarray) + dataarray_list.append(subset_dataarray) # Remove local file os.remove(f'download_{i}.nc')