Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/wri/cities-cif into CIF-286…
Browse files Browse the repository at this point in the history
…-CAMS
  • Loading branch information
weiqi-tori committed Nov 3, 2024
2 parents 4689024 + 84647e9 commit c313c87
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions city_metrix/layers/era_5_hottest_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ def hourly_mean_temperature(image):
},
f'download_{i}.nc')

dataarray = xr.open_dataset(f'download_{i}.nc')

# 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)
with xr.open_dataset(f'download_{i}.nc') as dataarray:
# 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).load()

dataarray_list.append(subset_dataarray)

Expand Down

0 comments on commit c313c87

Please sign in to comment.