Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revised EnsembleSummaryProvider interface #950

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED] - YYYY-MM-DD

### Changed

- [#950](https://github.com/equinor/webviz-subsurface/pull/950) - Revised `EnsembleSummaryProvider` to support finer control of which range of dates get returned when using lazy resampling and requesting data for multiple realizations. Note that this is a breaking change in the `EnsembleSummaryProvider` interface, see PR for more details.

## [0.2.11] - 2022-03-14

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import pandas as pd

from webviz_subsurface._providers import (
DateSpan,
EnsembleSummaryProvider,
Frequency,
ResamplingOptions,
VectorMetadata,
)

Expand Down Expand Up @@ -43,6 +45,7 @@ def vector_names_filtered_by_value(
def dates(
self,
resampling_frequency: Optional[Frequency],
date_span: DateSpan = DateSpan.UNION,
realizations: Optional[Sequence[int]] = None,
) -> List[datetime.datetime]:
raise NotImplementedError("Method not implemented for mock!")
Expand All @@ -53,7 +56,7 @@ def supports_resampling(self) -> bool:
def get_vectors_df(
self,
vector_names: Sequence[str],
resampling_frequency: Optional[Frequency],
resampling_options: Optional[ResamplingOptions],
realizations: Optional[Sequence[int]] = None,
) -> pd.DataFrame:
raise NotImplementedError("Method not implemented for mock!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
),
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
expressions=[TEST_EXPRESSION],
resampling_frequency=None,
resampling_options=None,
)

TEST_AFTER_2262_ACCESSOR = DerivedDeltaEnsembleVectorsAccessorImpl(
Expand All @@ -173,7 +173,7 @@
),
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
expressions=[TEST_EXPRESSION],
resampling_frequency=None,
resampling_options=None,
)

TEST_EMPTY_ACCESSOR = DerivedDeltaEnsembleVectorsAccessorImpl(
Expand All @@ -184,7 +184,7 @@
),
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
expressions=None,
resampling_frequency=None,
resampling_options=None,
)

# *******************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@
provider=EnsembleSummaryProviderMock(INPUT_DF),
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
expressions=[TEST_EXPRESSION],
resampling_frequency=None,
resampling_options=None,
)

TEST_AFTER_2262_ACCESSOR = DerivedEnsembleVectorsAccessorImpl(
name="Test after 2262 accessor",
provider=EnsembleSummaryProviderMock(INPUT_AFTER_2262_DF),
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
expressions=[TEST_EXPRESSION],
resampling_frequency=None,
resampling_options=None,
)

TEST_EMPTY_ACCESSOR = DerivedEnsembleVectorsAccessorImpl(
name="Empty provider accessor",
provider=EnsembleSummaryProviderMock(pd.DataFrame()),
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
expressions=None,
resampling_frequency=None,
resampling_options=None,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_create_derived_vectors_accessor_dict() -> None:
provider_set=provider_set,
expressions=[],
delta_ensembles=delta_ensembles,
resampling_frequency=None,
resampling_options=None,
relative_date=None,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from webviz_subsurface._providers import (
EnsembleSummaryProviderFactory,
Frequency,
ResamplingOptions,
VectorMetadata,
)

Expand Down Expand Up @@ -80,15 +81,19 @@ def test_create_from_arrow_unsmry_lazy(testdata_folder: Path, tmp_path: Path) ->
assert realizations[0] == 0
assert realizations[-1] == 99

vecdf = provider.get_vectors_df(["FOPR"], Frequency.MONTHLY)
vecdf = provider.get_vectors_df(
["FOPR"], ResamplingOptions(frequency=Frequency.MONTHLY)
)
assert vecdf.shape == (3100, 3)
assert vecdf.columns.tolist() == ["DATE", "REAL", "FOPR"]
assert vecdf["DATE"].nunique() == 31
assert vecdf["REAL"].nunique() == 100
sampleddate = vecdf["DATE"][0]
assert isinstance(sampleddate, datetime.datetime)

vecdf = provider.get_vectors_df(["FOPR"], Frequency.MONTHLY, [5])
vecdf = provider.get_vectors_df(
["FOPR"], ResamplingOptions(frequency=Frequency.MONTHLY), [5]
)
assert vecdf.shape == (31, 3)
assert vecdf.columns.tolist() == ["DATE", "REAL", "FOPR"]
assert vecdf["DATE"].nunique() == 31
Expand Down
Loading