UT-Covid / episimlab

Framework for development of epidemiological models
https://ut-covid.github.io/episimlab/
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Run Partition process in model context #13

Closed ethho closed 3 years ago

ethho commented 3 years ago

Fixes #12

ethho commented 3 years ago

Census ZCTA and the vertex index are not identical:

$ PYTHONPATH='.' poetry run python scripts/20210512_partition_model.py
Traceback (most recent call last):
  File "scripts/20210512_partition_model.py", line 69, in <module>
    main(**opts)
  File "scripts/20210512_partition_model.py", line 48, in main
    out_ds = input_ds.xsimlab.run(model=model, decoding=dict(mask_and_scale=False))
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/xr_accessor.py", line 860, in run
    driver.run_model()
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/drivers.py", line 478, in run_model
    _run(
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/drivers.py", line 342, in _run
    model.execute("initialize", rt_context, **execute_kwargs)
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/model.py", line 1023, in execute
    _, (_, signal_process) = self._execute_process(p_obj, *execute_args)
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/model.py", line 842, in _execute_process
    state_out, signal_out = executor.execute(
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/process.py", line 530, in execute
    signal_out = executor.execute(p_obj, runtime_context, state=state)
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xsimlab/process.py", line 394, in execute
    signal = self.meth(p_obj, *args)
  File "/Users/TASethanho/tacc/projects/meyers/covid/episimlab/episimlab/setup/counts.py", line 62, in initialize
    da[dict()] = self.read_census_csv()
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xarray/core/dataarray.py", line 718, in __setitem__
    assert_coordinate_consistent(value, obj.coords.variables)
  File "/Users/TASethanho/Library/Caches/pypoetry/virtualenvs/episimlab-aT2Erjcy-py3.8/lib/python3.8/site-packages/xarray/core/coordinates.py", line 382, in assert_coordinate_consistent
    raise IndexError(
IndexError: dimension coordinate 'vertex' conflicts between indexed and indexing objects:
<xarray.DataArray 'vertex' (vertex: 1935)>
array([75001, 75002, 75006, ..., 79936, 79938, 79942])
Coordinates:
  * vertex   (vertex) int64 75001 75002 75006 75007 ... 79935 79936 79938 79942
vs.
<xarray.IndexVariable 'vertex' (vertex: 87)>
array([76511, 76527, 76530, 76537, 76574, 76578, 78602, 78610, 78612, 78613,
       78615, 78616, 78617, 78619, 78620, 78621, 78626, 78628, 78632, 78633,
       78634, 78640, 78641, 78642, 78644, 78645, 78648, 78650, 78652, 78653,
       78654, 78655, 78659, 78660, 78662, 78664, 78665, 78666, 78669, 78676,
       78681, 78701, 78702, 78703, 78704, 78705, 78712, 78717, 78719, 78721,
       78722, 78723, 78724, 78725, 78726, 78727, 78728, 78729, 78730, 78731,
       78732, 78733, 78734, 78735, 78736, 78737, 78738, 78739, 78741, 78742,
       78744, 78745, 78746, 78747, 78748, 78749, 78750, 78751, 78752, 78753,
       78754, 78756, 78757, 78758, 78759, 78953, 78957], dtype=int32)
ethho commented 3 years ago

Partitioning Model: Usage

$ PYTHONPATH='.' poetry run python scripts/20210512_partition_model.py
# opens pyplot like below...

20210512_partition_model

ethho commented 3 years ago

As of ddb72e9, the partitioning model ingests contact_xr as a file (tests/data/20200311_contact_matrix.nc) via PartitionFromNC, instead of taking travel_fp and contacts_fp and processing via Partition. This was for the purposes of local development, since running Partition on realistic travel and contacts data takes ~45 minutes serially on Frontera.

ethho commented 3 years ago

Possible next step is to replace PartitionFromNC with Partition, pass travel_fp and contacts_fp, and run on Frontera.