diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c446f87..1e2ec2f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - xxx ## Changed -- xxx +- Speed-up timeseries check in from InfluxDB ## Fixed - xxx diff --git a/src/mesido/esdl/profile_parser.py b/src/mesido/esdl/profile_parser.py index d8da9736..23d939b5 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,15 @@ 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(s) {problem_timesteps} " + f"isn't " + f"exactly 1 hour" + ) # Check if any NaN values exist if profile_time_series.isnull().any().any(): raise Exception(