From 80b80d4b8a7b2e3d20a671c8d2c189067a9ffd02 Mon Sep 17 00:00:00 2001 From: Femke Janssen Date: Wed, 11 Feb 2026 16:03:43 +0100 Subject: [PATCH 1/2] speed up timeseries delta time check, from 0.5s for the PoCtutorial to <0.1s. Timeseries check linearly grows with the number of profiles --- src/mesido/esdl/profile_parser.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesido/esdl/profile_parser.py b/src/mesido/esdl/profile_parser.py index d8da9736..48410f12 100644 --- a/src/mesido/esdl/profile_parser.py +++ b/src/mesido/esdl/profile_parser.py @@ -315,7 +315,6 @@ def _load_profiles_from_source( ] ) series = unique_series[index_of_unique_profile] - self._check_profile_time_series(profile_time_series=series, profile=profile) container = profile.eContainer() asset = container.eContainer() converted_dataframe = self._convert_profile_to_correct_unit( @@ -506,12 +505,14 @@ def _check_profile_time_series( # Error check: ensure that the profile data has a time resolution of 3600s (1hour) as # expected - for d1, d2 in zip(profile_time_series.index, profile_time_series.index[1:]): - if d2 - d1 != pd.Timedelta(hours=1): - raise RuntimeError( - f"The timestep for variable {profile.field} between {d1} and {d2} isn't " - f"exactly 1 hour" - ) + idx = profile_time_series.index + dt = idx.to_series().diff()[1:] + problem_timesteps = idx[:-1][dt != pd.Timedelta(hours=1)] + if not problem_timesteps.empty: + raise RuntimeError( + f"The timestep for variable {profile.field} at timestamp {problem_timesteps} isn't " + f"exactly 1 hour" + ) # Check if any NaN values exist if profile_time_series.isnull().any().any(): raise Exception( From 75bce663dda5de52c44954bc02566cdce98eea5f Mon Sep 17 00:00:00 2001 From: Femke Janssen Date: Wed, 11 Feb 2026 16:07:43 +0100 Subject: [PATCH 2/2] style --- src/mesido/esdl/profile_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesido/esdl/profile_parser.py b/src/mesido/esdl/profile_parser.py index 48410f12..901ab67b 100644 --- a/src/mesido/esdl/profile_parser.py +++ b/src/mesido/esdl/profile_parser.py @@ -510,7 +510,7 @@ def _check_profile_time_series( problem_timesteps = idx[:-1][dt != pd.Timedelta(hours=1)] if not problem_timesteps.empty: raise RuntimeError( - f"The timestep for variable {profile.field} at timestamp {problem_timesteps} isn't " + f"The timestep for variable {profile.field} at timestamp {problem_timesteps} isn't " f"exactly 1 hour" ) # Check if any NaN values exist