Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev branch to merge back #8

Merged
merged 31 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4224975
Cache latest working example with 2-D sweep.
Sep 14, 2023
897b586
Making versions of emod-typhoid and emodpy really specific for now in…
Sep 14, 2023
c65b0a8
Adding Feb162019 config and campaign files.
Sep 14, 2023
b89024b
Point manifest to 2018 files.
Sep 14, 2023
728c96b
example.py uses new path param in cache_experiment_metadata_in_sql fu…
Sep 14, 2023
79585fa
Populate PrevalenceDistributionXXX keys in demographics since older b…
Sep 20, 2023
37a28ac
All-important __init__.py might have been missing still.
Sep 20, 2023
6fe9c48
Added requirements.txt for 2018 model.
Sep 20, 2023
1b3859b
Bump to 0.0.3
Sep 20, 2023
ec2d7a6
Update start_here to work natively with 2018 model.
Sep 20, 2023
cad0a8c
Show how to grab csv report.
Sep 20, 2023
3399ed8
add pakistan demographics
AKraay-IDM Sep 21, 2023
cfcbf72
Merge pull request #2 from InstituteforDiseaseModeling/main
jonathanhhb Sep 22, 2023
3a2a0ca
Rev'd emod-api and emod-typhoid to enable use of scheduled typhoid va…
Sep 25, 2023
1c7156d
Make vaccine efficacy profile functional.
Sep 25, 2023
7c52617
Make vaccine efficacy profile functional.
Sep 25, 2023
de10aa8
Pass through waning/duration params.
Sep 27, 2023
aa60096
Don't want that file in version control.
Sep 28, 2023
5670fcd
Adding comments during PR review.
Sep 28, 2023
7f05a8e
Removing dead code during PR review.
Sep 28, 2023
0c0b0d6
Dev branch to merge, sans branch changes to keep but not merge.
Sep 28, 2023
e66a13a
Added doc strings from ChatGPT for TV.
Sep 28, 2023
b50a01e
Merge remote-tracking branch 'origin/main' into dev_branch_to_merge_back
Sep 28, 2023
1e51ba2
Changed some remaining malaria references (from template) to typhiod.
Sep 28, 2023
8578161
Changed some remaining malaria references (from template) to typhiod.
Sep 28, 2023
66b3208
More whitespace for sphinx/RTD/etc.
Sep 28, 2023
84f1655
Less whitespace for sphinx/RTD/etc.
Sep 28, 2023
8fe80d2
Added html_css_files entry to conf.py for docs.
Sep 28, 2023
efd6edd
updated Sphinx config to correctly apply css, corrected typos in .git…
JSchripsema-IDM Sep 28, 2023
09a7fcd
Merge pull request #11 from JSchripsema-IDM/dev_branch_to_merge_back
jonathanhhb Sep 28, 2023
2b264a4
Fixed bug caught by Sharon where new_intervention_as_file wasnt passi…
Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/emodpy-typhoid*.rst
docs/emodpy_typhoid*.rst
docs/modules.rst

# PyBuilder
Expand Down
4 changes: 2 additions & 2 deletions docs/_templates/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends '!breadcrumbs.html' %}
{% block breadcrumbs %}
<li><a href="https://idmod.org/documentation">IDM docs</a> &raquo;</li>
<li><a href="{{ pathto(master_doc) }}">emodpy-malaria</a> &raquo;</li>
<li><a href="{{ pathto(master_doc) }}">emodpy-typhoid</a> &raquo;</li>
{% for doc in parents %}
<li><a href="{{ doc.link|e }}">{{ doc.title }}</a> &raquo;</li>
{% endfor %}
<li>{{ title }}</li>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions docs/_templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends '!footer.html' %}
{% block extrafooter %}
<p>emodpy-malaria is licensed under the <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">Creative Commons
<p>emodpy-typhoid is licensed under the <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">Creative Commons
Attribution-ShareAlike 4.0 International License</a>.</p>
<p>Send documentation feedback to <a href="mailto:[email protected]" target="_top">[email protected]</a></p>
<p><a href="https://www.gatesfoundation.org/Privacy-and-Cookies-Notice">Privacy and Cookies Notice</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
<a href="https://www.gatesfoundation.org/Terms-of-Use">Terms of Use</a></p>
{% endblock %}
{% endblock %}
50 changes: 33 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
else:
subprocess.check_output(["make.bat", "generate-api"], cwd=os.path.dirname(os.path.abspath(__file__)))

