def test_filters(self, data_grid):
        """Test filters as argument"""
        data_grid["filters"] = {
            "reek_sim_facies2.roff": {
                "include": ["FINESAND", "COARSESAND"],
            }
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert ["FINESAND", "COARSESAND"] == list(pdf.dataframe["FACIES"].unique())
        assert pdf.dataframe["PORO"].mean() == pytest.approx(0.2374, abs=0.001)

        data_grid["filters"] = {
            "reek_sim_facies2.roff": {
                "exclude": "FINESAND",
            }
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert "FINESAND" not in list(pdf.dataframe["FACIES"].unique())

        data_grid["filters"] = {
            "reek_sim_poro.roff": {
                "range": [0.15, 0.25],
            }
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())
        assert pdf.dataframe["PORO"].mean() == pytest.approx(0.2027, abs=0.001)
        assert pdf.dataframe["PORO"].min() > 0.15
        assert pdf.dataframe["PORO"].max() < 0.25
Exemple #2
0
    def _extract_statistics(
        self, dtype: str, data: dict, project: Optional[object], source: str
    ):
        """Create dataframe from properties and extract statistics"""
        QCC.verbosity = data.get("verbosity", 0)
        QCC.print_info("Starting run...")

        # Create Property dataframe from input (using XTGeo)
        property_data = (
            GridProps2df(project=project, data=data, xtgdata=self._xtgdata)
            if dtype == "grid"
            else WellLogs2df(
                project=project,
                data=data,
                xtgdata=self._xtgdata,
                blockedwells=dtype == "bwells",
            )
        )

        # Compute statistics
        stats = PropertyAggregation(property_data)

        self._set_dataframe_id_and_class_attributes(
            stats,
            source=source,
            run_id=data.get("name", source),
        )

        return stats.dataframe
Exemple #3
0
 def test_gridprops(self, data_grid):
     """Test creating property dataframe from grid properties"""
     pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())
     assert pdf.dataframe["PORO"].mean() == pytest.approx(0.1677, abs=0.001)
     assert pdf.dataframe["PORO"].max() == pytest.approx(0.3613, abs=0.001)
     assert set(pdf.dataframe.columns) == set(
         ["PORO", "PERM", "ZONE", "FACIES"])
Exemple #4
0
    def test_codenames(self, data_grid):
        """Test modifying codenames on selectors"""

        data_grid["selectors"] = {
            "ZONE": {
                "name": "reek_sim_zone.roff",
                "codes": {
                    1: "TOP",
                    2: "MID"
                }
            },
            "FACIES": {
                "name": "reek_sim_facies2.roff",
                "codes": {
                    1: "SAND",
                    2: "SAND"
                },
            },
        }

        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert set(["TOP", "MID", "Below_Low_reek"]) == {
            x
            for x in list(pdf.dataframe["ZONE"].unique()) if x is not None
        }

        assert set(["SAND", "SHALE"]) == {
            x
            for x in list(pdf.dataframe["FACIES"].unique()) if x is not None
        }
    def test_selector_filters(self, data_grid):
        """Test filters on selector"""
        data_grid["selectors"] = {
            "FACIES": {"name": "reek_sim_facies2.roff", "include": "FINESAND"},
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert ["FINESAND"] == list(pdf.dataframe["FACIES"].unique())

        # test exclude values using list
        data_grid["selectors"] = {
            "FACIES": {
                "name": "reek_sim_facies2.roff",
                "exclude": ["FINESAND", "SHALE"],
            },
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert "FINESAND" not in list(pdf.dataframe["FACIES"].unique())
        assert "SHALE" not in list(pdf.dataframe["FACIES"].unique())
    def test_filters_and_selector_filters(self, data_grid):
        """
        Test filters on both selector and as separate argument
        Wanted behaviour is to ignore the filter on the selector
        """
        data_grid["selectors"] = {
            "FACIES": {"name": "reek_sim_facies2.roff", "exclude": "FINESAND"},
        }
        data_grid["filters"] = {
            "reek_sim_facies2.roff": {
                "include": ["FINESAND", "COARSESAND"],
            }
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert ["FINESAND", "COARSESAND"] == list(pdf.dataframe["FACIES"].unique())
        assert pdf.dataframe["PORO"].mean() == pytest.approx(0.2374, abs=0.001)
    def test_filters_and_property_filters(self, data_grid):
        """
        Test filters on both properties and as separate argument.
        Wanted behaviour is to ignore the filter on the property
        """
        data_grid["properties"] = {
            "PORO": {"name": "reek_sim_poro.roff", "range": [0.2, 0.4]},
        }
        data_grid["filters"] = {
            "reek_sim_poro.roff": {
                "range": [0.15, 0.25],
            }
        }
        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())

        assert pdf.dataframe["PORO"].mean() == pytest.approx(0.2027, abs=0.001)
        assert pdf.dataframe["PORO"].min() > 0.15
        assert pdf.dataframe["PORO"].max() < 0.25
Exemple #8
0
    def test_props_and_selectors_as_list(self, data_grid):
        """Test"""
        data_grid["properties"] = ["reek_sim_poro.roff", "reek_sim_permx.roff"]
        data_grid["selectors"] = [
            "reek_sim_zone.roff", "reek_sim_facies2.roff"
        ]

        pdf = GridProps2df(data=data_grid, project=None, xtgdata=QCData())
        assert pdf.dataframe["reek_sim_poro.roff"].mean() == pytest.approx(
            0.1677, abs=0.001)
        assert pdf.dataframe["reek_sim_poro.roff"].max() == pytest.approx(
            0.3613, abs=0.001)
        assert set(pdf.dataframe.columns) == set([
            "reek_sim_poro.roff",
            "reek_sim_permx.roff",
            "reek_sim_zone.roff",
            "reek_sim_facies2.roff",
        ])