Use output files

At the end of the simulation, you will notice that a number of files have been written to the output directory. Some are logging or error output files, which you can read about more in Error and logging files. 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 report structure 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' );