User Tools

Site Tools


intermediate_processing_technical_information

The python file uploaded for the intermidiate processing of gBay MUST implement a function named 'process' that receives as an input information about the geographical region being used, the input nodes selected in the application, and the current iteration number.

It is also recommended to import the module 'node_utils'. In this module there are a set of functions that will make it easier to work with the gBay intermidiate processing function. It will be explained later.

The function 'process' has the following prototype:

process(GDALDatasetH dataset, list nodes_data, int iteration)

Inputs

dataset

Reference Dataset. It contains geographical information of the region being used by the current gBay run. gBay uses GDAL to operate with GIS files

For raster files, dataset is the result of calling: gdal.Open( raster_filename, GA_ReadOnly ).

Additional info: http://gdal.org/python/osgeo.gdal.Dataset-class.html

For vector files, dataset is the result of using ESRI Shapefile ogr driver:

driver = ogr.GetDriverByName('ESRI Shapefile')

dataset = driver.Open(vector_filename, 0)

Additional info: http://gdal.org/python/osgeo.ogr.DataSource-class.html

iteration

Current gBay iteration. 0 means before the first network inference. It is commonly used to set nodes beliefs depending on another nodes.

nodes_data

List of python dictionaries with the following keys:

<string> name: Node name <int> states: Number of states of the node <list>data: Likelihood / Values of the node ordered by cell, in case of raster, or feature in case of vector.

In case the node is type 'Discrete', each element of the list is a list of integers, being the current beliefs of the node.

In case the node is type 'Continuous', each element is a float, being the current value of the node.

Example: To get cell CELL belief of state STATE:

value = node.data[CELL][STATE]. Value should be in the range [0..100]

Making use of node_utils:

value = getStateCell(node, CELL, STATE)

Output

The output must have the same structure as nodes_data: It must be a list of dictionaries. In the case that only one node is modified, the list will have one element.

In case the output is not valid, an error message will be displayed in the console and the intrmidiate processing will be ignored.

Node Utils

This module implement the following set of functions:

getNodeByName(node_list, name): find a node in nodes data by name.

getState(likelihood, state): get likelihood of the state index, for discrete nodes.

getLikelihood(node, cell): get the likelihood of a node for a given cell.

setEvidence(node, cell, evidence): : set hard evidence for a node for a given cell.

setLikelihood(node, cell, likelihood): set the likelihood of a node for a given cell.

getValue(node, cell): get the value of a cell, for continuous nodes.

getStateCell(node, cell, state): get the satte likelihood of the node for the given cell.

printNode(node): print node information.

newNode(name, n_cells): create a new node for a given number of cells.

copyLikelihood(node, cell, likelihood): copy the likelihood of a node.

getStateHighestLikelihood(node, cell): get the state of the highest likelihood

getStateLowestLikelihood(node, cell): get the state of the lowest likelihood

isNODATA(node, cell): return True of False in case the cell is NODATA

validResultData(node_list, total_cells, print_error=True): return True or False in case the structure of node_list is valid. It is the function used to check it out of the intermidiate processing.

intermediate_processing_technical_information.txt · Last modified: 2023/04/21 15:30 by 127.0.0.1