tapios / risk-networks

Code for risk networks: a blend of compartmental models, graphs, data assimilation and semi-supervised learning
Other
2 stars 2 forks source link

Implement saving & loading of epidemic data #182

Closed dburov190 closed 3 years ago

dburov190 commented 3 years ago

This PR implements saving and loading of epidemic data.

There is one crucial edition to epiforecast.epidemic_storage_data, a simple change from namedtuple to an inner-class KeyType which, essentially, emulates the namedtuple behavior.

Second, there is one new wrapper written to load and save data in backward_forward_assimilation.py (and corresponding constants, args etc.)

By default, backward_forward_assimilation.py will try to load data, and if it fails, it will run the epidemic (but it won't save — sort of backwards compatibility). To alter that, there are two flags:

python3 backward_forward_assimilation.py --epidemic-load-data # disable loading of the data
python3 backward_forward_assimilation.py --epidemic-save-data # enable saving of the data

and two additional arguments: --epidemic-storage-name and --epidemic-kinetic-states-name which can be used to specify file names (again, don't need to do that by default).

jinlong83 commented 3 years ago

Can we only store epidemic data by the end of each day? It turns out that we currently store data every contact interval, and we seem to waste some memories on storing those unnecessary data.

dburov190 commented 3 years ago

regarding memory issues, I'm on it; but I think we can merge this one in if no other concerns — I'll address memory in a subsequent one (otherwise, this one can get stale)