{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# T3 - Multi-Individual Challenge Time Series" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport xarray as xr\n\nfrom emodlib.malaria import IntrahostComponent, create_config" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "duration = 350\nn_people = 25\n\nasexuals = np.zeros((n_people, duration))\ngametocytes = np.zeros((n_people, duration))\n\nconfig = create_config()\npp = [IntrahostComponent.create(config) for _ in range(n_people)]\n_ = [p.challenge() for p in pp]\n\nfor t in range(duration):\n for i, p in enumerate(pp):\n p.update(dt=1)\n asexuals[i, t] = p.parasite_density\n gametocytes[i, t] = p.gametocyte_density\n \nda = xr.DataArray(dims=('individual', 'time', 'channel'),\n coords=(range(n_people), range(duration), ['parasite_density', 'gametocyte_density']))\n \nda.loc[dict(channel='parasite_density')] = asexuals\nda.loc[dict(channel='gametocyte_density')] = gametocytes" }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray (individual: 25, time: 350, channel: 2)>\n",
"array([[[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]],\n",
"\n",
" [[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]],\n",
"\n",
" [[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
"...\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]],\n",
"\n",
" [[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]],\n",
"\n",
" [[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]]])\n",
"Coordinates:\n",
" * individual (individual) int64 0 1 2 3 4 5 6 7 8 ... 17 18 19 20 21 22 23 24\n",
" * time (time) int64 0 1 2 3 4 5 6 7 ... 342 343 344 345 346 347 348 349\n",
" * channel (channel) <U18 'parasite_density' 'gametocyte_density'