pycopm.utils.input_values module#
Create configuration objects from command-line arguments and TOML files.
- create_deck_config(cmdargs)[source]#
Create a deck configuration from parsed command arguments.
- Parameters:
- cmdargsargparse.Namespace
Command-line arguments for the deck-based workflow.
- Returns:
- ConfigViaDeck
Configuration populated from the command-line values.
- Parameters:
cmdargs (Namespace)
- Return type:
ConfigViaDeck
- parse_axis_modifications(uniform, localized)[source]#
Parse uniform or axis-specific grid modifications.
Uniform input contains one value for each axis. Axis-specific coarsening also accepts one-based indices and inclusive ranges such as
2:4,7.- Parameters:
- uniformstr
Comma-separated x, y, and z modification values.
- localizedlist
Axis-specific specifications in x, y, and z order.
- Returns:
- cijk, axis_values
Uniform axis values and the three parsed axis-specific arrays. Only one representation is populated.
- Parameters:
uniform (str)
localized (list)
- Return type:
tuple[NDArray, list]
- _is_finite_number(value)[source]#
Check whether a value is a finite non-Boolean number.
- Parameters:
- valueAny
Value to inspect.
- Returns:
- bool
Whether the value is a finite integer or floating-point number.
- Parameters:
value (Any)
- Return type:
TypeGuard[int | float]
- _is_integer(value)[source]#
Check whether a value is a non-Boolean integer.
- Parameters:
- valueAny
Value to inspect.
- Returns:
- bool
Whether the value is an integer and not a Boolean.
- Parameters:
value (Any)
- Return type:
TypeGuard[int]
- _add_validation_error(errors, message)[source]#
Add a TOML validation error.
- Parameters:
- errorslist[str]
Validation messages collected during the current validation pass.
- messagestr
Human-readable validation message.
- Parameters:
errors (list[str])
message (str)
- Return type:
None
- _warn(message)[source]#
Display a TOML validation warning.
- Parameters:
- messagestr
Human-readable warning passed to the shared terminal helper.
- Parameters:
message (str)
- Return type:
None
- _validate_string(cfg_file, key, errors)[source]#
Check that a TOML variable is a non-empty string.
- Parameters:
- cfg_filedict[str, Any]
TOML configuration values.
- keystr
Configuration variable name.
- errorslist[str]
Validation messages collected during the current validation pass.
- Returns:
- bool
Whether the variable is present and contains a non-empty string.
- Parameters:
cfg_file (dict[str, Any])
key (str)
errors (list[str])
- Return type:
bool
- _validate_integer(cfg_file, key, errors, minimum=0)[source]#
Check that a TOML variable is an integer within its lower bound.
- Parameters:
- cfg_filedict[str, Any]
TOML configuration values.
- keystr
Configuration variable name.
- errorslist[str]
Validation messages collected during the current validation pass.
- minimumint, optional
Inclusive lower bound for accepted values.
- Returns:
- bool
Whether the variable is present and satisfies the integer constraint.
- Parameters:
cfg_file (dict[str, Any])
key (str)
errors (list[str])
minimum (int)
- Return type:
bool
- _validate_number_array(cfg_file, key, errors, *, length=None, minimum=None, maximum=None)[source]#
Check the shape and values of a numeric TOML array.
- Parameters:
- cfg_filedict[str, Any]
TOML configuration values.
- keystr
Configuration variable name.
- errorslist[str]
Validation messages collected during the current validation pass.
- lengthint | None, optional
Required number of entries.
- minimumfloat | None, optional
Inclusive lower bound for every entry.
- maximumfloat | None, optional
Inclusive upper bound for every entry.
- Returns:
- bool
Whether the variable is present and satisfies all array constraints.
- Parameters:
cfg_file (dict[str, Any])
key (str)
errors (list[str])
length (int | None)
minimum (float | None)
maximum (float | None)
- Return type:
bool
- _validate_coarsening(cfg_file, key, expected_length, errors)[source]#
Validate one model-specific axis coarsening array.
The array must contain non-negative integers, match the number of grid boundaries for the selected model, and retain both outer boundaries.
- Parameters:
- cfg_filedict[str, Any]
TOML configuration values.
- keystr
Name of the x, y, or z coarsening variable.
- expected_lengthint
Required number of entries for the selected reference model.
- errorslist[str]
Validation messages collected during the current validation pass.
- Parameters:
cfg_file (dict[str, Any])
key (str)
expected_length (int)
errors (list[str])
- Return type:
None
- _validate_let_parameters(cfg_file, model, errors)[source]#
Validate the ordered LET-parameter definitions.
Each row contains a coefficient name, initial value, estimation flag, distribution name, lower bound, and upper bound. The order is checked because downstream table generation addresses coefficients by position.
- Parameters:
- cfg_filedict[str, Any]
TOML configuration values.
- modelstr | None
Normalized reference-model name, when valid.
- errorslist[str]
Validation messages collected during the current validation pass.
- Parameters:
cfg_file (dict[str, Any])
model (str | None)
errors (list[str])
- Return type:
None
- _validate_rock_properties(cfg_file, errors)[source]#
Validate rock-property history matching settings.
Each row contains a permeability name, estimation flag, and aggregation method. Property names are normalized to uppercase after validation.
- Parameters:
- cfg_filedict[str, Any]
TOML configuration values.
- errorslist[str]
Validation messages collected during the current validation pass.
- Parameters:
cfg_file (dict[str, Any])
errors (list[str])
- Return type:
None
- _validate_toml(cfg_file)[source]#
Validate and normalize TOML configuration values.
Unknown and internally managed variables are reported and removed. Remaining errors are collected so the user receives one complete validation report.
- Parameters:
- cfg_filedict[str, Any]
Raw values loaded from the TOML configuration.
- Returns:
- dict[str, Any]
Validated and normalized values suitable for
ConfigViaTOML.
- Raises:
- SystemExit
If one or more configuration values are invalid.
- Parameters:
cfg_file (dict[str, Any])
- Return type:
dict[str, Any]
- load_toml_config(input_file, output_directory, resource_directory, significant_digits)[source]#
Load, validate, and initialize a TOML configuration.
Validation and normalization occur before the reference EGRID is opened and before
ConfigViaTOMLis constructed.- Parameters:
- input_filestr
TOML configuration path.
- output_directorystr
Generated-project directory.
- resource_directorystr
Directory containing templates and reference simulations.
- significant_digitsint
Precision used when writing floating-point values.
- Returns:
- ConfigViaTOML
Validated configuration populated with reference-grid metadata.
- Raises:
- SystemExit
If the TOML configuration is invalid.
- Parameters:
input_file (str)
output_directory (str)
resource_directory (str)
significant_digits (int)
- Return type:
ConfigViaTOML