Skip to content

Commit 7062cf0

Browse files
jkumwendathewatimnjowetamuri
authored
Resource file path from simulation (#1410)
Co-authored-by: thewati <[email protected]> Co-authored-by: Watipaso Mulwafu <[email protected]> Co-authored-by: Emmanuel Mnjowe <[email protected]> Co-authored-by: Asif Tamuri <[email protected]>
1 parent eb94b70 commit 7062cf0

File tree

148 files changed

+2467
-2693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+2467
-2693
lines changed

docs/tlo_parameters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,11 @@ def write_parameters_file(
302302
)
303303
args = parser.parse_args()
304304
simulation = Simulation(
305-
start_date=Date(2010, 1, 1), seed=1234, log_config={"suppress_stdout": True}
305+
start_date=Date(2010, 1, 1), seed=1234, log_config={"suppress_stdout": True},
306+
resourcefilepath=args.resource_file_path
306307
)
307308
status_quo_parameters = get_parameters_for_status_quo()
308-
simulation.register(*fullmodel.fullmodel(args.resource_file_path))
309+
simulation.register(*fullmodel.fullmodel())
309310
internal_link_formatter = _formatters[args.output_file_path.suffix]["internal_link"]
310311
character_escaper = _formatters[args.output_file_path.suffix]["character_escaper"]
311312
module_parameter_tables, module_structured_parameters = get_parameter_tables(

src/scripts/Alri_analyses/alri_calibration_plots/GBD_comparison_plots.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@
5656
seed = random.randint(0, 50000)
5757

5858
# Establish the simulation object
59-
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
59+
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
60+
show_progress_bar=True, resourcefilepath=resourcefilepath)
6061

6162
# run the simulation
6263
sim.register(
63-
demography.Demography(resourcefilepath=resourcefilepath),
64-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
65-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
66-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
67-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
68-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
69-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
70-
service_availability=['*']),
71-
alri.Alri(resourcefilepath=resourcefilepath),
64+
demography.Demography(),
65+
enhanced_lifestyle.Lifestyle(),
66+
symptommanager.SymptomManager(),
67+
healthseekingbehaviour.HealthSeekingBehaviour(),
68+
healthburden.HealthBurden(),
69+
simplified_births.SimplifiedBirths(),
70+
healthsystem.HealthSystem(service_availability=['*']),
71+
alri.Alri(),
7272
alri.AlriPropertiesOfOtherModules()
7373
)
7474

src/scripts/Alri_analyses/alri_calibration_plots/analysis_Alri_default_params.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,19 @@
5151
}
5252

5353
# Establish the simulation object
54-
sim = Simulation(start_date=start_date, log_config=log_config, show_progress_bar=True)
54+
sim = Simulation(start_date=start_date, log_config=log_config,
55+
show_progress_bar=True, resourcefilepath=resourcefilepath)
5556

5657
# run the simulation
5758
sim.register(
58-
demography.Demography(resourcefilepath=resourcefilepath),
59-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
60-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
61-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
62-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
63-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
64-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath, disable=True),
65-
alri.Alri(resourcefilepath=resourcefilepath),
59+
demography.Demography(),
60+
enhanced_lifestyle.Lifestyle(),
61+
symptommanager.SymptomManager(),
62+
healthseekingbehaviour.HealthSeekingBehaviour(),
63+
healthburden.HealthBurden(),
64+
simplified_births.SimplifiedBirths(),
65+
healthsystem.HealthSystem(disable=True),
66+
alri.Alri(),
6667
alri.AlriPropertiesOfOtherModules()
6768
)
6869

src/scripts/Alri_analyses/alri_calibration_plots/analysis_Alri_with_and_without_treatment.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,18 @@
6161
_disable_and_reject_all = False
6262

6363
# add file handler for the purpose of logging
64-
sim = Simulation(start_date=start_date, log_config=log_config, show_progress_bar=True)
64+
sim = Simulation(start_date=start_date, log_config=log_config,
65+
show_progress_bar=True, resourcefilepath=resourcefilepath)
6566

6667
sim.register(
67-
demography.Demography(resourcefilepath=resourcefilepath),
68-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
69-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
70-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
71-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath,
72-
force_any_symptom_to_lead_to_healthcareseeking=True),
73-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
74-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
75-
disable=_disable,
76-
disable_and_reject_all=_disable_and_reject_all),
77-
78-
alri.Alri(resourcefilepath=resourcefilepath),
68+
demography.Demography(),
69+
enhanced_lifestyle.Lifestyle(),
70+
simplified_births.SimplifiedBirths(),
71+
symptommanager.SymptomManager(),
72+
healthseekingbehaviour.HealthSeekingBehaviour(force_any_symptom_to_lead_to_healthcareseeking=True),
73+
healthburden.HealthBurden(),
74+
healthsystem.HealthSystem(disable=_disable, disable_and_reject_all=_disable_and_reject_all),
75+
alri.Alri(),
7976
alri.AlriPropertiesOfOtherModules()
8077
)
8178

