ResSimpy.Nexus.DataModels.FcsFile.FcsNexusFile

class ResSimpy.Nexus.DataModels.FcsFile.FcsNexusFile(location: 'Optional[str]' = None, include_locations: 'Optional[list[str]]' = None, origin: 'Optional[str]' = None, include_objects: 'Optional[list[NexusFile]]' = None, file_content_as_list: 'Optional[list[str]]' = None, restart_file: 'Optional[NexusFile]' = None, structured_grid_file: 'Optional[NexusFile]' = None, options_file: 'Optional[NexusFile]' = None, runcontrol_file: 'Optional[NexusFile]' = None, override_file: 'Optional[NexusFile]' = None, eos_default_file: 'Optional[NexusFile]' = None, well_files: 'Optional[dict[int, NexusFile]]' = None, surface_files: 'Optional[dict[int, NexusFile]]' = None, rock_files: 'Optional[dict[int, NexusFile]]' = None, relperm_files: 'Optional[dict[int, NexusFile]]' = None, pvt_files: 'Optional[dict[int, NexusFile]]' = None, water_files: 'Optional[dict[int, NexusFile]]' = None, equil_files: 'Optional[dict[int, NexusFile]]' = None, tracer_init_files: 'Optional[dict[int, NexusFile]]' = None, aquifer_files: 'Optional[dict[int, NexusFile]]' = None, hyd_files: 'Optional[dict[int, NexusFile]]' = None, valve_files: 'Optional[dict[int, NexusFile]]' = None, separator_files: 'Optional[dict[int, NexusFile]]' = None, ipr_files: 'Optional[dict[int, NexusFile]]' = None, gas_lift_files: 'Optional[dict[int, NexusFile]]' = None, pump_files: 'Optional[dict[int, NexusFile]]' = None, compressor_files: 'Optional[dict[int, NexusFile]]' = None, choke_files: 'Optional[dict[int, NexusFile]]' = None, icd_files: 'Optional[dict[int, NexusFile]]' = None, esp_files: 'Optional[dict[int, NexusFile]]' = None, polymer_files: 'Optional[dict[int, NexusFile]]' = None, adsorption_files: 'Optional[dict[int, NexusFile]]' = None, flux_in_files: 'Optional[dict[int, NexusFile]]' = None)[source]

Bases: NexusFile

Public Data Attributes:

restart_file

structured_grid_file

options_file

runcontrol_file

override_file

eos_default_file

well_files

surface_files

rock_files

relperm_files

pvt_files

water_files

equil_files

tracer_init_files

aquifer_files

hyd_files

valve_files

separator_files

ipr_files

gas_lift_files

pump_files

compressor_files

choke_files

icd_files

esp_files

polymer_files

adsorption_files

flux_in_files

files_info

Inherited from NexusFile

include_locations

origin

include_objects

object_locations

line_locations

linked_user

last_modified

get_flat_list_str_file

get_flat_list_str_file_including_includes

Inherited from File

location

file_content_as_list

id

Unique identifier for each Node object.

file_modified

get_flat_list_str_file

Inherited from FileBase

location

file_content_as_list

get_flat_list_str_file

Methods:

__init__([location, include_locations, ...])

__repr__()

Return repr(self).

generate_fcs_structure(fcs_file_path[, ...])

Creates an instance of the FcsNexusFile, populates it through looking through the different keywords in the FCS and assigning the paths to objects.

fcs_keyword_map_single()

fcs_keyword_map_multi()

get_keyword_mapping()

update_fcs_file([new_file_path, ...])

Updates or creates a new fcs_file with all the updated include files.

write_out_included_file(file, attr_name, ...)

Writes out the included file and prepares to switch out the path in the fcs file.

change_file_path(new_file_path, token[, ...])

Switch the file path for a new file_path based on the value of the associated keyword in the fcs.

__eq__(other)

Return self==value.

Inherited from NexusFile

__init__([location, include_locations, ...])

generate_file_include_structure(file_path[, ...])

Generates a nexus file instance for a provided text file with information storing the included files.

export_network_lists()

Exports lists of connections from and to for use in network graphs.

iterate_line([file_index, max_depth, ...])

Generator object for iterating over a list of strings with nested NexusFile objects in them.

get_full_network([max_depth])

Recursively constructs two lists of from and to nodes representing the connections between files.

add_object_locations(obj_uuid, line_indices)

Adds a uuid to the object_locations dictionary.

find_which_include_file(flattened_index)

Given a line index that relates to a position within the flattened file_as_list from the method get_flat_file_as_list.

add_to_file_as_list(additional_content, index)

