diff --git a/src/semeio/forward_models/__init__.py b/src/semeio/forward_models/__init__.py index 50e18f86..e9b5f38f 100644 --- a/src/semeio/forward_models/__init__.py +++ b/src/semeio/forward_models/__init__.py @@ -1,4 +1,10 @@ +from typing import Optional + from ert import ForwardModelStepJSON, ForwardModelStepPlugin +from ert.config.forward_model_step import ForwardModelStepDocumentation + +from .scripts.design2params import description as design2params_description +from .scripts.design_kw import description as design_kw_description class Design2Params(ForwardModelStepPlugin): @@ -22,6 +28,15 @@ def validate_pre_realization_run( def validate_pre_experiment(self, fm_step_json: ForwardModelStepJSON) -> None: return fm_step_json + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="utility.templating", + source_package="semeio", + source_function_name="Design2Params", + description=design2params_description, + ) + class DesignKW(ForwardModelStepPlugin): def __init__(self): @@ -38,6 +53,18 @@ def validate_pre_realization_run( def validate_pre_experiment(self, fm_step_json: ForwardModelStepJSON) -> None: pass + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="utility.templating", + source_package="semeio", + source_function_name="DesignKW", + description=design_kw_description, + ) + + +from .scripts.gendata_rft import description as gendata_rft_description + class GenDataRFT(ForwardModelStepPlugin): def __init__(self): @@ -65,6 +92,53 @@ def __init__(self): }, ) + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="utility.transformation", + source_package="semeio", + source_function_name="GenDataRFT", + examples=""" +Setup a file with well-names and associated date of RFT data in a file called +e.g. ``well_date_rft.txt``:: + + -- well YYYY-MM-DD report_step + A-1 2000-02-01 0 + +A directory with trajectory files must be prepared, which must contain one +file for each well mentioned in the file above. A file in this directory +could look like:: + + -- utmx utmy depth_MD depth_TVD zone + 462608.57 5934210.96 1674.44 1624.38 Upper -- cell 29 28 2 + +(add more lines for more points). + +A zonemap-file is a text-file with k-index and zone-name pr line, e.g a file +named ``layer_zone_table.txt``:: + + 1 Upper + 2 Upper + 3 Lower + 4 Lower + +In the ert config, after running the Eclipse (or similiar) forward model, add:: + + DEFINE RFT_INPUT /../input/observations/rft + FORWARD_MODEL MAKE_DIRECTORY(=gendata_rft) + FORWARD_MODEL GENDATA_RFT(=/rft/, =/well_date_rft.txt, =/layer_zone_table.txt, =gendata_rft) + +For assisted history matching, add ``GEN_DATA`` statements to the ert config:: + + GEN_DATA A-1 RESULT_FILE:gendata_rft/RFT_A-1_%d INPUT_FORMAT:ASCII REPORT_STEPS:0 + +""", + description=gendata_rft_description, + ) + + +from .scripts.overburden_timeshift import description as ots_description + class OTS(ForwardModelStepPlugin): def __init__(self): @@ -73,6 +147,18 @@ def __init__(self): command=["overburden_timeshift", "-c", ""], ) + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="modelling.surface", + source_package="semeio", + source_function_name="OTS", + description=ots_description, + ) + + +from .scripts.fm_pyscal import description as pyscal_description + class Pyscal(ForwardModelStepPlugin): def __init__(self): @@ -98,6 +184,24 @@ def __init__(self): }, ) + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="modelling.reservoir", + source_package="semeio", + source_function_name="Pyscal", + description=pyscal_description, + examples=""" +.. code-block:: none + + FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =alternativerecommendation) + FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =RELPERM_INTERP) + FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =RELPERM_INTERP_WO, =RELPERM_INTERP_GO) + FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =2) -- for Eclipse family 2 output + +""", + ) + class InsertNoSim(ForwardModelStepPlugin): def __init__(self): @@ -111,6 +215,17 @@ def __init__(self): ], ) + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="utility.file_system", + source_package="semeio", + source_function_name="InsertNoSim", + description=""" +Inserts a NOSIM for every RUNSPEC occurrence in the file +""", + ) + class RemoveNoSim(ForwardModelStepPlugin): def __init__(self): @@ -119,13 +234,37 @@ def __init__(self): command=["sed", "-i", "/^NOSIM/d", ".DATA"], ) + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="utility.file_system", + source_package="semeio", + source_function_name="RemoveNoSim", + description="Remove all NOSIM lines from .DATA file", + ) + -class ReplaceStringConfig(ForwardModelStepPlugin): +from .scripts.replace_string import description as replace_string_description + + +class ReplaceString(ForwardModelStepPlugin): def __init__(self): super().__init__( name="REPLACE_STRING", command=["replace_string", "-o", "", "-n", "", "-f", ""], ) + @staticmethod + def documentation() -> Optional[ForwardModelStepDocumentation]: + return ForwardModelStepDocumentation( + category="utility.file_system", + source_package="semeio", + source_function_name="ReplaceString", + description=replace_string_description, + examples=""" + | REPLACE_STRING(=hello,=world,=some_file.txt + """, + ) + __all__ = ["Design2Params"] diff --git a/src/semeio/forward_models/scripts/design2params.py b/src/semeio/forward_models/scripts/design2params.py index 7181bea9..826ea67d 100755 --- a/src/semeio/forward_models/scripts/design2params.py +++ b/src/semeio/forward_models/scripts/design2params.py @@ -21,8 +21,6 @@ before you run DESIGN_KW. """ -category = "utility.templating" - def create_parser(): parser = argparse.ArgumentParser(description=description) diff --git a/src/semeio/forward_models/scripts/design_kw.py b/src/semeio/forward_models/scripts/design_kw.py index e2331fa3..84669e31 100755 --- a/src/semeio/forward_models/scripts/design_kw.py +++ b/src/semeio/forward_models/scripts/design_kw.py @@ -22,8 +22,6 @@ ``0.001``. """ -category = "utility.templating" - def create_parser(): parser = argparse.ArgumentParser(description=description) diff --git a/src/semeio/forward_models/scripts/fm_pyscal.py b/src/semeio/forward_models/scripts/fm_pyscal.py index e2d3c1fb..f68e74e0 100755 --- a/src/semeio/forward_models/scripts/fm_pyscal.py +++ b/src/semeio/forward_models/scripts/fm_pyscal.py @@ -78,20 +78,6 @@ def main_entry_point(): Run ``pyscal --help`` for syntax. """ -examples = """ - -.. code-block:: none - - FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =alternativerecommendation) - FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =RELPERM_INTERP) - FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =RELPERM_INTERP_WO, =RELPERM_INTERP_GO) - FORWARD_MODEL PYSCAL(=scalinput.xlsx, =eclipse/include/props/relperm.inc, =2) -- for Eclipse family 2 output - -""" # noqa - - -category = "modelling.reservoir" - def _get_args_parser(): """Construct an argparse parser for fm_pyscal""" diff --git a/src/semeio/forward_models/scripts/gendata_rft.py b/src/semeio/forward_models/scripts/gendata_rft.py index 1dc2b3be..b2695605 100755 --- a/src/semeio/forward_models/scripts/gendata_rft.py +++ b/src/semeio/forward_models/scripts/gendata_rft.py @@ -46,43 +46,6 @@ https://equinor.github.io/fmu-tools/create_rft_ertobs.html """ -examples = """ -Setup a file with well-names and associated date of RFT data in a file called -e.g. ``well_date_rft.txt``:: - - -- well YYYY-MM-DD report_step - A-1 2000-02-01 0 - -A directory with trajectory files must be prepared, which must contain one -file for each well mentioned in the file above. A file in this directory -could look like:: - - -- utmx utmy depth_MD depth_TVD zone - 462608.57 5934210.96 1674.44 1624.38 Upper -- cell 29 28 2 - -(add more lines for more points). - -A zonemap-file is a text-file with k-index and zone-name pr line, e.g a file -named ``layer_zone_table.txt``:: - - 1 Upper - 2 Upper - 3 Lower - 4 Lower - -In the ert config, after running the Eclipse (or similiar) forward model, add:: - - DEFINE RFT_INPUT /../input/observations/rft - FORWARD_MODEL MAKE_DIRECTORY(=gendata_rft) - FORWARD_MODEL GENDATA_RFT(=/rft/, =/well_date_rft.txt, =/layer_zone_table.txt, =gendata_rft) - -For assisted history matching, add ``GEN_DATA`` statements to the ert config:: - - GEN_DATA A-1 RESULT_FILE:gendata_rft/RFT_A-1_%d INPUT_FORMAT:ASCII REPORT_STEPS:0 - -""" # noqa -category = "utility.transformation" - def _build_parser(): parser = argparse.ArgumentParser(description=description) diff --git a/src/semeio/forward_models/scripts/overburden_timeshift.py b/src/semeio/forward_models/scripts/overburden_timeshift.py index b5b5f84a..f91be2a7 100755 --- a/src/semeio/forward_models/scripts/overburden_timeshift.py +++ b/src/semeio/forward_models/scripts/overburden_timeshift.py @@ -26,7 +26,6 @@ + 2 * "\n" + _create_docs(OTSConfig.model_json_schema(by_alias=False, ref_template="{model}")) ) -category = "modelling.surface" def _get_args_parser(): diff --git a/src/semeio/forward_models/scripts/replace_string.py b/src/semeio/forward_models/scripts/replace_string.py index b05681f6..f19736eb 100644 --- a/src/semeio/forward_models/scripts/replace_string.py +++ b/src/semeio/forward_models/scripts/replace_string.py @@ -19,8 +19,6 @@ """ -category = "utility.templating" - def _get_args_parser(): parser = argparse.ArgumentParser(description=description) diff --git a/src/semeio/hook_implementations/forward_models.py b/src/semeio/hook_implementations/forward_models.py index ff051574..2df1b7b1 100644 --- a/src/semeio/hook_implementations/forward_models.py +++ b/src/semeio/hook_implementations/forward_models.py @@ -13,7 +13,7 @@ InsertNoSim, Pyscal, RemoveNoSim, - ReplaceStringConfig, + ReplaceString, ) @@ -120,5 +120,5 @@ def installable_forward_model_steps(): Pyscal, InsertNoSim, RemoveNoSim, - ReplaceStringConfig, + ReplaceString, ] diff --git a/tests/hook_implementations/test_hook_implementations.py b/tests/hook_implementations/test_hook_implementations.py index 04c28989..fc58f502 100644 --- a/tests/hook_implementations/test_hook_implementations.py +++ b/tests/hook_implementations/test_hook_implementations.py @@ -11,7 +11,7 @@ InsertNoSim, Pyscal, RemoveNoSim, - ReplaceStringConfig, + ReplaceString, ) from semeio.workflows.ahm_analysis import ahmanalysis from semeio.workflows.csv_export2 import csv_export2 @@ -29,7 +29,7 @@ def test_that_installable_fm_steps_work_as_plugins(): assert OTS in fms assert InsertNoSim in fms assert RemoveNoSim in fms - assert ReplaceStringConfig in fms + assert ReplaceString in fms def test_hook_implementations():