Enerplot¶
Launch & Connect¶
-
mhi.enerplot.
application
()¶ This method will find try to find a currently running Enerplot application, and connect to it. If no running Enerplot application can be found, or if it is unable to connect to that application, a new Enerplot application will be launched and a connection will be made to it.
If running inside a Python environment embedded within an Enerplot application, the containing application instance is always returned.
Returns: The Enerplot application proxy object Return type: Enerplot Example:
import mhi.enerplot enerplot = mhi.enerplot.application() enerplot.load_files('myproject')
-
mhi.enerplot.
connect
(host='localhost', port=None, timeout=5)¶ This method will find try to find a currently running Enerplot application, and connect to it.
Parameters: - host (str) – The host the Enerplot application is running on (defaults to the local host)
- port (int) – The port to connect to. Required if running multiple Enerplot instances.
- timeout (float) – Seconds to wait for the connection to be accepted.
Returns: The Enerplot application proxy object
Return type: Example:
import mhi.enerplot enerplot = mhi.enerplot.application() enerplot.load_files('myproject')
-
mhi.enerplot.
launch
(port=None, silence=True, timeout=5, **options)¶ Launch a new Enerplot instance and return a connection to it.
Parameters: - port (int) – The port to connect to. Required if running multiple Enerplot instances.
- silence (bool) – Suppresses dialogs which can block automation.
- timeout (float) – Time (seconds) to wait for the connection to be accepted.
- **options – Additional keyword=value options
Returns: The Enerplot application proxy object
Return type: Example:
import mhi.enerplot enerplot = mhi.enerplot.launch() enerplot.load_files('myproject')
Application Object¶
-
class
mhi.enerplot.
Enerplot
¶ The Enerplot Application
This object is a proxy object, used to communicate with a running Enerplot Application.
Workspace¶
-
Enerplot.
new_workspace
(default_book=True)¶ Create a new workspace
The workspace will contain an ‘Untitled’ book, unless default_book is set to False.
Parameters: default_book (bool) – Create an ‘Untitled’ book in the new workspace
-
Enerplot.
load_workspace
(workspace, folder=None)¶ Load an existing Enerplot workspace
Parameters: - workspace (str) – pathname to the workspace to load. The extension .epwx is appended if not present.
- folder (str) – If provided, the path to the workspace is resolved relative to this folder.
-
Enerplot.
save_workspace
(*, save_projects=True)¶ Save the current Enerplot workspace
Parameters: save_projects (bool) – Set to False
if only the workspace should be saved, and not any unsaved projects.
-
Enerplot.
save_workspace_as
(workspace, *, folder=None, save_projects=True)¶ Save the current Enerplot workspace
Parameters: - workspace (str) – pathname to save the workspace as. The extension .epwx is appended if not present.
- folder (str) – If provided, the path to the workspace is resolved relative to this folder.
- save_projects (bool) – Set to
False
if only the workspace should be saved, and not any unsaved projects.
Books¶
-
Enerplot.
load_books
(*files, folder=None)¶ Load one or more books into the workspace.
Parameters: - *files (str) – pathnames to one or more project book files. A
~
or~user
prefix, as well as any$var
,${var}
and%var%
patterns in the pathnames are expanded, and the resulting pathnames are converted to absolute paths before being passed to the remote application. - folder (str) – If provided, the relative paths to the files are resolved relative to this folder.
- *files (str) – pathnames to one or more project book files. A
-
Enerplot.
new_book
(path, folder=None)¶ Create a new book
Parameters: - path (str) – location to store the book. The extension .epbx is appended if not present.
- folder (str) – If provided, the path to the book is resolved relative to this folder.
Returns: the book proxy object
Return type:
-
Enerplot.
books
()¶ Returns: an indexable dictionary of all currently loaded books Return type: IndexableDict[str,Book]
Data Files¶
-
Enerplot.
load_datafiles
(*files, folder=None, load_data=True, fmt=0)¶ Load data files
Parameters: - *files (str) – One or more pathnames to datafiles.
- folder (str) – If provided, the datafile paths are resolved relative to this folder.
- load_data (bool) – Set to False to delay loading of the data until it is needed.
- fmt (int) – If the extensions do not indicate a unique format, a format code is required.
Returns: An indexable dictionary of data files
Return type: IndexableDict[str,DataFile]
¶ Format Code Description DataFile.FLT_EMTDC PSCAD/EMTDC DataFile.FLT_CSV Comma Separated Files DataFile.FLT_CSV_UNFORMATTED Comma Separated Files (Unformatted) DataFile.FLT_COMTRADE COMTRADE Files DataFile.FLT_PSSE PSS/E Files DataFile.FLT_HFS Harmonic Frequency Scanner Files DataFile.FLT_RSCAD RSCAD Files
-
Enerplot.
new_datafile
(path='External Data')¶ Create a mutable datafile
Parameters: name (str) – The location to store the data Returns: the created data file Return type: MutableDataFile
-
Enerplot.
datafiles
()¶ List the currently loaded data files
Returns: an indexable dictionary of data files Return type: IndexableDict[str,DataFile]
Status & Progress¶
The status bar at the bottom of the application is used to give feedback to the user about the progress of various operations as well as the final results. The following functions grant a script access to this feedback.
-
Enerplot.
status
(message, window=0)¶ Display a message in a status bar message window
Parameters: - message (str) – Message to display in status bar
- window (int) – Status bar message window number (0, 1, or 2)
-
Enerplot.
progress
(text='', total=100, status=0, priority=0)¶ Create and return a Progress Bar
Parameters: - text (str) – Message to display in progress bar
- total (int) – Maximum progress value (default: 100)
- status (int) – 0 = running, 1 = waiting, 2 = stopped
- priority (int) – priority for the progress bar display
Returns: a progress bar
Return type:
-
class
mhi.enerplot.
Progress
¶ Progress Bar in the application’s Status Bar area
When finished with a progress bar, it is imperative to call the close() method to allow Enerplot to remove the bar from the status window. This is easiest done using a
with
statement which will automatically close the resource, even if an exception or early return occurs:with enerplot.progress() as progress_bar: progress_bar.update(10) progress_bar.update(50) progress_bar.update(100)
-
update
(amount=None, *, total=None, status=None, priority=None, text=None)¶ Update a previously created progress bar
Parameters: - amount (int) – new amount of progress to display in the bar
- total (int) – new maximum value for the progress bar (optional)
- status (int) – 0 = running, 1 = waiting, 2 = stopped (optional)
- priority (int) – priority for the progress bar (optional)
- text (str) – message to display in progress bar (optional)
-
amount
¶ progress bar amount (write-only)
-
total
¶ progress bar total (write-only)
-
status
¶ progress bar status code (write-only)
-
priority
¶ progress bar priority (write-only)
-
text
¶ progress bar text (write-only)
-
close
()¶ Remove the progress bar from the status bar at the bottom of the application.
When finished with a progress bar, it is imperative to call the close() method to allow Enerplot to remove the bar from the status window. This is easiest done using a
with
statement which will automatically close the resource, even if an exception or early return occurs:with enerplot.progress() as progress_bar: progress_bar.update(10) progress_bar.update(50) progress_bar.update(100)
-