-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add calculation of water zone volumes #925
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,43 @@ def _convert_table_from_rms_to_legacy_format(table: pd.DataFrame) -> pd.DataFram | |
columns="REAL", errors="ignore" | ||
) | ||
|
||
@staticmethod | ||
def _compute_water_zone_volumes_from_totals(table: pd.DataFrame) -> pd.DataFrame: | ||
""" | ||
Calculate 'water' zone volumes by subtracting HC-zone volumes from 'Total' | ||
volumes which represents the entire zone. Total volumes are removed after | ||
'water' zone volumes have been added to the table. | ||
""" | ||
_logger.debug("Computing water volumes from Totals...") | ||
|
||
total_suffix = "_TOTAL" | ||
total_columns = [col for col in table.columns if col.endswith(total_suffix)] | ||
|
||
if not total_columns: | ||
raise RuntimeError( | ||
"Found no 'Totals' volumes in the table. Please ensure 'Totals' " | ||
"are reported and rerun the volumetric job before export." | ||
) | ||
|
||
for total_col in total_columns: | ||
volumetric_col = total_col.replace(total_suffix, "") | ||
|
||
water_zone_col = f"{volumetric_col}_WATER" | ||
oil_zone_col = f"{volumetric_col}_OIL" | ||
gas_zone_col = f"{volumetric_col}_GAS" | ||
|
||
# first set water zone data equal to the Total | ||
# then subtract data from the oil/gas zone | ||
table[water_zone_col] = table[total_col] | ||
|
||
if oil_zone_col in table: | ||
table[water_zone_col] -= table[oil_zone_col] | ||
|
||
if gas_zone_col in table: | ||
table[water_zone_col] -= table[gas_zone_col] | ||
|
||
return table.drop(columns=total_columns) | ||
|
||
@staticmethod | ||
def _add_missing_columns_to_table(table: pd.DataFrame) -> pd.DataFrame: | ||
"""Add columns with nan values if not present in table.""" | ||
|
@@ -149,14 +186,12 @@ def _transform_and_add_fluid_column_to_table( | |
are renamed into 'BULK' and 'PORV' columns. To separate the data an additional | ||
FLUID column is added that indicates the type of fluid the row represents. | ||
""" | ||
table_index = [ | ||
col for col in _enums.InplaceVolumes.index_columns() if col in table | ||
] | ||
Comment on lines
-152
to
-154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was also given as input argument |
||
|
||
tables = [] | ||
for fluid in ( | ||
_enums.InplaceVolumes.Fluid.gas.value, | ||
_enums.InplaceVolumes.Fluid.oil.value, | ||
_enums.InplaceVolumes.Fluid.water.value, | ||
): | ||
fluid_suffix = fluid.upper() | ||
fluid_columns = [ | ||
|
@@ -188,6 +223,7 @@ def _convert_table_from_legacy_to_standard_format( | |
table_index = [ | ||
col for col in _enums.InplaceVolumes.index_columns() if col in table | ||
] | ||
table = self._compute_water_zone_volumes_from_totals(table) | ||
table = self._transform_and_add_fluid_column_to_table(table, table_index) | ||
table = self._add_missing_columns_to_table(table) | ||
return self._set_table_column_order(table) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be captured more upfront by evaluation the job settings which already are read
(this example from Drogon)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I know, did initially check several things on the job settings e.g. required calculations.. but found it difficult to write tests, had to mock so much. I'll keep it here for now and we can move later if we want 👍