Skip to content

Commit

Permalink
Add test function illustrating rate matching inconsistencey
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Aug 26, 2024
1 parent 0b1f308 commit 686ffa6
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion tests/test_observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import glob
import logging
import os

import contextlib
import dateutil
import numpy as np
import pandas as pd
import pytest
import yaml
from fmu.ensemble import EnsembleSet, Observations, ScratchEnsemble, ScratchRealization
from pathlib import Path
import res2df

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -228,6 +230,47 @@ def test_smry():
# print(vmismatch)


def test_smry_handling_of_rate_vectors(tmpdir):
"""Rate vectors in Eclipse are valid backwards in time.
Computing mismatches on rates for a specific date thus needs to look
forward in time.
"""
df = pd.DataFrame(
[
{"DATE": "2024-01-01", "FOPR": 10},
{"DATE": "2024-02-01", "FOPR": 100},
{"DATE": "2024-03-01", "FOPR": 1000},
]
)

real_dir = Path(tmpdir / "realization-0" / "iter-0")
ecl_dir = real_dir / "eclipse" / "model"
ecl_dir.mkdir(parents=True)
with contextlib.chdir(ecl_dir):
res_smry = res2df.summary.df2ressum(df, casename="FOPRTEST")
res_smry.fwrite()

rate_obs = Observations(
{
"smry": [
{
"key": "FOPR",
"observations": [
{"date": datetime.date(2024, 2, 1), "error": 1, "value": 1000}
],
}
]
}
)

real = ScratchRealization(str(real_dir))
real.load_smry()
mismatch = rate_obs.mismatch(real)
assert mismatch.loc[0, "MISMATCH"] == 0.0


def test_smry_labels():
testdir = os.path.dirname(os.path.abspath(__file__))
real = ScratchRealization(
Expand Down

0 comments on commit 686ffa6

Please sign in to comment.