src/scripts/Alri_analyses/alri_calibration_plots/analysis_effect_of_treatment.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,19 @@ def get_sim(popsize):
3939
"""Return a simulation (composed of only <5 years old) that has run for 0 days."""
4040
resourcefilepath = Path('./resources')
4141
start_date = Date(2010, 1, 1)
42-
sim = Simulation(start_date=start_date, seed=0)
42+
sim = Simulation(start_date=start_date, seed=0, resourcefilepath=resourcefilepath)
4343

4444
sim.register(
45-
demography.Demography(resourcefilepath=resourcefilepath),
46-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
47-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
48-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
45+
demography.Demography(),
46+
simplified_births.SimplifiedBirths(),
47+
enhanced_lifestyle.Lifestyle(),
48+
symptommanager.SymptomManager(),
4949
healthseekingbehaviour.HealthSeekingBehaviour(
50-
resourcefilepath=resourcefilepath,
5150
force_any_symptom_to_lead_to_healthcareseeking=True,
5251
),
53-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
54-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
55-
cons_availability='all',
56-
),
57-
alri.Alri(resourcefilepath=resourcefilepath),
52+
healthburden.HealthBurden(),
53+
healthsystem.HealthSystem(cons_availability='all'),
54+
alri.Alri(),
5855
AlriPropertiesOfOtherModules(),
5956
)
6057
sim.modules['Demography'].parameters['max_age_initial'] = 5

src/scripts/Alri_analyses/alri_calibration_plots/analysis_pulse_oximeter_vs_none.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,19 @@ def run_scenario(**kwargs):
4444
}
4545
}
4646

47-
sim = Simulation(start_date=start_date, log_config=log_config, show_progress_bar=True)
47+
sim = Simulation(start_date=start_date, log_config=log_config,
48+
show_progress_bar=True, resourcefilepath=resourcefilepath)
4849

4950
sim.register(
50-
demography.Demography(resourcefilepath=resourcefilepath),
51-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
52-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
53-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
54-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath,
51+
demography.Demography(),
52+
enhanced_lifestyle.Lifestyle(),
53+
simplified_births.SimplifiedBirths(),
54+
symptommanager.SymptomManager(),
55+
healthseekingbehaviour.HealthSeekingBehaviour(
5556
force_any_symptom_to_lead_to_healthcareseeking=True),
56-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
57-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
58-
disable=True,
59-
cons_availability='all',
60-
),
61-
alri.Alri(resourcefilepath=resourcefilepath),
57+
healthburden.HealthBurden(),
58+
healthsystem.HealthSystem(disable=True, cons_availability='all'),
59+
alri.Alri(),
6260
alri.AlriPropertiesOfOtherModules()
6361
)
6462

src/scripts/Alri_analyses/alri_calibration_plots/baseline_outputs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@
5555
seed = random.randint(0, 50000)
5656

5757
# Establish the simulation object
58-
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
58+
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
59+
show_progress_bar=True, resourcefilepath=resourcefilepath)
5960

6061
# run the simulation
6162
sim.register(
62-
demography.Demography(resourcefilepath=resourcefilepath),
63-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
64-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
65-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
66-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
67-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
68-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
69-
service_availability=['*']),
70-
alri.Alri(resourcefilepath=resourcefilepath),
63+
demography.Demography(),
64+
enhanced_lifestyle.Lifestyle(),
65+
symptommanager.SymptomManager(),
66+
healthseekingbehaviour.HealthSeekingBehaviour(),
67+
healthburden.HealthBurden(),
68+
simplified_births.SimplifiedBirths(),
69+
healthsystem.HealthSystem(service_availability=['*']),
70+
alri.Alri(),
7171
alri.AlriPropertiesOfOtherModules()
7272
)
7373

src/scripts/Alri_analyses/other_scripts/analysis_alri_classification.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,21 @@
5353
seed = random.randint(0, 50000)
5454

5555
# Establish the simulation object
56-
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
56+
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
57+
show_progress_bar=True, resourcefilepath=resourcefilepath)
5758

5859
# run the simulation
5960
sim.register(
60-
demography.Demography(resourcefilepath=resourcefilepath),
61-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
62-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
63-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
64-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
65-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
66-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
67-
service_availability=['*'],
68-
mode_appt_constraints=0,
69-
ignore_priority=True,
61+
demography.Demography(),
62+
enhanced_lifestyle.Lifestyle(),
63+
symptommanager.SymptomManager(),
64+
healthseekingbehaviour.HealthSeekingBehaviour(),
65+
healthburden.HealthBurden(),
66+
simplified_births.SimplifiedBirths(),
67+
healthsystem.HealthSystem(service_availability=['*'], mode_appt_constraints=0, ignore_priority=True,
7068
capabilities_coefficient=1.0,
7169
disable=True),
72-
alri.Alri(resourcefilepath=resourcefilepath),
70+
alri.Alri(),
7371
alri.AlriPropertiesOfOtherModules()
7472
)
7573