# Rename "emodpy-malaria" to "API reference"
# Rename "emodpy-typhoid" to "API reference"
filename = 'modules.rst' # This must match the Makefile
with open(filename) as f: # Read existing file
lines = f.readlines()
Expand Down Expand Up @@ -59,10 +59,27 @@
'sphinx_copybutton',
'sphinx.ext.intersphinx',
'sphinxext.remoteliteralinclude',
'myst_parser',
'sphinx_search.extension'
'myst_parser', # source files written in MD or RST
'sphinx_search.extension', # search across entire IDM docs domain
'sphinx.ext.viewcode' # link to view source code
]

myst_enable_extensions = [
"amsmath",
"attrs_inline",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]
plantuml = 'plantweb'

autodoc_default_options = {
Expand Down Expand Up @@ -208,15 +225,14 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".

html_static_path = ['_static']

html_context = {
'css_files': [
'_static/theme_overrides.css',
'_static/copy_button.css'
]
}
html_js_files = ['show_block_by_os.js']
html_css_files = ['theme_overrides.css']

html_js_files = ['show_block_by_os.js']


# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the docs.
Expand Down Expand Up @@ -310,7 +326,7 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'emodpy-malaria'
htmlhelp_basename = 'emodpy-typhoid'

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -336,7 +352,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'emodpy-malaria-docs.tex', u'emodpy-malaria',
(master_doc, 'emodpy-typhoid-docs.tex', u'emodpy-typhoid',
u'Institute for Disease Modeling', 'manual'),
]

Expand Down Expand Up @@ -378,7 +394,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'emodpy-malaria-docs', u'emodpy-malaria',
(master_doc, 'emodpy-typhoid-docs', u'emodpy-typhoid',
[author], 1)
]

Expand All @@ -392,8 +408,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'emodpy-malaria-docs', u'emodpy-malaria',
author, 'Institute for Disease Modeling', 'How to use emodpy for malaria simulations.',
(master_doc, 'emodpy-typhoid-docs', u'emodpy-typhoid',
author, 'Institute for Disease Modeling', 'How to use emodpy for typhoid simulations.',
'Miscellaneous'),
]

Expand All @@ -420,6 +436,6 @@
'emod_api': ('https://docs.idmod.org/projects/emod-api/en/latest/', None),
'emodpy': ('https://docs.idmod.org/projects/emodpy/en/latest/', None),
'idmtools': ('https://docs.idmod.org/projects/idmtools/en/latest/', None),
'emod-malaria': ('https://docs.idmod.org/projects/emod-malaria/en/latest/', None),
'emod-typhoid': ('https://docs.idmod.org/projects/emod-typhoid/en/latest/', None),
'pycomps': ('https://docs.idmod.org/projects/pycomps/en/latest/', None)
}
}
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
==============================

|EMODPY_typhoid| is a collection of Python scripts and utilities created to
streamline user interactions with |EMOD_s| and |IT_s| for modeling malaria.
streamline user interactions with |EMOD_s| and |IT_s| for modeling typhoid.
Much of the functionality is inherited from the
:doc:`emod_api:emod_api` and :doc:`emodpy:emodpy`.

Additional information about how to use |IT_s| can be found in
:doc:`idmtools:index`. Additional information about |EMOD_s| malaria
parameters can be found in :doc:`emod-malaria:parameter-overview`.
:doc:`idmtools:index`. Additional information about |EMOD_s| typhoid
parameters can be found in :doc:`emod-typhoid:parameter-overview`.

See :doc:`idmtools:index` for a diagram showing how |IT_s| and each of the
related packages are used in an end-to-end workflow using |EMOD_s| as the
Expand Down
2 changes: 1 addition & 1 deletion docs/variables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