To add content to the file as list, also updates object numbers and optionally allows user to add several additional new objects.

remove_object_from_file_as_list(...)

Removes all associated lines in the file as well as the object locations relating to a list of objects.

remove_from_file_as_list(index[, ...])

Remove an entry from the file as list.

insert_comments(additional_content, comments)

Adds comments alongside additional content.

get_object_locations_for_id(id)

Gets the number of object locations for a specified id.

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

Inherited from File

__init__([location, file_content_as_list])

write_to_file([new_file_path])

Writes to file specified in self.location the strings contained in the list self.file_content_as_list.

add_object_locations(obj_uuid, line_indices)

insert_comments(additional_content, comments)

get_object_locations_for_id(obj_id)

remove_object_from_file_as_list(...)

add_to_file_as_list(additional_content, index)

remove_from_file_as_list(index[, ...])

find_which_include_file(flattened_index)

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

Inherited from FileBase

write_to_file()

add_object_locations(obj_uuid, line_indices)

insert_comments(additional_content, comments)

get_object_locations_for_id(obj_id)

remove_object_from_file_as_list(...)

add_to_file_as_list(additional_content, index)

remove_from_file_as_list(index[, ...])

__init__([location, file_content_as_list, ...])

__repr__()

Return repr(self).

__eq__(other)

Return self==value.


