Skip to content

Commit

Permalink
Yearly inferred pandas frequency = AS-JAN (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
asnyv authored Mar 25, 2021
1 parent c595811 commit ada4c9f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#586](https://github.com/equinor/webviz-subsurface/pull/586) - Added phase ratio vs pressure and density vs pressure plots. Added unit and density functions to PVT library. Refactored code and added checklist for plots to be viewed in PVT plot plugin. Improved the layout.

### Fixed
- [#592](https://github.com/equinor/webviz-subsurface/pull/592) - Fixed bug for inferred frequency of yearly summary data.
- [#594](https://github.com/equinor/webviz-subsurface/pull/594) - Fixed bug in SurfaceViewerFMU where surfaces with only undefined values was not handled properly.
- [#584](https://github.com/equinor/webviz-subsurface/pull/584) - Fixed bug for in RelativePermeability plugin where it was not possible to plot against oil saturation axis when using relperm data of "family 2".
- [#595](https://github.com/equinor/webviz-subsurface/pull/595) - Raise a descriptive error in SurfaceViewerFMU plugin if no surfaces are available.
Expand Down
25 changes: 25 additions & 0 deletions tests/unit_tests/data_input/test_calc_from_cumulatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ def test_calc_from_cumulatives(testdata_folder: Path) -> None:
- real_data[real_data.DATE == "2002-02-01"]["GWPT:OP"].values
)

# Resample the data to yearly datapoints:
data_df = data_df[
data_df["DATE"].isin(["2000-01-01", "2001-01-01", "2002-01-01", "2003-01-01"])
]
calc_df = from_cum.calc_from_cumulatives(
data=data_df,
column_keys=["WGPT:OP_2", "GWPT:OP"],
time_index="yearly",
time_index_input="yearly",
as_rate=False,
)
# Test real 9, iter-0
real_data = data_df[(data_df["REAL"] == 9) & (data_df["ENSEMBLE"] == "iter-0")]
real_calc = calc_df[(calc_df["REAL"] == 9) & (calc_df["ENSEMBLE"] == "iter-0")]

assert real_calc[real_calc.DATE == "2000-01-01"]["INTVL_WGPT:OP_2"].values == (
real_data[real_data.DATE == "2001-01-01"]["WGPT:OP_2"].values
- real_data[real_data.DATE == "2000-01-01"]["WGPT:OP_2"].values
)

assert real_calc[real_calc.DATE == "2002-01-01"]["INTVL_GWPT:OP"].values == (
real_data[real_data.DATE == "2003-01-01"]["GWPT:OP"].values
- real_data[real_data.DATE == "2002-01-01"]["GWPT:OP"].values
)


@pytest.mark.parametrize(
"column_keys,time_index,time_index_input,as_rate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def calc_from_cumulatives(
def _verify_time_index(
df: pd.DataFrame, time_index: str, time_index_input: str
) -> None:
freqs = {"D": "daily", "MS": "monthly", "YS": "yearly"}
freqs = {"D": "daily", "MS": "monthly", "AS-JAN": "yearly"}
valid_time_indices = {
"daily": ["daily", "monthly", "yearly"],
"monthly": ["monthly", "yearly"],
Expand Down

0 comments on commit ada4c9f

Please sign in to comment.