Beispiel #1
0
def test_merge_rms_volumetrics_explicit(tmpdir):
    """Test finding and merging of multiple RMS volumetrics files"""
    tmpdir.chdir()
    Path("test_oil_1.txt").write_text("Zone  Bulk\nUpper  1.0")
    Path("test_gas_1.txt").write_text("Zone  Bulk\nUpper  1.0")
    Path("test_total_1.txt").write_text("Zone  Bulk\nUpper  1.0")

    expected_frame = pd.DataFrame([{
        "ZONE": "Upper",
        "BULK_OIL": 1.0,
        "BULK_GAS": 1.0,
        "BULK_TOTAL": 1.0
    }])
    pd.testing.assert_frame_equal(
        volumetrics.merge_rms_volumetrics("test"),
        expected_frame,
        check_like=True,
    )

    # Add a dummy file that we should not discover, and thus not interfere:
    Path("test_dummy_1.txt").write_text("aslkdjfa")
    pd.testing.assert_frame_equal(
        volumetrics.merge_rms_volumetrics("test"),
        expected_frame,
        check_like=True,
    )

    # What if there is no files found:
    with pytest.raises(OSError,
                       match="No volumetrics files found for filebase foo"):
        volumetrics.merge_rms_volumetrics("foo")
Beispiel #2
0
def main() -> None:
    args = get_parser().parse_args()

    if args.PRTFILE.endswith("csv"):
        simvolumes_df = pd.read_csv(args.PRTFILE, index_col="FIPNUM")
    else:
        simvolumes_df = currently_in_place_from_prt(args.PRTFILE, "FIPNUM")

    volumetrics_df = volumetrics.merge_rms_volumetrics(
        args.volumetricsbase).set_index(["REGION", "ZONE"])

    disjoint_sets_df = fipmapper.FipMapper(
        yamlfile=args.fipmapconfig).disjoint_sets()

    comparison_df = _compare_volumetrics(disjoint_sets_df, simvolumes_df,
                                         volumetrics_df)
    if args.sets:
        Path(args.sets).write_text(
            yaml.dump(_disjoint_sets_to_dict(disjoint_sets_df)))
    if args.output:
        comparison_df.to_csv(args.output, float_format="%g", index=False)
        logger.info("Written %d rows to %s", len(comparison_df), args.output)
    else:
        pd.set_option("display.max_rows", 1000)
        pd.set_option("display.max_columns", 50)
        pd.set_option("display.width", 1000)
        print(disjoint_sets_df)
        print(comparison_df.set_index("SET"))
Beispiel #3
0
def test_merge_rms_volumetrics_mixedcols(tmpdir):
    """Bulk in one file and Pore in another, just means we don't get all columns"""
    tmpdir.chdir()
    Path("test_oil_1.txt").write_text("Zone  Bulk\nUpper  1.0")
    Path("test_gas_1.txt").write_text("Zone  Pore\nUpper  1.0")
    Path("test_total_1.txt").write_text("Zone  Bulk\nUpper  1.0")

    expected_frame = pd.DataFrame([{
        "ZONE": "Upper",
        "BULK_OIL": 1.0,
        "PORV_GAS": 1.0,
        "BULK_TOTAL": 1.0
    }])
    pd.testing.assert_frame_equal(
        volumetrics.merge_rms_volumetrics("test"),
        expected_frame,
        check_like=True,
    )