src/scripts/Alri_analyses/other_scripts/create_new_logfile.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,23 @@
5353
seed = random.randint(0, 50000)
5454

5555
# Establish the simulation object
56-
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
56+
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
57+
show_progress_bar=True, resourcefilepath=resourcefilepath)
5758

5859
# run the simulation
5960
sim.register(
60-
demography.Demography(resourcefilepath=resourcefilepath),
61-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
62-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
63-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
64-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
65-
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
66-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
67-
service_availability=['*']),
61+
demography.Demography(),
62+
enhanced_lifestyle.Lifestyle(),
63+
symptommanager.SymptomManager(),
64+
healthseekingbehaviour.HealthSeekingBehaviour(),
65+
healthburden.HealthBurden(),
66+
simplified_births.SimplifiedBirths(),
67+
healthsystem.HealthSystem(service_availability=['*']),
6868
# mode_appt_constraints=0,
6969
# ignore_priority=True,
7070
# capabilities_coefficient=1.0,
7171
# disable=True),
72-
alri.Alri(resourcefilepath=resourcefilepath),
72+
alri.Alri(),
7373
alri.AlriPropertiesOfOtherModules()
7474
)
7575

src/scripts/bladder_cancer_analyses/bladder_cancer_analyses.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,21 @@
4646
def run_sim(service_availability):
4747
# Establish the simulation object and set the seed
4848
# seed is not set - each simulation run gets a random seed
49-
sim = Simulation(start_date=start_date, log_config={"filename": "LogFile"})
49+
sim = Simulation(start_date=start_date, log_config={"filename": "LogFile"}, resourcefilepath=resourcefilepath)
5050
# Register the appropriate modules
51-
sim.register(demography.Demography(resourcefilepath=resourcefilepath),
52-
contraception.Contraception(resourcefilepath=resourcefilepath),
53-
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
54-
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
55-
service_availability=service_availability),
56-
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
57-
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
58-
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
59-
labour.Labour(resourcefilepath=resourcefilepath),
60-
pregnancy_supervisor.PregnancySupervisor(resourcefilepath=resourcefilepath),
61-
bladder_cancer.BladderCancer(resourcefilepath=resourcefilepath),
62-
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(resourcefilepath=resourcefilepath),
63-
newborn_outcomes.NewbornOutcomes(resourcefilepath=resourcefilepath),
64-
postnatal_supervisor.PostnatalSupervisor(resourcefilepath=resourcefilepath)
51+
sim.register(demography.Demography(),
52+
contraception.Contraception(),
53+
enhanced_lifestyle.Lifestyle(),
54+
healthsystem.HealthSystem(service_availability=service_availability),
55+
symptommanager.SymptomManager(),
56+
healthseekingbehaviour.HealthSeekingBehaviour(),
57+
healthburden.HealthBurden(),
58+
labour.Labour(),
59+
pregnancy_supervisor.PregnancySupervisor(),
60+
bladder_cancer.BladderCancer(),
61+
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(),
62+
newborn_outcomes.NewbornOutcomes(),
63+
postnatal_supervisor.PostnatalSupervisor()
6564
)
6665
# Run the simulation
6766
sim.make_initial_population(n=popsize)
@@ -99,7 +98,7 @@ def get_cols_excl_none(allcols, stub):
9998
dalys = dalys.sort_index()
10099
# 4) DEATHS wrt age (total over whole simulation)
101100
deaths = output['tlo.methods.demography']['death']
102-
deaths['age_group'] = deaths['age'].map(demography.Demography(resourcefilepath=resourcefilepath).AGE_RANGE_LOOKUP)
101+
deaths['age_group'] = deaths['age'].map(demography.Demography().AGE_RANGE_LOOKUP)
103102
x = deaths.loc[deaths.cause == 'BladderCancer'].copy()
104103
x['age_group'] = x['age_group'].astype(make_age_grp_types())
105104
bladder_cancer_deaths = x.groupby(by=['age_group']).size()
@@ -162,7 +161,7 @@ def get_cols_excl_none(allcols, stub):
162161
deaths = results_no_healthsystem['bladder_cancer_deaths']
163162
deaths.index = deaths.index.astype(make_age_grp_types())
164163
# # make a series with the right categories and zero so formats nicely in the grapsh:
165-
agegrps = demography.Demography(resourcefilepath=resourcefilepath).AGE_RANGE_CATEGORIES
164+
agegrps = demography.Demography().AGE_RANGE_CATEGORIES
166165
totdeaths = pd.Series(index=agegrps, data=np.nan)
167166
totdeaths.index = totdeaths.index.astype(make_age_grp_types())
168167
totdeaths = totdeaths.combine_first(deaths).fillna(0.0)

0 commit comments

Comments
 (0)