Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/check_opmkeywords.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check OPM Keywords

on:
schedule:
# Run weekly on Monday at 00:00 UTC
- cron: '0 0 * * 1'

jobs:
check-opmkeywords:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Run opmkeywords sync script
run: |
set -euo pipefail
cd scripts
bash runmetoupdate.sh src/res2df/opmkeywords

- name: Check for changes
run: |
if [ -n "$(git status --porcelain src/res2df/opmkeywords/)" ]; then
echo "::error::OPM keywords are out of date!"
echo "The following files have changed:"
git status --porcelain src/res2df/opmkeywords/
echo ""
echo "Please run 'cd scripts && bash runmetoupdate.sh' locally and commit the changes."
git diff src/res2df/opmkeywords/
exit 1
else
echo "OPM keywords are up to date."
fi
80 changes: 80 additions & 0 deletions scripts/runmetoupdate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
#
# Run this to download a fresh copy of E100 keyword metadata from opm-common

# Default output directory (if not provided as an argument)
OUTPUT_DIR=${1:-"./"}

# Ensure the output directory exists
mkdir -p "$OUTPUT_DIR"

# Remember to sync the keyword list here with the list in common.py
keywords="
BRANPROP
COMPDAT
COMPLUMP
COMPSEGS
DENSITY
EQLDIMS
EQUIL
FAULTS
GRUPNET
GRUPTREE
NODEPROP
PBVD
PDVD
PVDG
PVDO
PVTG
PVTO
PVTW
ROCK
RSVD
RVVD
SGFN
SGOF
SGWFN
SLGOF
SOF2
SOF3
SWFN
SWOF
TABDIMS
VFPPROD
VFPINJ
WCONHIST
WCONINJE
WCONINJH
WCONPROD
WELOPEN
WELSEGS
WELSPECS
WLIST
WSEGAICD
WSEGSICD
WSEGVALV
"

for keyword in $keywords; do
firstletter=${keyword:0:1}
wget https://raw.githubusercontent.com/OPM/opm-common/master/opm/input/eclipse/share/keywords/000_Eclipse100/$firstletter/$keyword -O "$OUTPUT_DIR/$keyword"

# Assume that the presence of num_tables in some keywords is sort of a bug:
perl -p -i -e 's/num_tables/size/g' "$OUTPUT_DIR/$keyword"

# Fix multi-line comments in JSON files by replacing newlines with spaces
perl -0777 -p -i -e 's/"comment"\s*:\s*"((?:[^"\\]|\\.)*)"/"comment": "\1"/g; s/\n/ /g if /"comment":/' "$OUTPUT_DIR/$keyword"


# Pretty-print all json files (this is also done upstream)

if jq '.' "$OUTPUT_DIR/$keyword" > "$OUTPUT_DIR/$keyword.tmp"; then
rm "$OUTPUT_DIR/$keyword" && mv "$OUTPUT_DIR/$keyword.tmp" "$OUTPUT_DIR/$keyword"
else
rm "$OUTPUT_DIR/$keyword.tmp"
fi

git add "$OUTPUT_DIR/$keyword"
done

