{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Health care facilities - study steps\n", "------------------------------------\n", "This notebook runs a simulation with only a few people, just to show the study steps." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pysimpactcyan\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setting data directory to /usr/local/share/simpact-cyan/\n" ] } ], "source": [ "# First, we'll need to tell the Simpact simulation engine to use the MaxART-specific simulation\n", "simpact = pysimpactcyan.PySimpactCyan()\n", "simpact.setSimulationPrefix(\"maxart\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using identifier 'maxart-2016-03-08-16-36-10_6931_aWfQzxYG-'\n", "Results will be stored in directory '/tmp/simptest'\n", "Running simpact executable...\n", "Done.\n", "\n", "# read seed from /dev/urandom\n", "# Using seed 204635079\n", "# WARNING! Ignoring negative values when reading /usr/local/share/simpact-cyan/SWZ10adjv4.tif\n", "# Performing extra check on read configuration parameters\n", "# WARNING: ignoring consistency check for config key facilities.geo.coords (config value is '/usr/local/share/simpact-cyan/maxart-facilities.csv')\n", "# WARNING: ignoring consistency check for config key facilities.randomization (config value is '/tmp/maxart-randomization-fake_1.csv')\n", "# WARNING: ignoring consistency check for config key person.geo.dist2d.discrete.densfile (config value is '/usr/local/share/simpact-cyan/SWZ10adjv4.tif')\n", "# WARNING: ignoring consistency check for config key person.geo.dist2d.discrete.maskfile (config value is '/usr/local/share/simpact-cyan/hhohho_mask.tiff')\n", "# WARNING: ignoring consistency check for config key population.agedistfile (config value is '/usr/local/share/simpact-cyan/sa_2003.csv')\n", "# mNRM: using advanced algorithm\n", "# Release version\n", "# Simpact version is: 0.19.6testing\n", "# Current simulation time is 15\n", "# Number of events executed is 2415\n", "# Started with 200 people, ending with 184 (difference is -16)\n" ] } ], "source": [ "# We configure the simulation to use one of the files with fake randomization data\n", "# (which should have been saved to /tmp/maxart-randomization-fake_1.csv for this\n", "# exact configuration to work)\n", "\n", "cfg = { \"facilities.randomization\": \"/tmp/maxart-randomization-fake_1.csv\" }\n", "r = simpact.run(cfg, \"/tmp/simptest\")\n", "\n", "# We then read the steps as they have been written to a CSV log file\n", "steps = pd.read_csv(r[\"logsteps\"])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
timeBulandzeni ClinicHerefords ClinicHhukwini ClinicHoro ClinicMaguga ClinicMalandzela Nazarene ClinicMshingishingini Nazarene ClinicNdvwabangeni Nazarene ClinicNdzingeni Nazarene ClinicNtfonjeni ClinicPeak Nazarene ClinicPigg's Peak Government HospitalSigangeni ClinicSiphocosini Clinic
05.00000CCCCCCCCCCCCCC
15.33333CTCCCCCTCCCCCC
25.66667CICCTCCICTCCCC
36.00000CICTICCICITCCC
46.33333TICIICCICIICCT
56.66667IITIITCICIICCI
67.00000IIIIIICITIITCI
77.33333IIIIIITIIIIITI
87.66667IIIIIIIIIIIIII
98.00000PostPostPostPostPostPostPostPostPostPostPostPostPostPost
\n", "
" ], "text/plain": [ " time Bulandzeni Clinic Herefords Clinic Hhukwini Clinic Horo Clinic \\\n", "0 5.00000 C C C C \n", "1 5.33333 C T C C \n", "2 5.66667 C I C C \n", "3 6.00000 C I C T \n", "4 6.33333 T I C I \n", "5 6.66667 I I T I \n", "6 7.00000 I I I I \n", "7 7.33333 I I I I \n", "8 7.66667 I I I I \n", "9 8.00000 Post Post Post Post \n", "\n", " Maguga Clinic Malandzela Nazarene Clinic Mshingishingini Nazarene Clinic \\\n", "0 C C C \n", "1 C C C \n", "2 T C C \n", "3 I C C \n", "4 I C C \n", "5 I T C \n", "6 I I C \n", "7 I I T \n", "8 I I I \n", "9 Post Post Post \n", "\n", " Ndvwabangeni Nazarene Clinic Ndzingeni Nazarene Clinic Ntfonjeni Clinic \\\n", "0 C C C \n", "1 T C C \n", "2 I C T \n", "3 I C I \n", "4 I C I \n", "5 I C I \n", "6 I T I \n", "7 I I I \n", "8 I I I \n", "9 Post Post Post \n", "\n", " Peak Nazarene Clinic Pigg's Peak Government Hospital Sigangeni Clinic \\\n", "0 C C C \n", "1 C C C \n", "2 C C C \n", "3 T C C \n", "4 I C C \n", "5 I C C \n", "6 I T C \n", "7 I I T \n", "8 I I I \n", "9 Post Post Post \n", "\n", " Siphocosini Clinic \n", "0 C \n", "1 C \n", "2 C \n", "3 C \n", "4 T \n", "5 I \n", "6 I \n", "7 I \n", "8 I \n", "9 Post " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Let's show this step data. The first line is written when the study is started (by default\n", "# 5 years into the simulation). At that point, all facilities are in the control stage ('C').\n", "# Then, the stage each facility is in is written at regular intervals, when new facilities enter\n", "# the transitioning stage ('T'), or when they advance to the intervention stage ('I'). A final\n", "# line is written when the study has ended ('Post' study).\n", "steps" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }