Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 0184ae9

Browse files
Merge pull request #623 from JanEbbing/patch-1
Update NetCDF loading to use the cleaner code
2 parents f907054 + 044bf8d commit 0184ae9

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

nowcasting_dataset/data_sources/pv/pv_data_source.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,23 +377,11 @@ def load_solar_pv_data(
377377
"""
378378
logger.debug(f"Loading Solar PV Data from {filename} from {start_dt} to {end_dt}.")
379379

380-
# It is possible to simplify the code below and do
381-
# xr.open_dataset(file, engine='h5netcdf')
382-
# in the first 'with' block, and delete the second 'with' block.
383-
# But that takes 1 minute to load the data, where as loading into memory
384-
# first and then loading from memory takes 23 seconds!
385380
with fsspec.open(filename, mode="rb") as file:
386-
file_bytes = file.read()
387-
388-
with io.BytesIO(file_bytes) as file:
389381
pv_power = xr.open_dataset(file, engine="h5netcdf")
390382
pv_power = pv_power.sel(datetime=slice(start_dt, end_dt))
391383
pv_power_df = pv_power.to_dataframe()
392384

393-
# Save memory
394-
del file_bytes
395-
del pv_power
396-
397385
# Process the data a little
398386
pv_power_df = pv_power_df.dropna(axis="columns", how="all")
399387
pv_power_df = pv_power_df.clip(lower=0, upper=5e7)

0 commit comments

Comments
 (0)