From 92df7bbb9c786667364f7358f5ee90caad87ec1d Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 3 Jan 2024 10:27:42 +0100 Subject: [PATCH 1/2] build_renewable_profiles: improve logging of time passed --- scripts/build_renewable_profiles.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/scripts/build_renewable_profiles.py b/scripts/build_renewable_profiles.py index 3a1c525e..ef8683cb 100644 --- a/scripts/build_renewable_profiles.py +++ b/scripts/build_renewable_profiles.py @@ -277,15 +277,14 @@ if __name__ == "__main__": snakemake.input.country_shapes, buffer=buffer, invert=True ) + logger.info("Calculate landuse availability...") + start = time.time() + kwargs = dict(nprocesses=nprocesses, disable_progressbar=noprogress) - if noprogress: - logger.info("Calculate landuse availabilities...") - start = time.time() - availability = cutout.availabilitymatrix(regions, excluder, **kwargs) - duration = time.time() - start - logger.info(f"Completed availability calculation ({duration:2.2f}s)") - else: - availability = cutout.availabilitymatrix(regions, excluder, **kwargs) + availability = cutout.availabilitymatrix(regions, excluder, **kwargs) + + duration = time.time() - start + logger.info(f"Completed landuse availability calculation ({duration:2.2f}s)") # For Moldova and Ukraine: Overwrite parts not covered by Corine with # externally determined available areas @@ -304,8 +303,19 @@ if __name__ == "__main__": func = getattr(cutout, resource.pop("method")) if client is not None: resource["dask_kwargs"] = {"scheduler": client} + + logger.info("Calculate average capacity factor...") + start = time.time() + capacity_factor = correction_factor * func(capacity_factor=True, **resource) layout = capacity_factor * area * capacity_per_sqkm + + duration = time.time() - start + logger.info(f"Completed average capacity factor calculation ({duration:2.2f}s)") + + logger.info("Calculate weighted capacity factor time series...") + start = time.time() + profile, capacities = func( matrix=availability.stack(spatial=["y", "x"]), layout=layout, @@ -315,6 +325,9 @@ if __name__ == "__main__": **resource, ) + duration = time.time() - start + logger.info(f"Completed weighted capacity factor time series calculation ({duration:2.2f}s)") + logger.info(f"Calculating maximal capacity per bus (method '{p_nom_max_meth}')") if p_nom_max_meth == "simple": p_nom_max = capacity_per_sqkm * availability @ area From fdb63bc6ca4c3aa332104d26bca1c0a5d5c546c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 09:29:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/build_renewable_profiles.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build_renewable_profiles.py b/scripts/build_renewable_profiles.py index ef8683cb..83c79482 100644 --- a/scripts/build_renewable_profiles.py +++ b/scripts/build_renewable_profiles.py @@ -326,7 +326,9 @@ if __name__ == "__main__": ) duration = time.time() - start - logger.info(f"Completed weighted capacity factor time series calculation ({duration:2.2f}s)") + logger.info( + f"Completed weighted capacity factor time series calculation ({duration:2.2f}s)" + ) logger.info(f"Calculating maximal capacity per bus (method '{p_nom_max_meth}')") if p_nom_max_meth == "simple":