Exemple #1
0
def test_prepare_econ_table_csv(tmpdir):
    """Testing loading economics data from a CSV file"""
    tmpdir.chdir()
    Path("econ.csv").write_text(
        "year, oilprice, gasprice, costs\n2030, 60, 2, 100")

    with pytest.raises(ValueError):
        # usdtonok is not present:
        econ_df = presentvalue.prepare_econ_table("econ.csv")

    econ_df = presentvalue.prepare_econ_table("econ.csv", usdtonok=7)
    assert len(econ_df) == 1
    assert econ_df["discountrate"].unique() == [8]  # defaulted
    assert econ_df["usdtonok"].unique() == [7]
    assert econ_df["costs"].unique() == [100]
    assert econ_df.index.values == [2030]
Exemple #2
0
def test_no_gas(tmpdir):
    """Test that summary files with no gas prod/injection works
    (missing GPT is the same as zero GPT)"""
    tmpdir.chdir()
    smry = pd.DataFrame([
        {
            "DATE": "2030-01-01",
            "FOPT": 0
        },
        {
            "DATE": "2031-01-01",
            "FOPT": 1000
        },
    ])
    smry["DATE"] = pd.to_datetime(smry["DATE"])
    smry.set_index("DATE")
    eclsum = ecl2df.summary.df2eclsum(smry, "NOGAS")
    ecl.summary.EclSum.fwrite(eclsum)
    econ_df = presentvalue.prepare_econ_table(oilprice=100,
                                              gasprice=0,
                                              usdtonok=10,
                                              discountrate=0)
    assert np.isclose(
        presentvalue.presentvalue_main("NOGAS", econ_df,
                                       discountto=2030)["PresentValue"],
        presentvalue.BARRELSPRCUBIC,
    )
Exemple #3
0
def test_no_oil(tmpdir):
    """Test that summary files with only gas prod/injection works"""

    tmpdir.chdir()
    smry = pd.DataFrame([
        {
            "DATE": "2030-01-01",
            "FGPT": 0
        },
        {
            "DATE": "2031-01-01",
            "FGPT": 1000
        },
    ])
    smry["DATE"] = pd.to_datetime(smry["DATE"])
    smry.set_index("DATE")
    eclsum = ecl2df.summary.df2eclsum(smry, "NOOIL")
    ecl.summary.EclSum.fwrite(eclsum)
    econ_df = presentvalue.prepare_econ_table(oilprice=0,
                                              gasprice=10,
                                              usdtonok=10,
                                              discountrate=0)
    assert np.isclose(
        presentvalue.presentvalue_main("NOOIL", econ_df,
                                       discountto=2030)["PresentValue"],
        0.01,
    )
Exemple #4
0
def test_prepare_econ_table_simpletest():
    """A simple test of preparation of an economics dataframe,
    without loading from CSV"""
    econ_df = presentvalue.prepare_econ_table(
        oilprice=122, gasprice=33, usdtonok=11, discountrate=99
    )
    assert len(econ_df) == 1
    assert econ_df["oilprice"].unique() == [122]
    assert econ_df["gasprice"].unique() == [33]
    assert econ_df["usdtonok"].unique() == [11]
    assert econ_df["discountrate"].unique() == [99]
    assert econ_df.index.name == "year"