def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", campaign_filename="campaign.json", demographics_filename="../../demographics.json", propertyreport_name="PropertyReport.json", reportevenrecorder_name="ReportEventRecorder.csv", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("demographics_filename: " + demographics_filename + "\n") print("propertyreport_name: " + propertyreport_name + "\n") print("reportevenrecorder_name: " + reportevenrecorder_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() report_data_obj = parse_json_report(output_folder, propertyreport_name, debug) csv_df = parse_excel_report(output_folder, reportevenrecorder_name) create_report_file(report_data_obj, csv_df, report_name, debug)
def application( output_folder="output", stdout_filename="test.txt", config_filename="config.json", chart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=True): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "chart_name: " + chart_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename) drug_start_timestep = param_obj[dts.ParamKeys.KEY_DrugStartTime] tb_drug_relapse_rate_hiv = float(param_obj[dts.ConfigKeys.DrugParams.KEY_TbDrugRelapseRateHIV]) # Now process log output (probably) and compare to theory (not in this example) or to another report. relapses, cum_relapses = parse_stdout_file(drug_start_timestep, stdout_filename, debug) sft.plot_data( relapses, cum_relapses, label1="Relapses", label2="Cumulative Relapses", title="Relapses vs. Cumulative Relapses over Time", xlabel="Timestep", ylabel="Relapses", category="Relapses_vs_Cumulative_Relapse", show=True, line = True) active_TB_treatments = parse_json_report( output_folder, chart_name, debug) mean_relapses = [x * tb_drug_relapse_rate_hiv for x in active_TB_treatments] sft.plot_data( relapses[1:len(relapses) - 1], mean_relapses, label1="Relapses", label2="calculated relapses", title="Relapses vs. calculated relapses over Time", xlabel="Timestep", ylabel="Relapses", category="Relapses_actual_vs_calculated", show=True, line=True, overlap=True ) # Now we've ingested all relevant inputs, let's do analysis create_report_file( active_TB_treatments,relapses, tb_drug_relapse_rate_hiv,drug_start_timestep, report_name)
def application( output_folder="output", stdout_filename="test.txt", property_report_name="PropertyReportEnvironmental.json", report_event_recorder="ReportNodeEventRecorder.csv", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename+ "\n") print("property_report_name: " + property_report_name+ "\n") print("report_event_recorder: " + report_event_recorder+ "\n") print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done(stdout_filename) config_obj = General_Support.load_config_parameters(config_filename, Diagnostic_Support.config_keys, debug) demo_overlay_file = config_obj[ConfigKeys.Demographics_Filenames][-1] campaign_obj = Diagnostic_Support.load_campaign_file(campaign_filename, debug) demo_path = "Assets" if stdout_filename == "StdOut.txt" else "" property_obj = HINT_Support.load_demo_mr_overlay_file(demo_overlay_file, demo_path, debug)[0] ip_key_value = campaign_obj[CampaignKeys.EnvironmentalDiagnosticKeys.Environment_IP_Key_Value] property_keys = [] for channel in Diagnostic_Support.channels: property_keys.append("{0}:{1}".format(channel, ip_key_value)) property_df = HINT_Support.parse_property_report_json(property_report_name, output_folder, property_keys, debug) stdout_df = Diagnostic_Support.parse_stdout_file(stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) recorder_obj = Diagnostic_Support.parse_report_event_recorder(output_folder, report_event_recorder, debug) create_report_file(config_obj, campaign_obj, property_obj, property_df, stdout_df, recorder_obj, report_name, report_event_recorder, stdout_filename, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() #param_obj = load_emod_parameters("HIVMaleOverlay.json") param_obj = load_emod_parameters("campaign.json") #total_timesteps = param_obj[KEY_TOTAL_TIMESTEPS] start_timestep = 0 # get from config # Now process log output (probably) and compare to theory (not in this example) or to another report. male_probs, female_probs = parse_stdout_file(start_timestep, stdout_filename, debug) inset_days = parse_json_report(start_timestep, output_folder, insetchart_name, debug) create_report_file(male_probs, female_probs, param_obj, report_name)
def application(output_folder="output", stdout_filename="test.txt", property_report_name="PropertyReportEnvironmental.json", insetchart_name="InsetChart.json", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("property_report_name: " + property_report_name + "\n") print("insetchart_name: " + insetchart_name + "\n") print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done(stdout_filename) config_obj = hint_support.load_config_parameters(config_filename, config_keys, debug) campaign_obj = hint_support.load_campaign_file(campaign_filename, debug) stdout_df = parse_stdout_file(stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) demo_path = "Assets" if stdout_filename == "StdOut.txt" else "" property_list = hint_support.load_demo_mr_overlay_file( config_obj[ConfigKeys.Demographics_Filenames][1], demo_path, debug) property_keys = hint_support.build_channel_string_for_property(property_list, channels, debug) property_df = hint_support.parse_property_report_json(property_report_name, output_folder, property_keys, debug) property_obj = property_list[0] # this test only has one property object inset_chart_obj = General_Support.parse_inset_chart(output_folder, insetchart_name, inset_channels, debug) create_report_file(config_obj, campaign_obj, stdout_df, property_df, property_obj, inset_chart_obj, insetchart_name, property_report_name, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename + "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "insetchart_name: " + insetchart_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename) parsed_data = parse_stdout_file(param_obj, stdout_filename, debug=debug) inset_days = parse_json_report() parsed_data.extend([param_obj[KEY_TYPHOID_ACUTE_INFECTIOUSNESS]]) data_to_graph = create_report_file(parsed_data, inset_days, report_name=sft.sft_output_filename) sft.plot_data_sorted(data_to_graph[0], data_to_graph[1], label1="Actual", label2="Expected", title="Contact Dose Response Probability", xlabel="Occurrences", ylabel="Dose Response", category='contact_dose_response_probability_plot', alpha=0.5, overlap=True) sft.plot_data_sorted(data_to_graph[2], data_to_graph[3], label1="Actual", label2="Expected", title="Environmental Dose Response Probability", xlabel="Occurrences", ylabel="Dose Response", category='environmental_dose_response_probability_plot', alpha=0.5, overlap=True)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") print("current dir = " + os.getcwd()) sft.wait_for_done() param_obj, config_json = MM_Support.load_emod_parameters(config_filename) if debug: print(param_obj) node_demo_df, human_migration_df = MM_Support.parse_output_files( "output/ReportNodeDemographics.csv", "output/ReportHumanMigrationTracking.csv", debug) # for local testing # node_demo_df, human_migration_df = MM_Support.parse_output_files("ReportNodeDemographics.csv", "ReportHumanMigrationTracking.csv", debug) MM_Support.create_report_file(param_obj, node_demo_df, human_migration_df, report_name, debug)
def application(report_file, debug=False): # pdb.set_trace() # print( "Post-processing: " + report_file ) sft.wait_for_done() cdj = json.loads(open("config.json").read())["parameters"] start_time = cdj["Start_Time"] isj = json.loads(open(os.path.join("output", "InsetChart.json")).read())["Channels"] nonai = isj["Number of New Acute Infections"]["Data"] count = 0 sum_count = 0 counts = [] with open("test.txt") as logfile: for line in logfile: if re.search("Update\(\): Time:", line): counts.append(count) sum_count += count count = 0 if re.search("Infection stage transition", line) and re.search( "->Acute", line): count += 1 success = True with open(sft.sft_output_filename, "w") as report_file: if sum_count == 0: # make sure there is at least one acute infection during the test success = False report_file.write("Found no Acute Infections in test case.\n") else: # #2890 # for i in range(1, len(counts)): # count_log = counts[i] # count_icj = nonai[i-1] for i in range(0, len(counts)): count_log = counts[i] count_icj = nonai[i] timestep = start_time + i if count_log != count_icj: success = False report_file.write( "BAD: At time {0}: new Acute infections is {1} from Stdout log, while it's" " {2} from InsetChart.json.\n".format( timestep, count_log, count_icj)) # #2890 # counts2 = counts[1:len(counts)-1] # sft.plot_data(counts2, nonai, label1="New Acute from stdout", label2="New Acute from InsertChart", sft.plot_data(counts, nonai, label1="New Acute from stdout", label2="New Acute from InsertChart", title="New Acute Infections (InsetChart Test)", xlabel="Time", ylabel="Number of New Acute Infections", category='report_inset_chart_new_acute', alpha=0.5, overlap=True) report_file.write(sft.format_success_msg(success))
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = load_emod_parameters(config_filename) parsed_data = parse_stdout_file(param_obj[KEY_START_TIME], stdout_filename, debug=debug) inset_days = parse_json_report(param_obj[KEY_START_TIME], output_folder, insetchart_name, debug) processed_data = create_report_file(parsed_data, inset_days, report_name=sft.sft_output_filename) graph_the_data(processed_data[0], processed_data[1])
def application(output_folder="output", stdout_filename="test.txt", reporter_filename="Report_TBHIV_ByAge.csv", config_filename="config.json", report_name=sft.sft_output_filename, debug=True): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("reporter_filename: " + reporter_filename + "\n") print("config_filename: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = trs.load_emod_parameters(config_filename, debug) output_dict = parse_output_file(stdout_filename, param_obj[trs.Config.simulation_timestep], debug) report_column_list = [ ReportColumn.year, ReportColumn.agebin, ReportColumn.active_sx, ReportColumn.incidence ] reporter_df = trs.parse_custom_reporter( report_column_list, reporter_path=output_folder, reporter_filename=reporter_filename, debug=debug) trs.create_report_file_prevalence(ReportColumn.active_sx, ReportColumn.year, param_obj, output_dict, reporter_df, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = load_emod_parameters(config_filename) parsed_data = parse_stdout_file() inset_days = parse_json_report() create_report_file([ report_name, parsed_data, param_obj.get(TB_CD4_STRATA_I_S), param_obj.get(TB_CD4_S), param_obj.get(BASE_INF), param_obj.get(TB_ACTIVE_PS_INF_MULT), param_obj.get(TB_SMEAR_NEG_MULT) ])
def application(output_folder="output", stdout_filename="test.txt", initial_timestep=0, insetchart_name="InsetChart.json", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder + "\n") print("stdout_filename: " + stdout_filename + "\n") print("initial_timestep: " + str(initial_timestep) + "\n") print("insetchart_name: " + insetchart_name + "\n") print("config_filename: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() vles = VlesEnv() inset_chart_obj = vles.parse_inset_chart(output_folder=output_folder, insetchart_name=insetchart_name, debug=debug) attenuation = vles.parse_stdout_file(initial_timestep=initial_timestep, stdout_filename=stdout_filename, debug=debug) vles.create_report_file(attenuation=attenuation, inset_chart_obj=inset_chart_obj, report_name=report_name, debug=debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", campaign_filename="campaign.json", chart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=True): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("chart_name: " + chart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = load_emod_parameters(config_filename, campaign_filename) #total_timesteps = param_obj[KEY_TOTAL_TIMESTEPS] drug_start_time = param_obj[dts.ParamKeys.KEY_DrugStartTime] start_timestep = param_obj[dts.ConfigKeys.KEY_StartTime] # duration_of_interest = param_obj[dts.ParamKeys.KEY_DrugRegimenLength] drug_inactivation_rate = param_obj[ dts.ConfigKeys.DrugParams.KEY_TbDrugInactivationRateHIV] cum_inactivations, inactivation_times, active_count, inactivations = parse_stdout_file( drug_start_time, start_timestep, stdout_filename, debug) # inset_days = parse_json_report(start_timestep, output_folder, chart_name, debug) create_report_file(drug_start_time, inactivation_times, active_count, inactivations, drug_inactivation_rate, report_name, debug) return None
def application( output_folder="output", stdout_filename="test.txt", config_filename="config.json",campaign_filename="campaign.json", chart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=True): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "chart_name: " + chart_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename,campaign_filename) drug_mortality_rate_HIV = param_obj[dts.ConfigKeys.DrugParams.KEY_TbDrugMortalityRateHIV] drug_start_timestep = param_obj[dts.ParamKeys.KEY_DrugStartTime] duration_of_interest = param_obj[dts.ParamKeys.KEY_DrugRegimenLength] cum_deaths, deaths, infected_individuals, death_times = parse_stdout_file(drug_start_timestep, duration_of_interest, stdout_filename, debug) disease_deaths = parse_json_report(output_folder, chart_name, debug) sft.plot_data( cum_deaths, disease_deaths, label1="stdout", label2="insetchart", title="Cumulative Deaths stdout vs. insetchart", category="Cumulative_Deaths", xlabel="Timestep", ylabel="Deaths", show=True, line=True, overlap=True) # Now we've ingested all relevant inputs, let's do analysis create_report_file(drug_start_timestep, disease_deaths, cum_deaths, deaths, infected_individuals, death_times, drug_mortality_rate_HIV, report_name)
def application( output_folder="output", stdout_filename="test.txt", property_report_name="PropertyReport.json", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=True): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "property_report_name: " + property_report_name+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "campaign_filename: " + campaign_filename + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done(stdout_filename) config_obj = hint_support.load_config_parameters(config_filename, hint_support.config_keys, debug) campaign_obj = hint_support.load_campaign_file(campaign_filename, debug) stdout_df = hint_support.parse_stdout_file(stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) demo_path = "Assets" if stdout_filename == "StdOut.txt" else "" property_list = hint_support.load_demo_overlay_file( config_obj[ConfigKeys.Demographics_Filenames][1], demo_path, debug) property_keys = hint_support.build_channel_string_for_property(property_list, hint_support.channels, debug) property_df = hint_support.parse_property_report_json(property_report_name, output_folder, property_keys, debug) create_report_file(config_obj, campaign_obj, stdout_df, property_df, property_list, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", campaign_filename="campaign.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = dts.load_emod_parameters(config_filename, campaign_filename) start_timestep = param_obj[ConfigKeys.Start_Time] # get from config # Now process log output (probably) and compare to theory (not in this example) or to another report. infections = dts.parse_stdout_file(stdout_filename, debug) inset_summary = dts.parse_json_report(start_timestep, output_folder, insetchart_name, debug) dts.create_report_file(param_obj, infections, inset_summary, report_name)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", property_report_name="PropertyReportEnvironmental.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("property_report_name: " + property_report_name + "\n") print("config_filename: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done(stdout_filename) config_obj = General_Support.load_config_parameters( config_filename, config_keys, debug) stdout_df = parse_stdout_file(stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) demo_path = "Assets" if stdout_filename == "StdOut.txt" else "" property_list = HINT_Support.load_demo_mr_overlay_file( config_obj[ConfigKeys.Demographics_Filenames][-1], demo_path, debug) property_keys = HINT_Support.build_channel_string_for_property( property_list, channels, debug) property_df = HINT_Support.parse_property_report_json( property_report_name, output_folder, property_keys, debug) property_obj = property_list[0] # this test only has one property object create_report_file(config_obj, stdout_df, property_obj, property_df, report_name, debug)
def application(output_folder="output", csv_name="ReportNodeDemographics.csv", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder + "\n") print("csv_name: " + csv_name + "\n") print("config_name: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() with open(config_filename) as infile: test_config_name = json.load(infile)["parameters"]["Config_Name"] sft.start_report_file(report_name, test_config_name) all_data_df = pd.read_csv(path.join(output_folder, csv_name)) all_data_df.rename(columns={' NodeID': 'NodeID', ' Gender': 'Gender', ' AgeYears': 'AgeYears', ' NumIndividuals': 'NumIndividuals', ' NumInfected': 'NumInfected'}, inplace=True) all_data_df.drop(['NumInfected'], axis=1, inplace=True) if debug: all_data_df.to_csv("DEBUG_all_data_cleaned.csv") last_day_df = all_data_df.loc[all_data_df['Time']==399] if debug: last_day_df.to_csv("DEBUG_day_399_data_cleaned.csv") northern_nodes = last_day_df[last_day_df['NodeID'].isin([1,2,3])] southern_nodes = last_day_df[last_day_df['NodeID'].isin([7,8,9])] eastern_nodes = last_day_df[last_day_df['NodeID'].isin([3,6,9])] western_nodes = last_day_df[last_day_df['NodeID'].isin([1,4,7])] create_report_file(sft_filename=report_name, n_nodes=northern_nodes, s_nodes=southern_nodes, e_nodes=eastern_nodes, w_nodes=western_nodes)
def application(output_folder="output", config_filename="config.json", jsonreport_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + jsonreport_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() config_object = dtk_iis.load_config_file(config_filename=config_filename, debug=debug) demographics_overlay_name = config_object[ dtk_iis.ConfigKeys.DEMOGRAPHIC_FILENAMES][-1] campaign_name = config_object[dtk_iis.ConfigKeys.CAMPAIGN_FILENAME] test_config_name = config_object[dtk_iis.ConfigKeys.CONFIG_NAME] campaign_object = dtk_iis.load_campaign_file(campaign_name, debug) outbreak_day = campaign_object[dtk_iis.CampaignKeys.START_DAY] demographics_object = dtk_iis.load_demographics_file( demographics_filename=demographics_overlay_name, susceptibility_initialization_type=config_object[ dtk_iis.ConfigKeys.SUS_INIT_DIST_TYPE], debug=debug) average_immunity = demographics_object[ dtk_iis.DemographicFileKeys.KEY_AVERAGE_IMMUNITY] sft.start_report_file(report_name, test_config_name) report_data_object = dtk_iis.parse_json_report(output_folder=output_folder, report_name=jsonreport_name, debug=debug) statistical_population_channel = report_data_object[ dtk_iis.InsetChannels.STATISTICAL_POPULATION] new_infections_channel = report_data_object[ dtk_iis.InsetChannels.NEW_INFECTIONS] expected_infections_obj = dtk_iis.get_expected_infections( statistical_population_channel, average_immunity, campaign_object, debug=debug) actual_infections = dtk_iis.get_actual_infections(new_infections_channel, outbreak_day) dtk_iis.create_report_file(expected_infections_obj, actual_infections, outbreak_day, report_name, debug=debug)
def application(output_folder="output", stdout_filename=sft.sft_test_filename, config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): sft.wait_for_done() stc = STC() param_obj = stc.load_emod_parameters(config_filename=config_filename) output_df = stc.parse_output_file(output_filename=sft.sft_test_filename, start_time=param_obj[ConfigParameters.KEY_Start_Time], debug=False) stc.create_report_file(param_obj, output_df, report_name=report_name, age_index_1=2, age_index_2=3)
def application(output_folder="output", config_filename="config.json", jsonreport_name="InsetChart.json", stdout_filename="test.txt", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("config_filename: " + config_filename) print("insetchart_name: " + jsonreport_name) print("report_name: " + report_name) print("debug: " + str(debug)) sft.wait_for_done() config_object = dtk_iis.load_config_file(config_filename=config_filename, debug=debug) demographics_overlay_name = config_object[dtk_iis.ConfigKeys.DEMOGRAPHIC_FILENAMES][-1] campaign_name = config_object[dtk_iis.ConfigKeys.CAMPAIGN_FILENAME] test_config_name = config_object[dtk_iis.ConfigKeys.CONFIG_NAME] campaign_object = dtk_iis.load_campaign_file(campaign_name, debug) outbreak_day = campaign_object[dtk_iis.CampaignKeys.START_DAY] demographics_object = dtk_iis.load_demographics_file( demographics_filename=demographics_overlay_name, susceptibility_initialization_type=config_object[dtk_iis.ConfigKeys.SUS_INIT_DIST_TYPE], debug=debug) average_immunity = demographics_object[dtk_iis.DemographicFileKeys.KEY_AVERAGE_IMMUNITY] sft.start_report_file(report_name, test_config_name) individual_df = dtk_iis.parse_stdout_file(stdout_filename, debug=debug) dtk_iis.test_immunity_within_age_range(individual_df, max_age=365, expected_immunity=0.0) dtk_iis.test_immunity_within_age_range(individual_df, max_age=730, expected_immunity=0.4) report_data_object = dtk_iis.parse_json_report(output_folder=output_folder, report_name=jsonreport_name, debug=debug) statistical_population_channel = report_data_object[dtk_iis.InsetChannels.STATISTICAL_POPULATION] new_infections_channel = report_data_object[dtk_iis.InsetChannels.NEW_INFECTIONS] expected_infections_obj = dtk_iis.get_expected_infections(statistical_population_channel, average_immunity, campaign_object, debug=debug) actual_infections = dtk_iis.get_actual_infections(new_infections_channel, outbreak_day) dtk_iis.create_report_file(expected_infections_obj, actual_infections, outbreak_day, report_name, debug=debug)
def application(output_folder="output", stdout_filename="test.txt", reporter_filename="Report_TBHIV_ByAge.csv", inset_chart_filename="InsetChart.json", migration_report_filename="ReportHumanMigrationTracking.csv", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("reporter_filename: " + reporter_filename + "\n") print("inset_chart_filename: " + inset_chart_filename + "\n") print("migration_report_filename: " + migration_report_filename + "\n") print("config_filename: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = tms.load_emod_parameters([ Config.config_name, Config.simulation_timestep, Config.duration, Config.num_core, Config.demog_filename ], config_filename, debug) demog_filename = param_obj[Config.demog_filename][-1] node_list = tms.get_node_counts(demog_filename) json_obj = tms.parse_json_report([InsetChart.disease_death], inset_chart_filename, output_folder, debug) migration_df = tms.load_migration_report(migration_report_filename, output_folder) report_column_list = [ ReportColumn.year, ReportColumn.agebin, ReportColumn.hivdeaths, ReportColumn.diseasedeaths ] reporter_df = trs.parse_custom_reporter( report_column_list, reporter_path=output_folder, reporter_filename=reporter_filename, debug=debug) create_report_file_incidence(ReportColumn.diseasedeaths, ReportColumn.hivdeaths, ReportColumn.year, json_obj, param_obj, reporter_df, migration_df, node_list, stdout_filename, report_name, debug)
def application( output_folder="output", stdout_filename="test.txt", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done(stdout_filename) config_obj = General_Support.load_config_parameters(config_filename, config_keys, debug) stdout_df = parse_stdout_file(stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) create_report_file(config_obj, stdout_df, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "insetchart_name: " + insetchart_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename) parsed_data = parse_stdout_file(debug=True) create_report_file([report_name, parsed_data, param_obj.get(TB_CD4_ACTIVATION_VECTOR)], debug=True)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", chart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("chart_name: " + chart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = load_emod_parameters(config_filename) drug_start_timestep = param_obj[dts.ParamKeys.KEY_DrugStartTime] sim_start_timestep = param_obj[dts.ConfigKeys.KEY_StartTime] # Now process log output (probably) and compare to theory (not in this example) or to another report. duration_of_interest = param_obj[dts.ParamKeys.KEY_DrugRegimenLength] cum_clears, clear_times, stdout_days = parse_stdout_file( drug_start_timestep, duration_of_interest, stdout_filename, debug) inset_days = parse_json_report(sim_start_timestep, debug=debug) if debug: print("trying to plot data\n") sft.plot_data_sorted( cum_clears, label1="Cumulative Clearances", title="Cumulative Clearances over Time from Drugs (HIV+/No ART)", xlabel="Timestep", ylabel="Clearances", show=True) else: sft.plot_data( cum_clears, label1="Cumulative Clearances", title="Cumulative Clearances over Time from Drugs (HIV+/No ART)", xlabel="Timestep", ylabel="Clearances") #inset_days = parse_json_report(start_timestep, output_folder, chart_name, debug) # Now we've ingested all relevant inputs, let's do analysis if debug: print("trying to create report file\n") create_report_file(clear_times, param_obj, report_name, stdout_days, inset_days, debug)
def application( output_folder="output", stdout_filename="test.txt", insetchart_name="InsetChart.json", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "insetchart_name: " + insetchart_name+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "campaign_filename: " + campaign_filename + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename, debug) output_dict = parse_output_file(stdout_filename, debug) create_report_file(param_obj, output_dict, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", insetchart_name="InsetChart.json", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("insetchart_name: " + insetchart_name + "\n") print("config_filename: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done(stdout_filename) config_obj = hint_support.load_config_parameters(config_filename, config_keys, debug) inset_chart_obj = General_Support.parse_inset_chart(output_folder, insetchart_name, channels, debug) create_report_file(config_obj, inset_chart_obj, report_name, insetchart_name, debug)
def application(output_folder="output", config_filename="config.json", campaign_filename="campaign.json", demographics_filename="demographics_100_overlay.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("demographics_filename: " + demographics_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = ips.load_emod_parameters(config_filename, debug) campaign_obj = ips.load_campaign_file(param_obj[KEY_CAMPAIGN_NAME], debug) demographics_obj = ips.load_demographics_file( param_obj[KEY_DEMOGRAPHICS_NAME][-1], debug) report_data_obj = ips.parse_json_report(output_folder, insetchart_name, debug) sft.plot_data(report_data_obj[KEY_NEW_INFECTIONS], title="new infections", label1="New Infections", label2="NA", xlabel="time steps", ylabel="new infection", category='New_infections', show=True) sft.plot_data(report_data_obj[KEY_STATISTICAL_POPULATION], title="Statistical Population", label1="Statistical Population", label2="NA", xlabel="time steps", ylabel="Statistical Population", category='Statistical_population', show=True, line=True) ips.create_report_file(param_obj, campaign_obj, demographics_obj, report_data_obj, report_name, debug)
def application( output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "insetchart_name: " + insetchart_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = isb_support.load_emod_parameters(config_filename) simulation_timestep = param_obj[KEY_SIMULATION_TIMESTEP] output_df = isb_support.parse_output_file(stdout_filename, simulation_timestep, debug) report_df = isb_support.parse_json_report(output_folder, insetchart_name, debug) isb_support.create_report_file(param_obj, output_df, report_df, report_name, debug)
def application( output_folder="output", stdout_filename="test.txt", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename,debug) output_obj = parse_output_file(stdout_filename, debug) multipliers = output_obj[matches[0]] infectiousness = output_obj[matches[1]] create_report_file(param_obj, multipliers, infectiousness, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "insetchart_name: " + insetchart_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename) parsed_data = parse_stdout_file() inset_days = parse_json_report() create_report_file([report_name, parsed_data, param_obj.get(COINFECTION_MORTALITY_RATE_OFF_ART), param_obj.get(COINFECTION_MORTALITY_RATE_ON_ART)])
def application(output_folder="output", stdout_filename="test.txt", property_report_name="PropertyReportEnvironmental.json", report_event_recorder="ReportNodeEventRecorder.csv", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("property_report_name: " + property_report_name + "\n") print("report_event_recorder: " + report_event_recorder + "\n") print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done(stdout_filename) config_obj = General_Support.load_config_parameters( config_filename, Diagnostic_Support.config_keys, debug) demo_overlay_file = config_obj[ConfigKeys.Demographics_Filenames][-1] campaign_obj = Diagnostic_Support.load_campaign_file( campaign_filename, debug) demo_path = "Assets" if stdout_filename == "StdOut.txt" else "" property_obj = HINT_Support.load_demo_mr_overlay_file( demo_overlay_file, demo_path, debug)[0] ip_key_value = campaign_obj[ CampaignKeys.EnvironmentalDiagnosticKeys.Environment_IP_Key_Value] property_keys = [] for channel in Diagnostic_Support.channels: property_keys.append("{0}:{1}".format(channel, ip_key_value)) property_df = HINT_Support.parse_property_report_json( property_report_name, output_folder, property_keys, debug) stdout_df = Diagnostic_Support.parse_stdout_file( stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) recorder_obj = Diagnostic_Support.parse_report_event_recorder( output_folder, report_event_recorder, debug) create_report_file(config_obj, campaign_obj, property_obj, property_df, stdout_df, recorder_obj, report_name, report_event_recorder, stdout_filename, debug)
def application(output_folder="output", csv_name="ReportNodeDemographics.csv", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder + "\n") print("csv_name: " + csv_name + "\n") print("config_name: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() with open(config_filename) as infile: test_config_name = json.load(infile)["parameters"]["Config_Name"] sft.start_report_file(report_name, test_config_name) all_data_df = pd.read_csv(path.join(output_folder, csv_name)) all_data_df.rename(columns={ ' NodeID': 'NodeID', ' Gender': 'Gender', ' AgeYears': 'AgeYears', ' NumIndividuals': 'NumIndividuals', ' NumInfected': 'NumInfected' }, inplace=True) all_data_df.drop(['NumInfected'], axis=1, inplace=True) if debug: all_data_df.to_csv("DEBUG_all_data_cleaned.csv") last_day_df = all_data_df.loc[all_data_df['Time'] == 399] if debug: last_day_df.to_csv("DEBUG_day_399_data_cleaned.csv") northern_nodes = last_day_df[last_day_df['NodeID'].isin([1, 2, 3])] southern_nodes = last_day_df[last_day_df['NodeID'].isin([7, 8, 9])] eastern_nodes = last_day_df[last_day_df['NodeID'].isin([3, 6, 9])] western_nodes = last_day_df[last_day_df['NodeID'].isin([1, 4, 7])] create_report_file(sft_filename=report_name, n_nodes=northern_nodes, s_nodes=southern_nodes, e_nodes=eastern_nodes, w_nodes=western_nodes)
def application( output_folder="output", stdout_filename="test.txt", reporter_filename="Report_TBHIV_ByAge.csv", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=False): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "reporter_filename: " + reporter_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "campaign_filename: " + campaign_filename + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() param_obj = load_emod_parameters(config_filename, debug) campaign_obj = load_campaign_file(campaign_filename, debug) output_df = parse_output_file(stdout_filename, param_obj[Config.simulation_timestep], debug) reporter = parse_custom_reporter(reporter_path=output_folder, reporter_filename=reporter_filename, debug=debug) create_report_file(param_obj, campaign_obj, output_df, reporter, report_name, debug)
def application( output_folder="output", stdout_filename="test.txt", config_filename="config.json",campaign_filename="campaign.json", demographics_filename = "../../demographics.json", propertyreport_name="PropertyReport.json", report_name=sft.sft_output_filename, debug=True): if debug: print( "output_folder: " + output_folder ) print( "stdout_filename: " + stdout_filename+ "\n" ) print( "config_filename: " + config_filename + "\n" ) print( "campaign_filename: " + campaign_filename + "\n" ) print( "demographics_filename: " + demographics_filename + "\n" ) print( "propertyreport_name: " + propertyreport_name + "\n" ) print( "report_name: " + report_name + "\n" ) print( "debug: " + str(debug) + "\n" ) sft.wait_for_done() report_data_obj = parse_json_report(output_folder, propertyreport_name, debug) create_report_file(report_data_obj, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", initial_timestep=0, config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("initial_timestep: " + str(initial_timestep) + "\n") print("config_filename: " + config_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() param_obj = load_emod_parameters(config_filename, debug) stdout_data_obj = parse_stdout_file(initial_timestep, stdout_filename, debug) create_report_file(param_obj, stdout_data_obj, report_name, debug)
def application(report_file): sft.wait_for_done() # get params from config.json cdj = json.loads(open("config.json").read())["parameters"] # I don't use most of these yet, but they're pretty standard boilerplate for SFTs start_time = cdj["Start_Time"] lines = [] timestep = start_time with open("test.txt") as logfile: for line in logfile: if "Update(): Time:" in line: # calculate time step timestep += 1 # This test uses the PropertyReport not stdout. prt_json = json.loads( open( "output/PropertyReportTyphoid.json" ).read() ) geographic_zones = [ "A", "B", "C", "D", "E", "F", "G", "H", "I" ]
def application( output_folder="output", stdout_filename="test.txt", report_event_recorder="ReportNodeEventRecorder.csv", config_filename="config.json", campaign_filename="campaign.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename+ "\n") print("report_event_recorder: " + report_event_recorder+ "\n") print("config_filename: " + config_filename + "\n") print("campaign_filename: " + campaign_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done(stdout_filename) config_obj = General_Support.load_config_parameters(config_filename, Diagnostic_Support.config_keys, debug) campaign_obj = Diagnostic_Support.load_campaign_file(campaign_filename, debug) stdout_df = Diagnostic_Support.parse_stdout_file(stdout_filename, config_obj[ConfigKeys.Simulation_Timestep], debug) recorder_obj = Diagnostic_Support.parse_report_event_recorder(output_folder, report_event_recorder, debug) create_report_file(config_obj, campaign_obj, stdout_df, recorder_obj, report_name, report_event_recorder, debug)
def application(output_folder="output", config_filename="config.json", jsonreport_name="InsetChart.json", stdout_filename="test.txt", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + jsonreport_name + "\n") print("stdout filename:" + stdout_filename + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") sft.wait_for_done() config_object = dtk_iis.load_config_file(config_filename=config_filename, debug=debug) demographics_overlay_name = config_object[dtk_iis.ConfigKeys.DEMOGRAPHIC_FILENAMES][-1] campaign_name = config_object[dtk_iis.ConfigKeys.CAMPAIGN_FILENAME] test_config_name = config_object[dtk_iis.ConfigKeys.CONFIG_NAME] demographics_object = dtk_iis.load_demographics_file( demographics_filename=demographics_overlay_name, susceptibility_initialization_type=config_object[dtk_iis.ConfigKeys.SUS_INIT_DIST_TYPE], debug=debug) sft.start_report_file(report_name, test_config_name) i_df = dtk_iis.parse_stdout_file(stdout_filename, debug=debug) distribution_object = demographics_object[dtk_iis.DemographicFileKeys.SusceptibilityDistribution.KEY] distro_values = \ distribution_object[dtk_iis.DemographicFileKeys.SusceptibilityDistribution.ComplexKeys.DistributionValues][0] distro_results = \ distribution_object[dtk_iis.DemographicFileKeys.SusceptibilityDistribution.ComplexKeys.ResultValues][0] if debug: print("Sus distribution type: {0}\n".format(config_object[dtk_iis.ConfigKeys.SUS_INIT_DIST_TYPE])) print("Distribution object: {0}\n".format(distribution_object)) print("Distro values: {0}\n".format(distro_values)) with open(report_name, "a") as outfile: messages = dtk_iis.validate_complex_initialization_numpy( individual_dataframe=i_df, susceptibility_distribution=distribution_object, outfile=outfile, debug=debug) pass
def application(output_folder="output", config_filename="config.json", campaign_filename="campaign.json", demographics_filename="demographics_100_overlay.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("config_filename: " + config_filename+"\n") print("campaign_filename: " + campaign_filename+"\n") print("demographics_filename: " + demographics_filename+"\n") print("insetchart_name: " + insetchart_name+"\n") print("report_name: " + report_name+"\n") print("debug: " + str(debug)+"\n") sft.wait_for_done() param_obj = ips.load_emod_parameters(config_filename, debug) campaign_obj = ips.load_campaign_file(param_obj[KEY_CAMPAIGN_NAME], debug) demographics_obj = ips.load_demographics_file(param_obj[KEY_DEMOGRAPHICS_NAME][-1], debug) report_data_obj = ips.parse_json_report(output_folder, insetchart_name, debug) sft.plot_data(report_data_obj[KEY_NEW_INFECTIONS], title="new infections", label1="New Infections", label2="NA", xlabel="time steps", ylabel="new infection", category='New_infections', show=True) sft.plot_data(report_data_obj[KEY_STATISTICAL_POPULATION], title="Statistical Population", label1="Statistical Population", label2="NA", xlabel="time steps", ylabel="Statistical Population", category='Statistical_population', show=True, line=True) ips.create_report_file(param_obj, campaign_obj, demographics_obj, report_data_obj, report_name, debug)
def application(output_folder="output", stdout_filename="test.txt", config_filename="config.json", insetchart_name="InsetChart.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: " + output_folder) print("stdout_filename: " + stdout_filename + "\n") print("config_filename: " + config_filename + "\n") print("insetchart_name: " + insetchart_name + "\n") print("report_name: " + report_name + "\n") print("debug: " + str(debug) + "\n") print("current dir = " + os.getcwd()) sft.wait_for_done() param_obj, config_json = MM_Support.load_emod_parameters(config_filename) if debug: print (param_obj) node_demog_df, human_migration_df = MM_Support.parse_output_files("output/ReportNodeDemographics.csv", "output/ReportHumanMigrationTracking.csv", debug) # for local testing # node_demo_df, human_migration_df = MM_Support.parse_output_files("ReportNodeDemographics.csv", "ReportHumanMigrationTracking.csv", debug) MM_Support.create_report_file_stationary_distribution(param_obj, node_demog_df, report_name, debug)
def application(output_folder="output", config_filename="config.json", report_name=sft.sft_output_filename, debug=False): if debug: print("output_folder: {0}".format(output_folder)) print("config_filename: {0}".format(config_filename)) print("report_name: {0}".format(report_name)) print("debug: {0}".format(debug)) config_object = d_ss.load_config_file(config_filename=config_filename, debug=debug) sft.start_report_file(output_filename=report_name, config_name=config_object[d_ss.ConfigKeys.CONFIGNAME_KEY], already_started=True) sft.wait_for_done() dtk_filename = path.join(output_folder, 'state-00005.dtk') dtk_file = d_ss.DtkFile(dtk_filename) dtk_file.write_node_to_disk(node_index=0) dtk_file.write_simulation_to_disk() infected_people_to_check = [] with open("DEBUG_found_infected_persons.json") as infile: infected_people_to_check = json.load(infile) if debug: print(f"Infected_people_to_check: {infected_people_to_check}") infected_people_first={} infected_people_second={} for suid in infected_people_to_check: suid_int = int(suid) print("Trying suid: {0}".format(suid_int)) infected_people_first[suid] = d_ss.SerializedHuman.from_file(f"human-{suid_int}-old.json") dtk_file.write_human_to_disk(node_index=0, suid=suid_int, debug=debug) infected_people_second[suid] = d_ss.SerializedHuman.from_file(f"human-{suid_int}-new.json") # Make sure each individual is Simulation_Duration days older messages = [] expected_age_delta = config_object[d_ss.ConfigKeys.Serialization.TIMESTEPS_KEY][0] for person in infected_people_to_check: infection_suid = infected_people_to_check[person] if debug: # print(f"X is: {x}") print(f"person is: {person}") print(f"infection is: {infection_suid}") print(f"infected_people_first[person] = {infected_people_first[person]}") print(f"infected_people_second[person] = {infected_people_second[person]}") aging_messages = infected_people_first[person].compare_to_older(infected_people_second[person], expected_age_delta) messages += aging_messages if aging_messages else [f"GOOD: human {person} checks out"] older_infection = infected_people_first[person].get_infection_by_suid(infection_suid) newer_infection = infected_people_second[person].get_infection_by_suid(infection_suid) messages += newer_infection.compare_to_older(older_infection, expected_age_delta) messages += newer_infection.validate_own_timers() # Make sure each infection is Simulation_Duration days older #TODO: compare the simulation objects #TODO: compare the node objects success_message_formatter = sft.format_success_msg d_ss.generate_report_file(config_object, report_name, output_folder=output_folder, messages=messages, success_formatter=success_message_formatter, debug=debug) d_ss.clean_serialization_test(debug)