Output files

After running a simulation, the simulation data is extracted, aggregated, and saved as an output report to the output directory in the working directory. Depending on your configuration, one or more output reports will be created, each of which summarize different data from the simulation. Output reports can be in JSON, CSV, or binary file formats. EMOD also creates logging or error output files.

The EMOD functionality that produces an output report is known as a reporter. EMOD provides several built-in reporters for outputting data from simulations. By default, EMOD will always generate the report InsetChart.json, which contains the simulation-wide average disease prevalence by time step. If none of the provided reports generates the output report that you require, you can create a custom reporter.

If you want to visualize the data output from an EMOD simulation, you must use graphing software to plot the output reports. In addition to output reports, EMOD will generate error and logging files to help troubleshoot any issues you may encounter.

Using output files

At the end of the simulation, you will notice that a number of files have been written to the output directory. The rest are output reports that contain data from the simulation itself, usually in JSON or CSV format. This topic describes how to parse and use the output reports.

By default, the output report InsetChart.json is always produced, which contains per- timestep values accumulated over the simulation in a variety of reporting channels, for example, “New Infections”, “Adult Vectors”, and “Parasite Prevalence”. EMOD provides several other built-in reports that you can produce if you enable them in the configuration file. See Output files for additional information about the reports and how to enable them.

If none of the built-in output reports provide the data you need, you can use a custom reporter that plugs in to the Eradication.exe as a EMODule dynamic link library (DLL). For more information, see Custom reporters.

In order to interpret the output of EMOD simulations, you will find it useful to parse the output reports into an analyzable structure. For example, you can use a Python or MATLAB script to create graphs and charts for analysis.

Use Python to parse data

The example below uses the Python package JSON to parse the file and the Python package matplotlib.pyplot to plot the output. This is a very simple example and not likely the most robust or elegant. Be sure to set the actual path to your working directory.

import os
import json
import matplotlib.pyplot as plt

# open and parse InsetChart.json
ic_json = json.loads( open( os.path.join( WorkingDirectoryLocation, "output", "InsetChart.json" ) ).read() )
ic_json_allchannels = ic_json["Channels"]
ic_json_birthdata = ic_json["Channels"]["Births"]

# plot "Births" channel by time step
plt.plot( ic_json_birthdata[  "Data"  ], 'b-' )
plt.title( "Births" )
plt.show()

Use MATLAB to parse data

The example below uses the MATLAB toolbox JSONlab to parse an InsetChart.json file and plot one channel. This script uses JSONLab to parse the file into a usable form in MATLAB. This is a very simple example and not likely the most robust or elegant. Be sure to set the actual paths to JSONlab and your working directory.

% this sample uses JSONLab toolbox
addpath('PATH TO/jsonlab');

% open and parse InsetChart.json
ic_json = loadjson( fullfile( 'WorkingDirectoryLocation', 'output', 'InsetChart.json' ));
ic_json_allchannels = ic_json.Channels;
ic_json_birthinfo = ic_json_allchannels.Births;
ic_json_birthdata = ic_json_birthinfo.Data;
M = num2cell(ic_json_birthdata);

% plot "Births" channel by time step
plot(cell2mat(M));
title( 'Births' );