コード例 #1
0
def test_eqlnum2(tmpdir, mocker):
    """What if a model does not have EQLNUM=1 cells present"""
    tmpdir.chdir()
    pd.DataFrame([
        # This dataframe is a minimum dataset for check_swatinit
        # to run.
        {
            "EQLNUM": 2,
            "Z": 1000,
            "SWATINIT": 0.9,
            "PORV": 100,
            "SWAT": 0.8,
            "VOLUME": 80,
            "QC_FLAG": __PC_SCALED__,
            "SATNUM": 2,
            "PCOW_MAX": 2,
            "PPCW": 4,
            "PC_SCALING": 2,
            "OIP_INIT": 0,
        }
    ]).to_csv("foo.csv")

    # Should not error:
    mocker.patch("sys.argv", ["check_swatinit", "foo.csv"])
    main()

    # But default plotting should error:
    mocker.patch("sys.argv", ["check_swatinit", "foo.csv", "--plot"])
    with pytest.raises(SystemExit, match="EQLNUM 1 does not exist in grid"):
        main()
コード例 #2
0
def test_rptrst_allprops(simulator, tmp_path, mocker):
    """Test what happens when RPTRST is ALLPROPS (which probably implies BASIC=1)"""
    os.chdir(tmp_path)
    model = PillarModel(rptrst="ALLPROPS")
    run_reservoir_simulator(simulator, model, perform_qc=False)
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    main()  # No exceptions.
コード例 #3
0
def test_rptrst_basic_1(simulator, tmp_path, mocker):
    """Test what happens when RPTRST is BASIC=1"""
    os.chdir(tmp_path)
    model = PillarModel(rptrst="BASIC=1")
    run_reservoir_simulator(simulator, model, perform_qc=False)
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    main()  # No exceptions/errors.
コード例 #4
0
def test_no_unifout(tmp_path, mocker):
    """Test what happens when UNIFOUT is not included"""
    os.chdir(tmp_path)
    model = PillarModel(unifout="")
    run_reservoir_simulator(find_flow_simulator(), model, perform_qc=False)
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    with pytest.raises(SystemExit, match="UNIFOUT"):
        main()
コード例 #5
0
def test_no_swatinit(tmp_path, mocker, caplog):
    """Test what check_swatinit does on a case not initialized by SWATINIT"""
    os.chdir(tmp_path)
    model = PillarModel(swatinit=[None])
    run_reservoir_simulator(find_flow_simulator(), model, perform_qc=False)
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    main()
    assert "INIT-file/deck does not have SWATINIT" in caplog.text
コード例 #6
0
def test_no_rptrst(tmpdir, mocker):
    """Test what happens when RPTRST is not included, no UNRST"""
    tmpdir.chdir()
    model = PillarModel(rptrst="")
    run_reservoir_simulator(find_flow_simulator(), model, perform_qc=False)
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    with pytest.raises(SystemExit, match="UNRST"):
        main()
コード例 #7
0
def test_no_unrst(tmp_path, mocker):
    """Test what happens when there is no restart file with SWAT[0]"""
    os.chdir(tmp_path)
    model = PillarModel()
    run_reservoir_simulator(find_flow_simulator(), model, perform_qc=False)
    os.unlink("FOO.UNRST")
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    with pytest.raises(SystemExit, match="UNRST"):
        main()
コード例 #8
0
def test_no_filleps(tmp_path, mocker, caplog):
    """Test the output when we don't have SWL (FILLEPS is needed)"""
    os.chdir(tmp_path)
    model = PillarModel(filleps="")
    run_reservoir_simulator(find_flow_simulator(), model, perform_qc=False)
    mocker.patch("sys.argv", ["check_swatinit", "FOO.DATA"])
    main()
    assert "SWL not found" in caplog.text
    assert "FILLEPS" in caplog.text
コード例 #9
0
def test_reek(tmpdir, mocker):
    """Test that we can run on the Reek dataset with no crashes,
    and with plotting to file"""

    tmpdir.chdir()
    mocker.patch(
        "sys.argv",
        [
            "check_swatinit",
            str(REEK_DATAFILE),
            "--output",
            "foo.csv",
            "--plotfile",
            "scatter.png",
            "--volplotfile",
            "volplot.png",
        ],
    )
    main()
    qc_frame = pd.read_csv("foo.csv")
    assert Path("scatter.png").exists()
    assert Path("volplot.png").exists()

    # Check that we never get -1e20 from libecl in any data:
    assert np.isclose(qc_frame.select_dtypes("number").min().min(),
                      -7097,
                      atol=1)
    assert np.isclose(qc_frame.select_dtypes("number").max().max(),
                      5938824,
                      atol=1)

    mocker.patch(
        "sys.argv",
        [
            "check_swatinit",
            "foo.csv",
            "--plotfile",
            "scatter_eqlnum2.png",
            "--eqlnum",
            "2",
        ],
    )
    main()
    # (EQLNUM 2 in Reek is only water)
    assert Path("scatter_eqlnum2.png").exists()

    mocker.patch(
        "sys.argv",
        [
            "check_swatinit",
            "foo.csv",
            "--plotfile",
            "scatter_eqlnum99.png",
            "--eqlnum",
            "99",
        ],
    )
    with pytest.raises(SystemExit, match="EQLNUM"):
        main()
    assert not Path("scatter_eqlnum99.png").exists()