Skip to content

Commit

Permalink
LODES ADRIO Data Estimation (#177)
Browse files Browse the repository at this point in the history
* Basic Progress and Estimation Implementation.

* Outlier state sizes and accounting for aux versus main files.

* Added dictionary of file sizes and added average JT04-JT05 sizes.

* Fixed some minor bugs, reformatted 06-05 devlog rumes.

* Small readability fixes.

* Small condition change.

* Cache Key fix

* Naming conventions fix and url generation function added.
  • Loading branch information
meaghan66 authored Oct 18, 2024
1 parent 51c34e4 commit 5a5d2ed
Show file tree
Hide file tree
Showing 2 changed files with 326 additions and 64 deletions.
147 changes: 109 additions & 38 deletions doc/devlog/2024-06-05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,65 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ADRIO data usage estimation:\n",
"- epymorph.adrio.lodes.Commuters will download 32.8 MB and write 32.8 MB to disk\n",
"In total we will:\n",
"- Download 32.8 MB, taking 32 seconds (assuming 1.0 MB/s)\n",
"- Write 32.8 MB to disk cache (you have 249.2 GB free space)\n"
]
}
],
"source": [
"from unittest.mock import Mock\n",
"\n",
"import numpy as np\n",
"\n",
"from epymorph.data_shape import SimDimensions\n",
"from epymorph.geography.us_census import StateScope\n",
"from epymorph.simulation import NamespacedAttributeResolver\n",
"from epymorph import *\n",
"from epymorph.adrio import acs5\n",
"from epymorph.simulator.data import evaluate_param\n",
"from epymorph.adrio import lodes\n",
"\n",
"\n",
"state_scope = StateScope.in_states_by_code([\"AZ\", \"CO\", \"NV\", \"NM\"])\n",
"time_period = 2015\n",
"geoids = state_scope.get_node_ids()\n",
"\n",
"rume = SingleStrataRume.build(\n",
" ipm_library[\"no\"](),\n",
" mm_library[\"no\"](),\n",
" init.NoInfection(),\n",
" scope=state_scope,\n",
" time_frame=TimeFrame.year(time_period),\n",
" params={\"population\": acs5.Population(), \"commuters\": lodes.Commuters(time_period)},\n",
")\n",
"\n",
"data = Mock(spec=NamespacedAttributeResolver)\n",
"dim = Mock(spec=SimDimensions)\n",
"rng = Mock(spec=np.random.Generator)"
"rume.estimate_data()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading epymorph.adrio.lodes.Commuters:\n",
" |####################| 100% (87.504s)\n"
]
}
],
"source": [
"from epymorph.adrio import adrio, lodes\n",
"\n",
"time_period = 2015\n",
"commuters = lodes.Commuters(time_period)\n",
"geoids = adrio.NodeId()"
"with sim_messaging():\n",
" commuters = evaluate_param(rume, \"commuters\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -103,13 +129,9 @@
}
],
"source": [
"print(\n",
" f\"Home/Work GEOIDs:\\n {geoids.evaluate_in_context(data, dim, state_scope, rng)}\\n\"\n",
")\n",
"print(f\"Home/Work GEOIDs:\\n {geoids}\\n\")\n",
"\n",
"print(\n",
" f\"Commuters Matrix:\\n {commuters.evaluate_in_context(data, dim, state_scope, rng)}\\n\"\n",
")"
"print(f\"Commuters Matrix:\\n {commuters}\\n\")"
]
},
{
Expand Down Expand Up @@ -181,23 +203,78 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ADRIO data usage estimation:\n",
"- epymorph.adrio.lodes.CommutersByAge will download 0 Bytes and write 0 Bytes to disk\n",
"- epymorph.adrio.lodes.CommutersByAge will not require any additional data\n",
"- epymorph.adrio.lodes.CommutersByAge will not require any additional data\n",
"In total we will:\n",
"- Download no additional data\n",
"- Write no new data to disk cache\n"
]
}
],
"source": [
"from epymorph.adrio.lodes import CommutersByAge\n",
"from epymorph.geography.us_census import CountyScope\n",
"from epymorph import *\n",
"from epymorph.adrio import acs5\n",
"from epymorph.simulator.data import evaluate_param\n",
"from epymorph.adrio import lodes\n",
"\n",
"time_period = 2015\n",
"county_scope = CountyScope.in_counties([\"04013\", \"08041\", \"32003\", \"35001\"])\n",
"geoids = county_scope.get_node_ids()\n",
"\n",
"commuters_29_under = CommutersByAge(time_period, \"29 and Under\")\n",
"commuters_30_54 = CommutersByAge(time_period, \"30_54\")\n",
"commuters_55_over = CommutersByAge(time_period, \"55 and Over\")"
"rume = SingleStrataRume.build(\n",
" ipm_library[\"no\"](),\n",
" mm_library[\"no\"](),\n",
" init.NoInfection(),\n",
" scope=county_scope,\n",
" time_frame=TimeFrame.year(time_period),\n",
" params={\n",
" \"population\": acs5.Population(),\n",
" \"commuters_29_under\": lodes.CommutersByAge(time_period, \"29 and Under\"),\n",
" \"commuters_30_54\": lodes.CommutersByAge(time_period, \"30_54\"),\n",
" \"commuters_55_over\": lodes.CommutersByAge(time_period, \"55 and Over\"),\n",
" },\n",
")\n",
"\n",
"rume.estimate_data()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading epymorph.adrio.lodes.CommutersByAge:\n",
" |####################| 100% (11.563s)\n",
"Loading epymorph.adrio.lodes.CommutersByAge:\n",
" |####################| 100% (18.080s)\n",
"Loading epymorph.adrio.lodes.CommutersByAge:\n",
" |####################| 100% (14.555s)\n"
]
}
],
"source": [
"with sim_messaging():\n",
" commuters_29_under = evaluate_param(rume, \"commuters_29_under\")\n",
" commuters_30_54 = evaluate_param(rume, \"commuters_30_54\")\n",
" commuters_55_over = evaluate_param(rume, \"commuters_55_over\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -225,15 +302,9 @@
}
],
"source": [
"print(\n",
" f\"Commuters ages 29 and under:\\n {commuters_29_under.evaluate_in_context(data, dim, county_scope, rng)}\\n\"\n",
")\n",
"print(\n",
" f\"Commuters between ages 30 and 54:\\n {commuters_30_54.evaluate_in_context(data, dim, county_scope, rng)}\\n\"\n",
")\n",
"print(\n",
" f\"Commuters ages 55 and over:\\n {commuters_55_over.evaluate_in_context(data, dim, county_scope, rng)}\\n\"\n",
")"
"print(f\"Commuters ages 29 and under:\\n {commuters_29_under}\\n\")\n",
"print(f\"Commuters between ages 30 and 54:\\n {commuters_30_54}\\n\")\n",
"print(f\"Commuters ages 55 and over:\\n {commuters_55_over}\\n\")"
]
}
],
Expand All @@ -253,7 +324,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.0rc1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 5a5d2ed

Please sign in to comment.