.. |IDM_l| replace:: Institute for Disease Modeling (IDM)
.. |EMODPY_s| replace:: emodpy
.. |EMODPY_typhoid| replace:: typhoid
.. |EMODPY_typhoid| replace:: emodpy-typhoid
.. |emod_api| replace:: emod-api
.. |IDM_s| replace:: IDM
.. |EMOD_l| replace:: Epidemiological MODeling software (EMOD)
Expand Down
12 changes: 12 additions & 0 deletions emodpy_typhoid/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def cleanup_for_2018_mode( config ):
# when using 2018 binary
config.parameters.pop( "Serialized_Population_Filenames" )
config.parameters.pop( "Serialization_Time_Steps" )
config.parameters.pop( "Demographics_Filename" )

config.parameters.Incubation_Period_Distribution = "FIXED_DURATION" # hack
config.parameters.Infectious_Period_Distribution = "FIXED_DURATION" # hack
config.parameters.Base_Incubation_Period = 1
config.parameters.Base_Infectious_Period = 1
config.parameters["Listed_Events"] = []

6 changes: 5 additions & 1 deletion emodpy_typhoid/demographics/TyphoidDemographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class TyphoidDemographics(Demographics):
"""
def __init__(self, nodes, idref="Gridded world grump2.5arcmin", base_file=None):
super().__init__( nodes, idref, base_file )
# The following is for back-compat with older versions of the model which looked for these keys unconditionally.
self.raw["Defaults"]["IndividualAttributes"]["PrevalenceDistributionFlag"] = 0
self.raw["Defaults"]["IndividualAttributes"]["PrevalenceDistribution1"] = 0
self.raw["Defaults"]["IndividualAttributes"]["PrevalenceDistribution2"] = 0
#super().SetDefaultProperties()

def fromBasicNode(lat=0, lon=0, pop=1e6, name=1, forced_id=1):
Expand Down Expand Up @@ -77,7 +81,7 @@ def from_csv( pop_filename_in, site="No_Site", min_node_pop = 0 ):
site: A string to identify the country, village, or trial site.

Returns:
A :py:class:`~emodpy_malaria.demographics.MalariaDemographics` instance.
A :py:class:`~emodpy_typhoid.demographics.MalariaDemographics` instance.
"""
typhoid_demog = Demog.from_csv( pop_filename_in )
nodes = []
Expand Down
75 changes: 63 additions & 12 deletions emodpy_typhoid/interventions/typhoid_vaccine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,36 @@
from emod_api.interventions import common
import json

def new_intervention( camp, efficacy=1.0, mode="Shedding" ):
"""
TyphoidVaccine intervention wrapper. Just the intervention. No configuration yet.
def new_intervention( camp, efficacy=0.82, mode="Shedding", constant_period=0, decay_constant=6935.0 ):
"""
Create a new TyphoidVaccine intervention with specified parameters. If you use this function directly, you'll need to distribute the intervention with a function like ScheduledCampaignEvent or TriggeredCampaignEvent from emod_api.interventions.common.

Args:
camp (Camp): The camp to which the intervention is applied.
efficacy (float, optional): The efficacy of the Typhoid vaccine. Default is 0.82.
mode (str, optional): The mode of the intervention. Default is "Shedding".
constant_period (float, optional): The constant period of the waning effect in days. Default is 0.
decay_constant (float, optional): The decay time constant for the waning effect. Default is 6935.0.

Returns:
TyphoidVaccine: A fully configured instance of the TyphoidVaccine intervention with the specified parameters.
"""

intervention = s2c.get_class_with_defaults( "TyphoidVaccine", camp.schema_path )
intervention.Effect = efficacy
intervention.Mode = mode
# WaningEffect is TBD.
intervention.Changing_Effect = s2c.get_class_with_defaults( "WaningEffectBoxExponential" )
intervention.Changing_Effect.Initial_Effect = efficacy
intervention.Changing_Effect.Box_Duration = constant_period
intervention.Changing_Effect.Decay_Time_Constant = decay_constant
return intervention

def new_triggered_intervention(
camp,
efficacy=0.82,
mode="Shedding",
constant_period=0,
decay_constant=6935.0,
start_day=1,
triggers=[ "Births" ],
coverage=1.0,
Expand All @@ -23,29 +41,62 @@ def new_triggered_intervention(
co_event=None # expansion slot
):
"""
Distribute TyphoidVaccine when something happens as determined by a signal published from the
model or another campaign event.
Create a new triggered TyphoidVaccine intervention based on specified parameters.

