Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Network Analysis and Data Integration (NADI)

NADI is group of software packages that facilitate network analysis and do data analysis on data related to network/nodes.

NADI System consists of:

ToolDescription
NADI GISGeographic Information (GIS) Tool for Network Detection
NADI Task SystemDomain Specific Programming Language
NADI PluginsPlugins that provide the functions in Task System
NADI libraryRust and Python library to use in your programs
NADI CLICommand Line Interface to run NADI Tasks
NADI IDEIntegrated Development Environment to write/ run NADI Tasks

The github repositories consisting of source codes:

RepoTool
nadi-gisNadi GIS
nadi-systemNadi CLI/ IDE/ Core
nadi-plugins-rustSample Plugins
nadi-bookSource for this Nadi Book

NADI GIS

Geographic Information (GIS) Tool for Network Detection. The main purpose of the NADI GIS is to find the network connectivity between a set of points using a stream network (which can be developed from elevation models, or downloaded from national databases).

NADI GIS can be used as a terminal command or QGIS plugin, refer to installation section for how to install it.

NADI Task System

Task System is a Domain Specific Programming Language (DSL) that is designed for river network analysis. This is the main core of the network analysis. This is included when you install NADI as a library, CLI or GUI.

NADI Plugins

The functions available to call in the task system comes from plugins. There are many internal plugins with core functions already available, while users can load their own plugins for other functions.

Refer to the plugins section of the book for more details on how to use plugins, how to write them and what to keep in mind while using them.

NADI libraries

Rust and Python library to use in your programs. Rust library nadi_core is available to download/use from cargo with the command cargo add nadi_core.

While Python library requires you to clone the repo and build it with maturin (for now). Future plan for it includes publishing it in pypi.

Rust Libraries

If you are not writing your own rust programs or plugins, you can skip this section.

There are three rust libraries:

LibraryUse
nadi_coreCore library with data types, and plugin structure
nadi_pluginRust Procedural macro library to write nadi plugins
string_template_plusLibrary for string templates with variables

Everything is loaded by nadi_core so you don’t need to load them separately.

NADI Python

While using NADI from python library, you only have access to nadi data types (Node, Network, etc), and the plugin functions, which are enough for most cases as python language syntax, variables, loops etc will give you a lot of flexibility on how to do your own analysis. The python module is structured as follows:

nadi [contains Node, Network, etc]
 +-- functions
 | +-- node [contains node functions]
 | +-- network [contains network functions]
 | +-- env [contains env functions]
 +-- plugins
   +-- <plugin> [each plugin will be added here]
   | +-- node [contains node functions]
   | +-- network [contains network functions]
   | +-- env [contains env functions]
   +-- <next-plugin> and so on ...

The functions are available directly through functions submodule, or through each plugin in plugins submodule. An example python script looks like this:

import nadi
import nadi.functions as fn

net = nadi.Network("data/ohio.network")
for node in net.nodes:
    try:
        _ = int(node.name)
        node.is_usgs = True
        print(fn.node.render(node, "Node {_NAME} is USGS Site"))
    except ValueError:
        node.is_usgs = False

This code shows how to load a network, how to loop through the nodes, and use python logic, or use nadi functions for the node and assign attributes.

More detail on how to use NADI from python will be explained in NADI Python chapter.

NADI CLI

Command Line Interface to run NADI Tasks.

This can run nadi task files, syntax highlight them for verifying them, generate markdown documentations for the plugins. The documentations included in this book (Function List and each plugin’s page like Attributes Plugin attrs) are generated with that. The documentation on each plugin functions comes from their docstrings in the code, please refer to how to write plugins section of the book for details on that.

The available options are shown below.

Usage: nadi [OPTIONS] [TASK_FILE]

Arguments:
  [TASK_FILE]  Tasks file to run; if `--stdin` is also provided this runs before stdin

Options:
  -C, --completion <FUNC_TYPE>  list all functions and exit for completions [possible values: node, network, env]
  -c, --fncode <FUNCTION>       print code for a function
  -f, --fnhelp <FUNCTION>       print help for a function
  -g, --generate-doc <DOC_DIR>  Generate markdown doc for all plugins and functions
  -l, --list-functions          list all functions and exit
  -n, --network <NETWORK_FILE>  network file to load before executing tasks
  -p, --print-tasks             print tasks before running
  -s, --show                    Show the tasks file, do not do anything
  -S, --stdin                   Use stdin for the tasks; reads the whole stdin before execution
  -t, --task <TASK_STR>         Run given string as task before running the file
  -h, --help                    Print help
  -V, --version                 Print version

NADI IDE

NADI Integrated Development Environment (IDE) is a Graphical User Interface (GUI) for the users to write/ run NADI Tasks.

As seen in the image below, IDE consists of multiple components arranged in a tiling manner. You can drag them to move them around and build your own layout. When you start IDE it suggests you some layouts and what to open. You can use the buttons on the top right of each pane to:

  • change pane type
  • vertically split current pane
  • horizontally split current pane
  • fullscreen current page/ restore layout if it’s fullscreen
  • close current pane

Screenshot of NADI IDE

It has the following components:

Text Editor

Open text files, edit and save them.

It comes with syntax highlighting for most languages. And custom highlight for tasks and network files.

For Tasks file, it can also show you function signatures on top so you can write tasks easily, knowing what arguments the function needs and what the default values are.

While open inside IDE, it can also run the tasks by sending them to the terminal, or search help documentations on functions. Hover over the buttons on the top row to see which button does what, and the keyboard shortcut to use them as well.

Terminal

Terminal is there so you can run NADI in a interactive session. Read Eval Print Loop (REPL) of NADI here is meant mostly to be used inside the IDE to evaluate the tasks from editor, but you can open it independently as well.

Function Help

This is a GUI with the list of all available plugin functions. You can expand the sidebar on left to search and browse functions. You can filter by type of function (node, network, env) with the buttons. When you click a function you can read its documentation on the right side.

Capabilities of the iced GUI libraries are limited right now, so you cannot select or copy text from the help. Please refer to the documentation online to do that. Or generate the documentation locally using nadi-cli tool.

Network Viewer

This is a pane where network is visualized, this is a very basic visualization to see the connections and is not optimized for drawing. Please avoid using this pane (making it visible) in case of large networks as it takes a lot of computation to draw this each frame.

Attribute Browser

When you click on a node on Network Viewer it will open/update showing the attributes of that node. There is no way to edit the attributes from here, which is intensional design as attributes should be assigned from tasks so that they are reproducible. For temporary assignments use the terminal.

SVG Viewer

This is a basic utility that can open a SVG file from disk and visualize it. You can click the refresh button to re-read the same file. This is intended for a quick way to check the SVG saved/exported from tasks. This is not a full fledge SVG renderer, so open them in image viewers or browsers to see how it looks.

Trivia

  • Nadi means River in Nepali (and probably in many south asian languages).
  • First prototype of NADI was Not Available Data Integration, as it was meant to be an algorithm to fill data gaps using network information, but it was modified to be more generic for many network related analysis.