Skip to content

Commit

Permalink
removed preserved vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
asnyv committed Aug 12, 2020
1 parent 6976758 commit 964717c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions webviz_subsurface/_datainput/from_timeseries_cumulatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ def calc_from_cumulatives(
data = data.copy()
if isinstance(column_keys, str):
column_keys = [column_keys]
# Don't want to delete anything from the current DataFrame, even if not defined by column_keys.
# This is to be able to plot e.g. cumulatives, delta cumulatives and average rates at the same
# time.
columns_to_preserve = [
col for col in data.columns if col not in (["ENSEMBLE", "REAL", "DATE"])
]

# Converting the DATE axis to datetime to allow for timedeltas
data.loc[:, ["DATE"]] = pd.to_datetime(data["DATE"])
_verify_time_index_input(data, time_index_input)
Expand Down Expand Up @@ -68,7 +63,7 @@ def calc_from_cumulatives(
# Preserve ENSEMBLE and REAL
diff_cum = pd.concat(
[
data[["ENSEMBLE", "REAL"] + columns_to_preserve],
data[["ENSEMBLE", "REAL"]],
data[["ensrealuid"] + column_keys]
.diff()
.shift(-1)
Expand All @@ -81,7 +76,7 @@ def calc_from_cumulatives(
# Reset index (DATE becomes regular column)
diff_cum.reset_index(inplace=True)

# Convert interval cumulative to daily average rate
# Convert interval cumulative to daily average rate if requested
if as_rate:
days = diff_cum["DATE"].diff().shift(-1).dt.days.fillna(value=0)
for vec in column_keys:
Expand Down

0 comments on commit 964717c

Please sign in to comment.