vis_tools.SpatialReports module

SpatialReports.py

This class is a collection class that keeps track of all the SpatialReport_* files in a given directory. It is used by VisSet.

Usage:

reports = SpatialReports("output/")
print reports
class vis_tools.SpatialReports.SpatialReports(spatial_dir='', verbose=False)

Bases: object

Collection class for a set of spatial reports.

The class is constructed with the directory in which SpatialReport_* files reside. Thereafter the public data members described below, and the various accessor functions, can be used to get access to the list.

Additionally, since SpatialReports implements __len__, __iter__, and

__getitem__, the SpatialReports object can be treated as a list:, e.g.:

spatial_reports = SpatialReports("/output")
path = spatial_reports[0]

Public members:

source_dir (str): The source directory used to construct the SpatialReports object.

paths (array): Array of strings with paths to the SpatialReport_* files.

properties (dict): Dictionary<friendlyName, dict<key,value>> of additional properties to associate with each SpatialBinary file path. Currently these are unused, but will be used in an upcoming version.

k_spatial_filename_glob = 'SpatialReport*_*.bin'
k_spatial_leaf_re = '^SpatialReport[^_]*_(.*)'
get(index)

Returns detailed information on spatial binary by index.

Returns

An object containing the name, friendly name, and path (url) to the spatial binary at the provided index.

Return type

obj

Parameters

index (int) – Index, 0-based, into path list.

add(report_path)

Manually add a spatial binary to the list.

This method can be used to manually add a spatial binary to the list even if it is not in the source_dir where spatial_binaries normally live. This is useful for adding a programmatically-generated spatial binary to the list. Such generated spatial binaries are generally located in the preprocessing script’s products directory.

Example:

reports = SpatialReports("output/")
reports.add(path.join(k_products_dir,
    'SpatialReport_Infectious_Vector_Count'))
Returns

None.

Parameters
  • report_path (str) – The path to the spatial binary. Note that this

  • need not be within source_dir. (path) –

emit_object()

Emits an object used by VisSet to represent spatial binary channels.

Result:

object: A Dictionary<friendly_name, file_path> for the spatial binaries found in the target directory.

Parameters

None.

emit_object_json()

Emits the JSON for the object from emit_object.

Result:

str: JSON representation of the emit_object() result.

Parameters

None.

remove(friendly_name)

Removes a spatial binary from the list by friendly name.

Returns

None.

Parameters
  • friendly_name (str) – The friendly name of the spatial binary path

  • remove. E.g., for SpatialReport_Adult_Vectors, the friendly (to) –

  • is "Adult Vectors". (name) –