Using Python Code for Interactive AGVis Web Sessions
The functionality of interaction through Python code will improve the applicability. The main use of AGVis can be classified into two aspects: 1) starting, and 2) visualizing.
AGVis web is hosted using Python http.server. The visualization part is using the Leaflet. The data exchange between ANDES and AGVis is through a socket file using DiME.
It is possible to let AGVis interact with the web and the Python code through the socket file, namely, DiME client and DiME server.
Starting
Description
The modules cli and system module (available at cli and system) allows users to launch AGVis from either the command line or IPython as showing below:
Command line:
agvis run --host 127.0.0.1 --port 8810
IPython:
import agvis
web = agvis.webapp()
web.run(open_browser=True)
Update on 04/28/2023
We have developed two modules, cli and web, which enhance the starting process of AGVis web. For more information on how to use the command line interface, please refer to our documentation on Command line usage.
In this implementation, we use http.server and socketserver.TCPServer to host the web application in the background. However, Flask can be a better choice for its flexibility and usability to allow interactive usage.
web.load(agvis.get_case('ieee39.xlsx')) # Load topology into the web
web.play(andes_case='ieee39.xlsx', andes_output='ieee39_out.csv') # play the animation with given input
web.refresh() # Refresh the web
...
web.stop()
One possible approach for integration is to use DiME, which can start and run a DiME server backend for communication between ANDES and AGVis. However, this approach may require the packaging of DiME. See https://github.com/CURENT/dime/issues/47 for more discussion.
Then, this improvement makes it possible to integrate AGVis as a built-in visualizer for ANDES and AMS in the future.
Using Python Code for Interactive AGVis Web Sessions
The functionality of interaction through Python code will improve the applicability. The main use of AGVis can be classified into two aspects: 1) starting, and 2) visualizing. AGVis web is hosted using Python http.server. The visualization part is using the Leaflet. The data exchange between ANDES and AGVis is through a socket file using DiME.
It is possible to let AGVis interact with the web and the Python code through the socket file, namely, DiME client and DiME server.
Starting
Description
The modules
cli
andsystem
module (available at cli and system) allows users to launch AGVis from either the command line or IPython as showing below:Command line:
IPython:
Update on 04/28/2023
We have developed two modules,
cli
andweb
, which enhance the starting process of AGVis web. For more information on how to use the command line interface, please refer to our documentation on Command line usage.In this implementation, we use
http.server
andsocketserver.TCPServer
to host the web application in the background. However, Flask can be a better choice for its flexibility and usability to allow interactive usage.Reference: https://flask.palletsprojects.com/en/2.3.x/
Visualizing
Description
After starting a web using the following code:
The further interaction can be:
One possible approach for integration is to use DiME, which can start and run a DiME server backend for communication between ANDES and AGVis. However, this approach may require the packaging of DiME. See https://github.com/CURENT/dime/issues/47 for more discussion.
Then, this improvement makes it possible to integrate AGVis as a built-in visualizer for ANDES and AMS in the future.