Args:
camp (Camp): The camp to which the intervention is applied.
efficacy (float, optional): The efficacy of the Typhoid vaccine. Default is 0.82.
mode (str, optional): The mode of the intervention. Default is "Shedding".
constant_period (float, optional): The constant period of the waning effect in days. Default is 0.
decay_constant (float, optional): The decay time constant for the waning effect. Default is 6935.0.
start_day (int, optional): The day on which the intervention starts. Default is 1.
triggers (list, optional): List of triggers for the intervention. Default is ["Births"].
coverage (float, optional): Demographic coverage of the intervention. Default is 1.0.
node_ids (list, optional): List of node IDs where the intervention is applied. Default is None.
property_restrictions_list (list, optional): List of property restrictions for the intervention. Default is an empty list.
co_event (None, optional): Expansion slot for future use.

Returns:
TriggeredCampaignEvent: An instance of a triggered campaign event with the TyphoidVaccine intervention.
"""
iv = new_intervention( camp )
iv = new_intervention( camp, efficacy=efficacy, mode=mode, constant_period=constant_period, decay_constant=decay_constant )

#event = common.ScheduledCampaignEvent( camp, Start_Day=start_day, Demographic_Coverage=coverage, Intervention_List=[ act_intervention, bcast_intervention ], Node_Ids=nodeIDs, Property_Restrictions=property_restrictions_list )
event = common.TriggeredCampaignEvent( camp, Start_Day=start_day, Triggers=triggers, Demographic_Coverage=coverage, Intervention_List=[ iv ], Node_Ids=node_ids, Property_Restrictions=property_restrictions_list, Event_Name="Triggered Typhoid Vax" )

return event

def new_scheduled_intervention(
camp,
efficacy=0.82,
mode="Shedding",
constant_period=0,
decay_constant=6935.0,
start_day=1,
coverage=1.0,
node_ids=None,
property_restrictions_list=[],
co_event=None # expansion slot
):
"""
Distribute TyphoidVaccine when something happens as determined by a signal published from the
model or another campaign event.
Create a new scheduled TyphoidVaccine intervention based on specified parameters.

Args:
camp (Camp): The camp to which the intervention is applied.
efficacy (float, optional): The efficacy of the Typhoid vaccine. Default is 0.82.
mode (str, optional): The mode of the intervention. Default is "Shedding".
constant_period (float, optional): The constant period of the waning effect in days. Default is 0.
decay_constant (float, optional): The decay time constant for the waning effect. Default is 6935.0.
start_day (int, optional): The day on which the intervention starts. Default is 1.
coverage (float, optional): Demographic coverage of the intervention. Default is 1.0.
node_ids (list, optional): List of node IDs where the intervention is applied. Default is None.
property_restrictions_list (list, optional): List of property restrictions for the intervention. Default is an empty list.
co_event (None, optional): Expansion slot for future use.

Returns:
ScheduledCampaignEvent: An instance of a scheduled campaign event with the TyphoidVaccine intervention.

"""
iv = new_intervention( camp )
iv = new_intervention( camp, efficacy=efficacy, mode=mode, constant_period=constant_period, decay_constant=decay_constant )

#event = common.ScheduledCampaignEvent( camp, Start_Day=start_day, Demographic_Coverage=coverage, Intervention_List=[ act_intervention, bcast_intervention ], Node_Ids=nodeIDs, Property_Restrictions=property_restrictions_list )
event = common.ScheduledCampaignEvent( camp, Start_Day=start_day, Demographic_Coverage=coverage, Intervention_List=[ iv ], Node_Ids=node_ids, Property_Restrictions=property_restrictions_list )
Expand All @@ -54,7 +105,7 @@ def new_scheduled_intervention(

def new_intervention_as_file( camp, start_day, filename=None ):
import emod_api.campaign as camp
camp.add( new_triggered_intervention( camp, start_day ), first=True )
camp.add( new_triggered_intervention( camp, start_day=start_day ), first=True )
if filename is None:
filename = "TyphoidVaccine.json"
camp.save( filename )
Expand Down
Loading
Loading