Skip to content

Commit 3be9fa9

Browse files
authored
Update to sampled infections output file.
Update to output sampled infection files.
2 parents 218ab73 + c2aac19 commit 3be9fa9

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

fpg_observational_model/run_observational_model.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ def get_default_config():
2828
},
2929
'intervention_start_month': 29, # Provide month where an intervention is applied. Currently any sampling pre/post intervention for a single intervention is supported.
3030
'sampling_configs': {
31-
'random': {
32-
'method': 'random',
33-
'n_samples_year': 100,
34-
'replicates': 2,
35-
'method_params': {
36-
'population_proportions': [1, 0], # Use to sample from the source or sink only, equally, etc. Within population comparisons of genetic metrics can be specified below - just make sure to total number of samples per year * proportion reflects the numbers you want per population.
37-
'monogenomic_proportion': False, # Set to False if sampling randomly
38-
'equal_monthly': False}
39-
},
31+
# 'random': {
32+
# 'method': 'random',
33+
# 'n_samples_year': 100,
34+
# 'replicates': 2,
35+
# 'method_params': {
36+
# 'population_proportions': [1, 0], # Use to sample from the source or sink only, equally, etc. Within population comparisons of genetic metrics can be specified below - just make sure to total number of samples per year * proportion reflects the numbers you want per population.
37+
# 'monogenomic_proportion': False, # Set to False if sampling randomly
38+
# 'equal_monthly': False}
39+
# },
4040
# 'seasonal': {
4141
# 'method': 'seasonal',
4242
# 'n_samples_year': 100,
43-
# 'replicates': 2,
43+
# 'replicates': 1,
4444
# 'method_params': {
4545
# 'season': 'full', # Options: full or peak; currently hardcoded to match Senegal's seasonality; update for other scenarios in unified_sampling.py
4646
# }
@@ -450,7 +450,11 @@ def deep_merge(default_dict, override_dict):
450450
sample_output_filepath = f'{output_path}/{sim_name}_FPG_SampledInfections.csv'
451451
# Merge in individual IBx results for sampled infections
452452
if not all_infection_ibx.empty:
453-
sample_df = sample_df.merge(all_infection_ibx, on='infIndex', how='left')
453+
# remove the monthly samples if in the df to have a smaller sampling only infection file
454+
if 'month_rep0' in sample_df.columns:
455+
sample_df = sample_df.drop(columns=['month_rep0'])
456+
sample_df = extract_sampled_infections(sample_df)
457+
sample_df = sample_df.merge(all_infection_ibx, on='infIndex', how='inner')
454458
sample_df.to_csv(sample_output_filepath, index=False)
455459

456460
save_ibx_distributions = True

fpg_observational_model/unified_sampling.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,12 @@ def run_sampling_model(input_df, config, intervention_start_month=None, verbose=
672672

673673
# Add simulation_year column if it doesn't exist
674674
if 'simulation_year' not in df.columns and 'year' in df.columns:
675-
df['simulation_year'] = df['year'].copy()
675+
df['simulation_year'] = df['year'].copy()
676676

677+
# Ensure continuous_month exists for time-based filtering
678+
if 'continuous_month' not in df.columns:
679+
df = convert_month(df)
680+
677681
try:
678682
# Step 1: Apply hard filters
679683
if verbose:

0 commit comments

Comments
 (0)