git status .
9 changes: 6 additions & 3 deletions src/res2df/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,18 @@ def keyworddata_to_df(
else:
dict_records.append(recdict)
record_counter += 1
result_df: pd.DataFrame
if df_records and dict_records:
dict_df = pd.DataFrame(data=dict_records)
return pd.concat([*df_records, dict_df]).reset_index(drop=True)
result_df = pd.concat([*df_records, dict_df])
elif df_records: # trust that this is all one type?
return pd.concat(df_records).reset_index(drop=True)
result_df = pd.concat(df_records)
elif dict_records: # records contain lists.
return pd.DataFrame(data=dict_records).reset_index(drop=True)
result_df = pd.DataFrame(data=dict_records)
else:
return pd.DataFrame()
# Drop columns that are entirely NaN/None (e.g., unused optional keyword items)
return result_df.reset_index(drop=True).dropna(axis=1, how="all")


def parse_opmio_deckrecord(
Expand Down
2 changes: 1 addition & 1 deletion src/res2df/compdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def deck2dfs(
)
)
if "INFO_TYPE" in rec_data and rec_data["INFO_TYPE"] == "ABS":
rec_data["SEGMENT_MD"] = rec_data["SEGMENT_LENGTH"]
rec_data["SEGMENT_MD"] = rec_data["LENGTH"]
welsegsrecords.append(rec_data)
elif kword.name == "WLIST":
for rec in kword:
Expand Down
6 changes: 6 additions & 0 deletions src/res2df/opmkeywords/BRANPROP
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"sections": [
"SCHEDULE"
],
"requires": [
"NETWORK"
],
"prohibits": [
"GRUPNET"
],
"items": [
{
"name": "DOWNTREE_NODE",
Expand Down
17 changes: 16 additions & 1 deletion src/res2df/opmkeywords/COMPDAT
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,85 @@
],
"items": [
{
"item": 1,
"name": "WELL",
"value_type": "STRING"
},
{
"item": 2,
"name": "I",
"value_type": "INT",
"default": 0
},
{
"item": 3,
"name": "J",
"value_type": "INT",
"default": 0
},
{
"item": 4,
"name": "K1",
"value_type": "INT"
},
{
"item": 5,
"name": "K2",
"value_type": "INT"
},
{
"item": 6,
"name": "STATE",
"value_type": "STRING",
"default": "OPEN"
},
{
"item": 7,
"name": "SAT_TABLE",
"value_type": "INT",
"default": 0
},
{
"item": 8,
"name": "CONNECTION_TRANSMISSIBILITY_FACTOR",
"value_type": "DOUBLE",
"dimension": "Viscosity*ReservoirVolume/Time*Pressure"
},
{
"item": 9,
"name": "DIAMETER",
"value_type": "DOUBLE",
"dimension": "Length"
},
{
"item": 10,
"name": "Kh",
"value_type": "DOUBLE",
"dimension": "Permeability*Length",
"default": -1
},
{
"item": 11,
"name": "SKIN",
"value_type": "DOUBLE",
"dimension": "1",
"default": 0
},
{
"item": 12,
"name": "D_FACTOR",
"value_type": "DOUBLE",
"dimension": "1"
"dimension": "Time/GasSurfaceVolume",
"default": 0
},
{
"item": 13,
"name": "DIR",
"value_type": "STRING",
"default": "Z"
},
{
"item": 14,
"name": "PR",
"value_type": "DOUBLE",
"dimension": "Length"
Expand Down
8 changes: 5 additions & 3 deletions src/res2df/opmkeywords/EQLDIMS
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"name": "DEPTH_NODES_P",
"value_type": "INT",
"default": 100
"default": 2000
},
{
"name": "DEPTH_NODES_TAB",
Expand All @@ -23,12 +23,14 @@
{
"name": "NTTRVD",
"value_type": "INT",
"default": 1
"default": 1,
"comment": "Not supported"
},
{
"name": "NSTRVD",
"value_type": "INT",
"default": 20
"default": 20,
"comment": "Not supported"
}
]
}
31 changes: 29 additions & 2 deletions src/res2df/opmkeywords/EQUIL
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,86 @@
"keyword": "EQLDIMS",
"item": "NTEQUL"
},
"description": "The EQUIL item is used when equilibrationg the model. The item should consist of one record for each PVT region",
"description": "The EQUIL item is used when equilibrating the model. The item should consist of exactly one record for each EQUIL region",
"items": [
{
"item": 1,
"name": "DATUM_DEPTH",
"value_type": "DOUBLE",
"default": 0,
"dimension": "Length"
},
{
"item": 2,
"name": "DATUM_PRESSURE",
"value_type": "DOUBLE",
"dimension": "Pressure"
},
{
"item": 3,
"name": "OWC",
"value_type": "DOUBLE",
"default": 0,
"dimension": "Length",
"description": "The OWC item is depth of the OIL Water contact. This should ..."
},
{
"item": 4,
"name": "PC_OWC",
"value_type": "DOUBLE",
"default": 0,
"dimension": "Pressure"
},
{
"item": 5,
"name": "GOC",
"value_type": "DOUBLE",
"default": 0,
"dimension": "Length"
},
{
"item": 6,
"name": "PC_GOC",
"value_type": "DOUBLE",
"default": 0,
"dimension": "Pressure"
},
{
"item": 7,
"name": "BLACK_OIL_INIT",
"value_type": "INT",
"default": 0
},
{
"item": 8,
"name": "BLACK_OIL_INIT_WG",
"value_type": "INT",
"default": 0
},
{
"item": 9,
"name": "OIP_INIT",
"value_type": "INT",
"default": -5,
"comment": "The default is a state variable"
"comment": "Only values less than or equal to zero supported"
},
{
"item": 10,
"name": "EQLOPT04",
"value_type": "INT",
"comment": "This item is ECLIPSE300 specific"
},
{
"item": 11,
"name": "EQLOPT5",
"value_type": "INT",
"comment": "This item is ECLIPSE300 specific"
},
{
"item": 12,
"name": "BLACK_OIL_INIT_HG",
"value_type": "INT",
"default": 0
Comment on lines +73 to +89

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test failed due to more columns expected in the new version of opmkeywords

}
]
}
Loading