# Population dislocation result aggregated to the block group level.
# Transition probability matrix per social vulnerability level.
transition_probability_matrix = "60f5e2ae544e944c3cec0794"
# Initial mass probability function for stage 0.
initial_probability_vector = "60f5e918544e944c3cec668b"
# Create housing recovery instance
housing_recovery = HousingRecoverySequential(client)
# Load input datasets
for keys, values in hhrs_dislocation_dataset_names.items():
housing_recovery.set_input_dataset("population_dislocation_block", values)
housing_recovery.load_remote_input_dataset("tpm", transition_probability_matrix)
housing_recovery.load_remote_input_dataset("initial_stage_probabilities", initial_probability_vector)
# Chain with SV output
housing_recovery.set_input_dataset('sv_result', sv_result)
# Initial value to seed the random number generator to ensure replication
seed = 1111
# A size of the analysis time step.
t_delta = 1.0
# Total duration.
t_final = 90.0
# Specify the result name
result_name = f"housing_recovery_result_{keys}"
# Set analysis parameters
housing_recovery.set_parameter("result_name", result_name)
housing_recovery.set_parameter("seed", seed)
housing_recovery.set_parameter("t_delta", t_delta)
housing_recovery.set_parameter("t_final", t_final)
housing_recovery.set_parameter("num_cpu", 8)
housing_recovery.run()
result = housing_recovery.get_output_dataset("ds_result")
hh_stagehistory_df = result.get_dataframe_from_csv()
#timesteps = ["1", "7", "13", "25", "85"] # t0, t6, t12, t24, t84
timesteps = ["1", "2", "3", "4", "5", "6", "7", "13", "25", "37", "49", "61", "73", "85"]
HHRSOutputProcess.get_hhrs_stage_count(timesteps, hh_stagehistory_df,
filename_json=f"hhrs_stage_count_{keys}.json")
8.1 Social vulnerabilities#