ResSimpy.Nexus.runcontrol_operations.SimControls
- class ResSimpy.Nexus.runcontrol_operations.SimControls(model)[source]
Bases:
objectPublic Data Attributes:
date_format_stringtimesMethods:
__init__(model)Class for controlling all runcontrol and time related functionality :param model: NexusSimulator instance :param __times: list of times to be included in the runcontrol file :type __times: None | list[str] :param __date_format_string: How the dates should formatted based on date_format.
get_times(times_file)Retrieves a list of TIMES from the supplied Runcontrol / Include file.
delete_times(file_content)Deletes times from file contents.
remove_times_from_file(file_content, ...)Removes the times from a file - used for replacing with new times :param file_content: a list of strings containing each line of the file as a new entry :type file_content: list[str] :param output_file_path: path to the file to output to.
convert_date_to_number(date)Converts a date to a number designating number of days from the start date.
compare_dates(x, y)Comparator for two supplied dates or numbers.
sort_remove_duplicate_times(times)Removes duplicates and nans from the times list, then sorts them.
check_date_format(date)Checks that a supplied date is in the correct format.
get_date_format(date_format)Returns the date format being used by the model formats used: ('MM/DD/YYYY', 'DD/MM/YYYY').
Loads the run control information into the class instance.
modify_times([content, operation])Modifies the output times in the simulation.
- __init__(model) None[source]
Class for controlling all runcontrol and time related functionality :param model: NexusSimulator instance :param __times: list of times to be included in the runcontrol file :type __times: None | list[str] :param __date_format_string: How the dates should formatted based on date_format. :type __date_format_string: str
- static get_times(times_file: list[str]) list[str][source]
Retrieves a list of TIMES from the supplied Runcontrol / Include file.
Args:
times_file (list[str]): list of strings with each line from the file a new entry in the list
- returns:
list[str] – list of all the values following the TIME keyword in supplied file, empty list if no values found
- static delete_times(file_content: list[str]) list[str][source]
Deletes times from file contents.
- Parameters:
file_content (list[str]) – list of strings with each line from the file a new entry in the list.
- Returns:
list[str] – the modified file without any TIME cards in
- static remove_times_from_file(file_content: list[str], output_file_path: str) None[source]
Removes the times from a file - used for replacing with new times :param file_content: a list of strings containing each line of the file as a new entry :type file_content: list[str] :param output_file_path: path to the file to output to. :type output_file_path: str
- convert_date_to_number(date: str | float) float[source]
Converts a date to a number designating number of days from the start date.
Args:
date (str | float): a date or time stamp from a Nexus simulation
- raises ValueError:
if supplied incorrect type for ‘date’ parameter
Returns:
float: the difference between the supplied date and the start date of the simulator
- compare_dates(x: str | float, y: str | float) int[source]
Comparator for two supplied dates or numbers.
Args:
x (str | float): first date to compare y (str | float): second date to compare
Returns:
int: -1 if y > x, 0 if y == x, 1 if y < x
- sort_remove_duplicate_times(times: list[str]) list[str][source]
Removes duplicates and nans from the times list, then sorts them.
Args:
times (list[str]): list of times to remove duplicates from
Returns:
list[str]: list of times without duplicates
- check_date_format(date: str | float) None[source]
Checks that a supplied date is in the correct format.
Args:
date (str | float): date to check the format of
- raises ValueError:
If a date provided isn’t in a date format that the model expects
- static get_date_format(date_format: DateFormat) str[source]
Returns the date format being used by the model formats used: (‘MM/DD/YYYY’, ‘DD/MM/YYYY’).
- load_run_control_file()[source]
Loads the run control information into the class instance. If the write_times attribute is True then it expands out any INCLUDE files with the times found within :raises ValueError: if the run_control_file attribute is None.
- modify_times(content: list[str] | None = None, operation: str = 'merge')[source]
Modifies the output times in the simulation.
Args:
content (list[str]], optional): The content to modify using the above operation, represented as a list of strings with a new entry per line of the file. Defaults to None. operation (str, optional): operation to perform on the content provided (e.g. ‘merge’). Defaults to ‘merge’.
Raises:
ValueError: if the supplied dates are before the start date of the simulation