Skip to content

Commit

Permalink
Include Victoria mixing matrix graph in Romain's notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
jtrauer committed Sep 1, 2021
1 parent 8ed77fb commit 1d5e4bb
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions notebooks/user/rragonnet/compare_matrices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
"source": [
"model_iso3 = \"AUS\"\n",
"source_iso3 = \"GBR\"\n",
"age_adjust = True\n",
"\n",
"AGEGROUP_STRATA = [str(5 * i) for i in range(16)]\n",
"\n",
"\n",
"prem_matrices = get_prem_mixing_matrices(model_iso3)\n",
"new_matrices = build_synthetic_matrices(model_iso3, source_iso3, AGEGROUP_STRATA)\n",
"new_matrices = build_synthetic_matrices(model_iso3, source_iso3, AGEGROUP_STRATA, age_adjust)\n",
"\n",
"# normalise new_matrices\n",
"lambdas_prem, _ = np.linalg.eig(prem_matrices[\"all_locations\"])\n",
Expand Down Expand Up @@ -112,6 +113,30 @@
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create matrix outputs to look as similar as possible to previous Vic figure\n",
"fig = plt.figure(dpi=200)\n",
"reordered_locations = (\"all_locations\", \"home\", \"work\", \"other_locations\", \"school\")\n",
"positions = [1, 2, 3, 5, 6]\n",
"for i_loc, location in zip(positions, reordered_locations):\n",
" ax = fig.add_subplot(2, 3, i_loc)\n",
" ax.imshow(\n",
" np.flipud(np.transpose(new_matrices[location])), \n",
" cmap=cm.hot, \n",
" vmin=0,\n",
" vmax=new_matrices[location].max(), \n",
" origin='lower'\n",
" )\n",
" ax.set_title(location.replace(\"_\", \" \"), fontsize=11)\n",
" ax.set_xticks([])\n",
" ax.set_yticks([])"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -239,7 +264,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.13"
"version": "3.6.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 1d5e4bb

Please sign in to comment.