__init__(location: str | None = None, include_locations: list[str] | None = None, origin: str | None = None, include_objects: list[ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, file_content_as_list: list[str] | None = None, restart_file: NexusFile | None = None, structured_grid_file: NexusFile | None = None, options_file: NexusFile | None = None, runcontrol_file: NexusFile | None = None, override_file: NexusFile | None = None, eos_default_file: NexusFile | None = None, well_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, surface_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, rock_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, relperm_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, pvt_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, water_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, equil_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, tracer_init_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, aquifer_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, hyd_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, valve_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, separator_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, ipr_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, gas_lift_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, pump_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, compressor_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, choke_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, icd_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, esp_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, polymer_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, adsorption_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None, flux_in_files: dict[int, ResSimpy.Nexus.DataModels.NexusFile.NexusFile] | None = None) None[source]
class FileIndex(index: 'int')

Bases: object

__init__(index: int) None
add_object_locations(obj_uuid: UUID, line_indices: list[int]) None

Adds a uuid to the object_locations dictionary. Used for storing the line numbers where objects are stored within the flattened file_as_list.

Parameters:
  • obj_uuid (UUID) – unique identifier of the object being created/stored.

  • line_indices (list[int]) – line number in the flattened file_content_as_list (i.e. from the get_flat_list_str_file method).

add_to_file_as_list(additional_content: list[str], index: int, additional_objects: dict[uuid.UUID, list[int]] | None = None, comments: str | None = None) None

To add content to the file as list, also updates object numbers and optionally allows user to add several additional new objects.

Parameters:
  • additional_content (list[str]) – Additional lines as a list of strings to be added.

  • index (int) – index to insert the new lines at in the calling flat_file_as_list

  • additional_objects (Optional[dict[UUID, int]]) – defaults to None. Otherwise, a dictionary keyed with the UUID of the new objects to add as well as the corresponding index of the object in the original calling NexusFile

  • comments (str | None) – defaults to None. Comments to add in-line to the file.

export_network_lists()

Exports lists of connections from and to for use in network graphs.

Raises:

ValueError – If the from and to lists are not the same length

Returns:

tuple[list] – list of to and from file paths where the equivalent indexes relate to a connection

find_which_include_file(flattened_index: int) tuple[ResSimpy.File.File, int]

Given a line index that relates to a position within the flattened file_as_list from the method get_flat_file_as_list.

Parameters:

flattened_index (int) – index in the flattened file as list structure

Returns:

tuple[File, int] where the first element is the file that the relevant line is in and the second element is the relative index in that file.

classmethod generate_file_include_structure(file_path: str, origin: str | None = None, recursive: bool = True, skip_arrays: bool = True, top_level_file: bool = True) Self

Generates a nexus file instance for a provided text file with information storing the included files.

Parameters:
  • file_path (str) – path to a file

  • origin (Optional[str], optional) – Where the file was opened from. Defaults to None.

  • recursive (bool) – Whether the method should recursively drill down multiple layers of include_locations.

  • skip_arrays (bool) – If set True skips the INCLUDE arrays that come after property array and VALUE

  • top_level_file (bool) – If set to True, the code assumes this is a ‘top level’ file rather than an included

  • one.

Returns:

NexusFile – a class instance for NexusFile with knowledge of include files

get_full_network(max_depth: int | None = None) tuple[list[str | None], list[str | None]]

Recursively constructs two lists of from and to nodes representing the connections between files.

Parameters:

max_depth (Optional[int], optional) – depth of the iteration to construct the network down to. Defaults to None.

Returns:

tuple[list[str | None], list[str | None]] – two lists of from and to nodes where corresponding indices create an edge within a graph network. e.g. (from_list[i], to_list[i]) is a connection between two files.

get_object_locations_for_id(id: UUID) list[int]

Gets the number of object locations for a specified id.

property id: UUID

Unique identifier for each Node object.

static insert_comments(additional_content: list[str], comments: str) list[str]

Adds comments alongside additional content.

Parameters:
  • additional_content (list[str]) – additional lines of the file to be added with a new entry per line.

  • comments (str) – comments to be added to all lines

Returns:

list of strings within the content.

iterate_line(file_index: FileIndex | None = None, max_depth: int | None = None, parent: NexusFile | None = None, prefix_line: str | None = None, keep_include_references=False) Generator[str, None, None]

Generator object for iterating over a list of strings with nested NexusFile objects in them.

Yields:

str – sequential line from the file.

remove_from_file_as_list(index: int, objects_to_remove: list[uuid.UUID] | None = None, string_to_remove: str | None = None) None

Remove an entry from the file as list. Also updates existing object locations and removes any specified objects from the object locations dictionary.

Parameters:
  • index (int) – index n the calling flat_file_as_list to remove the entry from

  • objects_to_remove (Optional[list[UUID]]) – list of object id’s to remove from the object locations. Defaults to None

  • string_to_remove (Optional[str]) – if specified will only remove the listed string from the entry at the index. Defaults to None, which removes the entire entry.

remove_object_from_file_as_list(objects_to_remove: list[uuid.UUID]) None

Removes all associated lines in the file as well as the object locations relating to a list of objects.

write_to_file(new_file_path: str | None = None) None

Writes to file specified in self.location the strings contained in the list self.file_content_as_list.

classmethod generate_fcs_structure(fcs_file_path: str, recursive: bool = True) Self[source]

Creates an instance of the FcsNexusFile, populates it through looking through the different keywords in the FCS and assigning the paths to objects.

Args:

fcs_file_path (str): path to the fcs file of interest recursive (bool, optional): Whether the NexusFile structure will be recursively created. Defaults to True.

Raises:

FileNotFoundError: if the fcs file cannot be found ValueError: if no content can be found within the fcsfile

Returns:

FcsNexusFile: instance of a FcsNexusFile for a given fcs file path

update_fcs_file(new_file_path: str | None = None, new_include_file_location: str | None = None, write_out_all_files: bool = False, preserve_file_names: bool = False) None[source]

Updates or creates a new fcs_file with all the updated include files.

Parameters:
  • new_file_path (None | str) – Defaults to None. If None overwrites the original file.

  • provided. (If string it will save the file in the path) –

  • new_include_file_location (None | str) – Defaults to None. If None saves in the same directory as the fcs file. Otherwise saves it to a path either absolute or relative to the file path provided.

  • write_out_all_files (bool) – Defaults to False. If False writes out only changed files.

  • files. (If False writes out all) –

  • preserve_file_names (bool) – Defaults to False. If True will derive names from the existing fcs_file.

  • Nexus. (If False will derive new names from the new fcs file name and the property it represents in) –

write_out_included_file(file: NexusFile, attr_name: str, file_directory: str, keyword: str, new_fcs_name: str, method_number: int | None = None, write_out_all_files: bool = False, preserve_file_names: bool = False) None[source]

Writes out the included file and prepares to switch out the path in the fcs file.

Parameters:
  • file (NexusFile) – file to write out

  • attr_name (str) – attribute name of the method to be replaced

  • file_directory (str) – path to directory the file should be stored in

  • keyword (str) – Nexus keyword for the type of method.

  • new_fcs_name (str) – new file name for the fcs

  • method_number (None | int) – method number to include in the file name (defaults to None)

  • preserve_file_names (bool) – Defaults to False. If True will derive names from the existing fcs_file.

  • Nexus. (If False will derive new names from the new fcs file name and the property it represents in) –

change_file_path(new_file_path: str, token: str, method_number: int | None = None) bool[source]

Switch the file path for a new file_path based on the value of the associated keyword in the fcs.

Parameters:
  • new_file_path (str) – file path to replace the existing file path with.

  • token (If None then will only look for keywords that follow directly after a) – token indicating the

  • method_number (int | None) – method number for the file to replace.

  • token

Returns:

(bool) – representing whether the file was successfully changed