Skip to content
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

Refactor and check conformity #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
17 changes: 7 additions & 10 deletions aps/algorithms/APSModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import copy
import xml.etree.ElementTree as ET
from typing import List, Optional, Tuple, Union, Dict, TYPE_CHECKING
from warnings import warn

from aps.algorithms.APSMainFaciesTable import APSMainFaciesTable
from aps.algorithms.APSZoneModel import APSZoneModel
Expand Down Expand Up @@ -690,7 +689,7 @@ def update_model_file(
without putting any data into the data structure.
"""
if (not use_rms_uncertainty_table) and (not parameter_file_name):
raise IOError(f'Expect that a global variable file exists')
raise IOError('Expect that a global variable file exists')
# Read XML model file
tree = ET.parse(model_file_name)
root = tree.getroot()
Expand Down Expand Up @@ -728,7 +727,7 @@ def update_model_file(

if current_job_name is None:
print(
f'NOTE: The APS parameters are not updated when running interactively'
'NOTE: The APS parameters are not updated when running interactively'
)
else:
if len(keywords_defined_for_updating) > 0:
Expand Down Expand Up @@ -783,7 +782,7 @@ def update_model_file(
)

# Set new values if keyword in global_variables file and in fmu tag in model file match
if (len(keywords_defined_for_updating) > 0) and (keywords_read != None):
if (len(keywords_defined_for_updating) > 0) and (keywords_read is not None):
# Update the list of keywords in the model file with new values from FMU global_variables
found_an_update = False
for item in keywords_defined_for_updating:
Expand All @@ -800,7 +799,7 @@ def update_model_file(
print(f'The APS parameters are updated for the job: {current_job_name}')
if debug_level >= Debug.VERBOSE:
print(
f' Parameter name Original value New value'
' Parameter name Original value New value'
)
else:
# Should never occur
Expand Down Expand Up @@ -892,7 +891,7 @@ def __parse_global_variables(
keywords.append(item)
return keywords

except:
except KeyError:
# No parameter specified to be updated for the current APS job
return None

Expand Down Expand Up @@ -1594,7 +1593,7 @@ def check_active_cells(self, project, debug_level=Debug.OFF):
# Check if there are (zone_number, region_numbers) in the grid model without any specified APS model.
if debug_level >= Debug.VERBOSE:
print(
f'-- Check if there are zones with regions without any specified APS model.'
'-- Check if there are zones with regions without any specified APS model.'
)
list_of_undefined_zone_regions = []
for zone_number in zone_param.code_names.keys():
Expand Down Expand Up @@ -1643,7 +1642,6 @@ def check_and_update_simbox_thickness(self, project, debug_level=Debug.OFF):
grid3D = grid_model.get_grid(realisation_number)
try:
# Check for RMS14.1 and newer
simbox = grid3D.simbox
# Is RMS14.1 or newer
simbox_thickness_per_zone = get_simulation_box_thickness(grid3D)
for key, zone_model in self.__zoneModelTable.items():
Expand All @@ -1654,7 +1652,7 @@ def check_and_update_simbox_thickness(self, project, debug_level=Debug.OFF):
f'--- Zone: {zone_number} Simbox thickness: {zone_model.sim_box_thickness}'
)
self.__zoneModelTable[key] = zone_model
except:
except KeyError:
# Nothing done for older versions of RMS
pass

Expand Down Expand Up @@ -1926,7 +1924,6 @@ def print_job_settings(self):
print(
f' Trend param extrapolation: {self.__fmu_trend_param_extrapolation}'
)

if self.__fmu_mode != 'OFF':
print(
f' Update only residual GRF in ERT: {self.__fmu_use_residual_fields}'
Expand Down
20 changes: 9 additions & 11 deletions aps/rms_jobs/copy_rms_param_to_fmu_grid.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/env python
# -*- coding: utf-8 -*-

"""This module is used in FMU workflows to copy a continuous 3D parameter
from geomodel grid to ERTBOX grid and extrapolate values that are undefined
in ERTBOX grid. This functionality is used when the user wants to
use FIELD keywords for petrophysical properties in ERT in Assisted History Matching.
"""

from aps.toolbox.copy_rms_param_to_ertbox_grid import (
run as run_copy_rms_param_to_ertbox,
)
from aps.utils.constants.simple import Debug, ModelFileFormat
# TODO: When the stubs are removed from the APS repository (deprecated), then this function here can be removed
# It will be replaced by fmu.tools.rms function copy_rms_param

from aps.toolbox import copy_rms_param_to_ertbox_grid
from aps.utils.constants.simple import ModelFileFormat
from aps.utils.methods import get_specification_file, SpecificationType


Expand All @@ -23,19 +25,15 @@ def run(project, **kwargs):
"""
if project.current_realisation > 0:
raise ValueError(
f'In RMS models to be used with a FMU loop in ERT,'
'In RMS models to be used with a FMU loop in ERT,'
'the grid and parameters should be shared and realisation = 1'
)
params = {
'project': project,
'model_file_name': get_specification_file(
_type=SpecificationType.RESAMPLE, _format=ModelFileFormat.YML, **kwargs
),
'debug_level': Debug.VERBOSE,
'debug_level': 2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably still use the Enum so that it is clearer what the intension is

}

run_copy_rms_param_to_ertbox(params, seed=project.seed)


if __name__ == '__main__':
run(project)
copy_rms_param_to_ertbox_grid.run(params)
Loading
Loading