Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/mesido/esdl/profile_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. One small thing. problem_timesteps can have multiple entries so maybe change the text to "....at timestamp(s) {problem_timesteps} ..."

f"exactly 1 hour"
)
# Check if any NaN values exist
if profile_time_series.isnull().any().any():
raise Exception(
Expand Down