Share
 
 

Introduction

Setting up a Python Notebook within ArcGIS Pro

By installing ArcGIS Pro and InfoWater Pro, your machine is equipped to access multiple python packages to perform analysis and results sharing.

The easiest way to begin running Python as an InfoWater Pro user is to create a Python Notebook within ArcGIS Pro. You can create Python notebooks from the Analysis tab and begin scripting alongside the model.

Python notebooks can be saved and shared between projects as .ipynb files. The ArcGIS Pro Catalog provides support for loading .ipynb files and managing their metadata associated with the project.

Refer to ESRI's documentation on Python notebooks for additional information.

Note: You can also access the same python capabilities in other Python IDE's.

Start scripting

To get started reading InfoWater Pro results, you will need to import the Manager class and call it on an output file path to instantiate an output object for scripting.

Here is a simple example to import the class and call it on an output file. A new output manager object called "outman" is created for the specified model output data with all of the behaviors inherited from the class. The script can then call any of the available methods to extract results.

>>> from infowater.output.manager import Manager
>>> outman = Manager("C:\\Users\\Public\\Documents\\InfoWater Pro\\Examples\\Net1.OUT\\SCENARIO\\BASE\\HYDQUA.OUT")
>>> outman.get_range_data("Junction","Pressure","Avg")
[288.8804931640625, 276.3491516113281, 276.96966552734375, 280.3660888671875, 276.39874267578125, 279.9580078125, 284.6310729980469, 272.4742736816406, 261.0697937011719]

Useful tips

  • Refer the Output manager class documentation and examples as you build scripts.
  • You can call in-line help within the python notebook using the “help()” command.

  • If you are unsure of the available fields, output types, units, or indices that can be used, you can refer to the full metadata of any output.

The following example dumps the metadata into json format for easy viewing:

>>> import json
>>> metadata = outman.get_metadata() 
>>> print(json.dumps(vars(metadata), indent=4))

Note: The range fields are included toward the bottom, which can be used to specify range outputs in several methods:

Learn from Others

The Autodesk customer success team maintain a library of sample scripts on GitHub where users are welcome to find ideas and borrow code. Everyone is encouraged to join the community, ask questions, and submit ideas and improvements.

https://github.com/innovyze/Open-Source-Support

Sample .IPYNB files can be downloaded, added to your model project through the Catalog, and adapted to suit your needs.

Was this information helpful?