ResSimpy.Nexus.structured_grid_operations.StructuredGridOperations
- class ResSimpy.Nexus.structured_grid_operations.StructuredGridOperations(model: NexusSimulator)[source]
Bases:
objectMethods:
__init__(model)load_token_value_if_present(token, modifier, ...)Gets a token's value if there is one and loads it into the token_property.
replace_value(file_as_list, old_property, ...)Replace the value and token + modifier with the new values.
Appends an include file to the end of a grid for adding LGRs.
get_grid_file_as_3d_list(path)Converts a grid file to a 3D list.
view_command(field[, previous_lines, ...])Displays how the property is declared in the structured grid file.
- __init__(model: NexusSimulator) None[source]
- static load_token_value_if_present(token: str, modifier: str, token_property: VariableEntry, line: str, file_as_list: list[str], ignore_values: list[str] | None = None) None[source]
Gets a token’s value if there is one and loads it into the token_property.
Args:
token (str): the token being searched for. e.g. ‘PERMX’ modifier (str): any modifiers applied to the token e.g. ‘MULT’ token_property (VariableEntry): VariableEntry object to store the modifier and value pair into line (str): line to search for the token in ignore_values (Optional[list[str]], optional): values to be ignored. Defaults to None.
Raises:
ValueError: raises an error if no numerical value can be found after the supplied token modifier pair
- returns:
None – stores the value into token_property supplied instead
- static replace_value(file_as_list: list[str], old_property: VariableEntry, new_property: VariableEntry, token_name: str) None[source]
Replace the value and token + modifier with the new values.
Args:
file_as_list (list[str]): a list of strings containing each line of the file as a new entry old_property (VariableEntry): property found in the original file to be replaced new_property (VariableEntry): new property to replace the old property with token_name (str): name of the token being replaced
- returns:
None – modifies the file_as_list with the new property
- static append_include_to_grid_file(include_file_location: str, structured_grid_file_path: str) None[source]
Appends an include file to the end of a grid for adding LGRs.
Args:
include_file_location (str): path to a file to include in the grid structured_grid_file_path (str): file path to the structured grid.
Raises:
ValueError: if no structured grid file path is specified in the class instance
- static get_grid_file_as_3d_list(path: str) list | None[source]
Converts a grid file to a 3D list.
Args:
path (str): path to a grid file
Returns:
Optional[list[str]]: Returns None if no file is found, returns the grid as a 3d array otherwise
- view_command(field: str, previous_lines: int = 3, following_lines: int = 3) str | None[source]
Displays how the property is declared in the structured grid file.
Args:
field (str): property as written in the structured grid (e.g. KX) previous_lines (int, optional): how many lines to look back from the field searched for. Defaults to 3. following_lines (int, optional): how many lines to look forward from the field searched for. Defaults to 3.
Raises:
ValueError: if no structured grid file path is specified in the class instance
Returns:
Optional[str]: the string associated with the supplied property from within the structured grid. If the field is not found in the structured grid returns None.