Skip to content

Commit

Permalink
Update example notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
perolavsvendsen committed Jan 16, 2024
1 parent 77ee7eb commit 70fe5ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
18 changes: 9 additions & 9 deletions examples/explorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,24 @@
"from fmu.sumo.explorer import TimeFilter, TimeType\n",
"\n",
"# get surfaces with timestamps\n",
"time = TimeFilter(type=TimeType.TIMESTAMP)\n",
"time = TimeFilter(time_type=TimeType.TIMESTAMP)\n",
"surfs = case.surfaces.filter(time=time)\n",
"print(\"Timestamp:\", len(surfs))\n",
"\n",
"# get surfaces with time intervals\n",
"time = TimeFilter(type=TimeType.INTERVAL)\n",
"time = TimeFilter(time_type=TimeType.INTERVAL)\n",
"surfs = case.surfaces.filter(time=time)\n",
"print(\"Interval:\", len(surfs))\n",
"\n",
"\n",
"# get surfaces with time data (timestamp or interval)\n",
"time = TimeFilter(type=TimeType.ALL)\n",
"time = TimeFilter(time_type=TimeType.ALL)\n",
"surfs = case.surfaces.filter(time=time)\n",
"print(\"Time data:\", len(surfs))\n",
"\n",
"\n",
"# get surfaces without time data\n",
"time = TimeFilter(type=TimeType.NONE)\n",
"time = TimeFilter(time_type=TimeType.NONE)\n",
"surfs = case.surfaces.filter(time=time)\n",
"print(\"No time data:\", len(surfs))\n",
"\n",
Expand All @@ -277,23 +277,23 @@
"\n",
"\n",
"# get surfaces with timestamp in range\n",
"time = TimeFilter(type=TimeType.TIMESTAMP, start=\"2018-01-01\", end=\"2022-01-01\")\n",
"time = TimeFilter(time_type=TimeType.TIMESTAMP, start=\"2018-01-01\", end=\"2022-01-01\")\n",
"surfs = case.surfaces.filter(time=time)\n",
"\n",
"# get surfaces with time intervals in range\n",
"time = TimeFilter(type=TimeType.INTERVAL, start=\"2018-01-01\", end=\"2022-01-01\")\n",
"time = TimeFilter(time_type=TimeType.INTERVAL, start=\"2018-01-01\", end=\"2022-01-01\")\n",
"surfs = case.surfaces.filter(time=time)\n",
"\n",
"# get surfaces where intervals overlap with range\n",
"time = TimeFilter(type=TimeType.INTERVAL, start=\"2018-01-01\", end=\"2022-01-01\", overlap=True)\n",
"time = TimeFilter(time_type=TimeType.INTERVAL, start=\"2018-01-01\", end=\"2022-01-01\", overlap=True)\n",
"surfs = case.surfaces.filter(time=time)\n",
"\n",
"# get surfaces with exact timestamp matching (t0 == start)\n",
"time = TimeFilter(type=TimeType.TIMESTAMP, start=\"2018-01-01\", exact=True)\n",
"time = TimeFilter(time_type=TimeType.TIMESTAMP, start=\"2018-01-01\", exact=True)\n",
"surfs = case.surfaces.filter(time=time)\n",
"\n",
"# get surfaces with exact interval matching (t0 == start AND t1 == end)\n",
"time = TimeFilter(type=TimeType.INTERVAL, start=\"2018-01-01\", end=\"2022-01-01\", exact=True)\n",
"time = TimeFilter(time_type=TimeType.INTERVAL, start=\"2018-01-01\", end=\"2022-01-01\", exact=True)\n",
"surfs = case.surfaces.filter(time=time)"
]
}
Expand Down
33 changes: 19 additions & 14 deletions examples/tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
"import pandas as pd\n",
"import pyarrow as pa\n",
"from fmu.sumo.explorer import Explorer, AggregatedTable\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
"%matplotlib inline\n",
"\n",
"# These examples use Seaborn for plotting. Seaborn does not automatically install with\n",
"# fmu-sumo. If your environment does not have Seaborn installed, uncomment line below.\n",
"\n",
"# !pip install seaborn\n",
"import seaborn as sns"
]
},
{
Expand Down Expand Up @@ -145,7 +150,7 @@
"\n",
"# fetching the actual table as a Pandas dataframe\n",
"print(one_table.name)\n",
"print(one_table.to_pandas.head())\n",
"print(one_table.to_pandas().head())\n",
"\n",
"# If you know the metadata fields you can access the data directly on the object with square brackets\n",
"print(one_table[\"data\"])"
Expand Down Expand Up @@ -253,7 +258,7 @@
"source": [
"\n",
"pressure = rft_tables.filter(column=\"PRESSURE\")[0]\n",
"frame = pressure.to_pandas\n",
"frame = pressure.to_pandas()\n",
"print(f\"The following columns are in the pressure object {frame.columns.to_list()}\")"
]
},
Expand Down Expand Up @@ -333,8 +338,8 @@
"outputs": [],
"source": [
"GRID = AggregatedTable(case, \"DROGON\", \"grid\", \"iter-0\")\n",
"GRID[\"PORO\"].to_pandas.plot(kind=\"hist\", y=\"PORO\")\n",
"GRID[\"PERMX\"].to_pandas.head()"
"GRID[\"PORO\"].to_pandas().plot(kind=\"hist\", y=\"PORO\")\n",
"GRID[\"PERMX\"].to_pandas().head()"
]
},
{
Expand All @@ -352,7 +357,7 @@
"source": [
"EQUIL = AggregatedTable(case, \"DROGON\", \"equil\", \"iter-0\")\n",
"CONTACT_TYPE = \"OWC\"\n",
"sns.boxplot(pd.pivot_table(EQUIL[CONTACT_TYPE].to_pandas, index=\"REAL\", columns=\"EQLNUM\", values=CONTACT_TYPE).values)\n",
"sns.boxplot(pd.pivot_table(EQUIL[CONTACT_TYPE].to_pandas(), index=\"REAL\", columns=\"EQLNUM\", values=CONTACT_TYPE).values)\n",
"plt.show()"
]
},
Expand All @@ -371,7 +376,7 @@
"source": [
"RELPERM = AggregatedTable(case, \"DROGON\", \"satfunc\", \"iter-0\")\n",
"\n",
"KRW = pd.concat((RELPERM[\"KRW\"].to_pandas,RELPERM[\"SW\"].to_pandas ), axis=1).T.drop_duplicates().T\n",
"KRW = pd.concat((RELPERM[\"KRW\"].to_pandas(), RELPERM[\"SW\"].to_pandas()), axis=1).T.drop_duplicates().T\n",
"print(KRW.head())"
]
},
Expand Down Expand Up @@ -409,7 +414,7 @@
"\n",
"summary = AggregatedTable(case, \"DROGON\", \"summary\", \"iter-0\")\n",
"VECTOR_NAME = \"FOIP\"\n",
"ax = pd.pivot_table(summary[VECTOR_NAME].to_pandas, index=\"DATE\", columns=\"REAL\", values=VECTOR_NAME).dropna(axis=0).plot()\n",
"ax = pd.pivot_table(summary[VECTOR_NAME].to_pandas(), index=\"DATE\", columns=\"REAL\", values=VECTOR_NAME).dropna(axis=0).plot()\n",
"ax.get_legend().remove()\n",
"ax.set_label(VECTOR_NAME)\n",
"plt.show()"
Expand All @@ -429,7 +434,7 @@
"outputs": [],
"source": [
"COMPDAT = AggregatedTable(case, \"DROGON\", \"compdat\", iteration=\"iter-0\")\n",
"COMPDAT[\"KH\"].to_pandas"
"COMPDAT[\"KH\"].to_pandas()"
]
},
{
Expand All @@ -446,7 +451,7 @@
"outputs": [],
"source": [
"COMPLETIONS = AggregatedTable(case, \"DROGON\", \"wellcompletiondata\", \"iter-0\")\n",
"KH = COMPLETIONS[\"KH\"].to_pandas\n",
"KH = COMPLETIONS[\"KH\"].to_pandas()\n",
"KH.head()"
]
},
Expand Down Expand Up @@ -494,7 +499,7 @@
"REPORTS = AggregatedTable(case, \"DROGON\", \"fipreports\", \"iter-0\")\n",
"print(REPORTS.columns)\n",
"REPORT_NAME = \"STOIIP_OIL\"\n",
"STOIIP = REPORTS[REPORT_NAME].to_pandas.dropna(subset=REPORT_NAME, axis=0)\n",
"STOIIP = REPORTS[REPORT_NAME].to_pandas().dropna(subset=REPORT_NAME, axis=0)\n",
"STOIIP.head()"
]
},
Expand All @@ -514,7 +519,7 @@
"source": [
"FAULTS = AggregatedTable(case, \"DROGON\", \"faults\", \"iter-0\")\n",
"print(FAULTS.columns)\n",
"COMPLETE = pd.concat((FAULTS[\"I\"].to_pandas,FAULTS[\"J\"].to_pandas, FAULTS[\"K\"].to_pandas))\n",
"COMPLETE = pd.concat((FAULTS[\"I\"].to_pandas(), FAULTS[\"J\"].to_pandas(), FAULTS[\"K\"].to_pandas()))\n",
"COMPLETE.head()"
]
},
Expand Down Expand Up @@ -563,7 +568,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.8.18"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 70fe5ca

Please sign in to comment.