Skip to content

Commit

Permalink
Merge pull request #417 from DHI/Inline-_interp_time
Browse files Browse the repository at this point in the history
Inline `_interp_time` to avoid confusion
  • Loading branch information
jsmariegaard authored Feb 9, 2024
2 parents 3cba82a + 4d1ed82 commit 94125bd
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions modelskill/model/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ def _get_valid_times(
df["idx"] = range(len(df))

# for query times get available left and right index of source times
df = _interp_time(df, obs_index).dropna()
df = (
df.reindex(df.index.union(obs_index))
.interpolate(method="time", limit_area="inside")
.reindex(obs_index)
.dropna()
)
df["idxa"] = np.floor(df.idx).astype(int)
df["idxb"] = np.ceil(df.idx).astype(int)

Expand All @@ -158,11 +163,3 @@ def _get_valid_times(
return df[valid_idx].index


def _interp_time(df: pd.DataFrame, new_time: pd.DatetimeIndex) -> pd.DataFrame:
"""Interpolate time series to new time index"""
new_df = (
df.reindex(df.index.union(new_time))
.interpolate(method="time", limit_area="inside")
.reindex(new_time)
)
return new_df

0 comments on commit 94125bd

Please sign in to comment.