Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/atc138/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def main():
parser = argparse.ArgumentParser(description="Run ATC-138 Functional Recovery Assessment")
parser.add_argument("input_dir", help="Path to the directory containing input files (e.g., simulated_inputs.json)")
parser.add_argument("output_dir", help="Path to the directory where outputs will be saved")
parser.add_argument("--output_file", type=str, help="String to name output file (default recovery_outputs.json)", default="recovery_outputs.json")
parser.add_argument("--seed", type=int, help="Random seed for reproducibility", default=None)
parser.add_argument("--force_rebuild", action="store_true", help="Flag to force override of simulated_inputs.json and rebuild", default=False)

Expand All @@ -18,7 +19,7 @@ def main():
sys.exit(1)

try:
run_analysis(args.input_dir, args.output_dir, seed=args.seed, force_rebuild=args.force_rebuild)
run_analysis(args.input_dir, args.output_dir, output_file=args.output_file, seed=args.seed, force_rebuild=args.force_rebuild)
except Exception as e:
print(f"Error running analysis: {e}", file=sys.stderr)
sys.exit(1)
Expand Down
9 changes: 7 additions & 2 deletions src/atc138/driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
def run_analysis(input_dir, output_dir, seed=None, force_rebuild=False):
def run_analysis(input_dir, output_dir,
output_file='recovery_outputs.json',
seed=None, force_rebuild=False):

'''This script facilitates the performance based functional recovery and
reoccupancy assessment of a single building for a single intensity level
Expand All @@ -20,6 +22,9 @@ def run_analysis(input_dir, output_dir, seed=None, force_rebuild=False):

output_dir: string
Path to the directory where the output file (recovery_outputs.json) will be saved.

output_file: string
Name the output file as specified. Default name is 'recovery_outputs.json'.

seed: int
Random seed to be passed to the Numpy random engine. Default behavior
Expand Down Expand Up @@ -191,7 +196,7 @@ def run_analysis(input_dir, output_dir, seed=None, force_rebuild=False):

output_json_object = json.dumps(functionality)

with open(os.path.join(output_dir, "recovery_outputs.json"), "w") as outfile:
with open(os.path.join(output_dir, output_file), "w") as outfile:
outfile.write(output_json_object)

end_time = time.time()
Expand Down
4 changes: 2 additions & 2 deletions src/atc138/functionality/other_functionality_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def fn_building_safety(damage, building_model, damage_consequences, utilities,
recovery_day['fire_suppression'] = np.fmax(recovery_day['fire_suppression'], np.amax(repair_complete_day[:,damage['fnc_filters']['fire_building']], axis=1))

# Consider utilities (assume no backup water supply)
recovery_day['fire_suppression'] = np.fmax(recovery_day['building']['fire'], np.array(utilities['water'])) # Assumes building does not have backup water supply
recovery_day['fire_suppression'] = np.fmax(recovery_day['fire_suppression'], np.array(utilities['water'])) # Assumes building does not have backup water supply

# Componet Breakdowns
comp_breakdowns['fire_suppression'][:,:,tu] = damage['fnc_filters']['fire_building'] * repair_complete_day
Expand Down Expand Up @@ -297,7 +297,7 @@ def fn_building_safety(damage, building_model, damage_consequences, utilities,
# Add days to components that are affecting occupancy
contributing_drops = ((damaged_comps * filt_fs_drop) > 0) * np.logical_not(fire_drop_operational).reshape(num_reals,1) #count all components that contributed to non operational fire drops
contributing_branches = ((damaged_comps * filt_fs_drop) > 0) * np.logical_not(fire_branch_operational).reshape(num_reals,1) # count all components that contributed to non operational fire drops
contributing_comps = np.amax(contributing_drops, contributing_branches)
contributing_comps = np.fmax(contributing_drops, contributing_branches)
comp_breakdowns_local_fire[:,:,tu] = comp_breakdowns_local_fire[:,:,tu] + contributing_comps * delta_day.reshape(num_reals,1)

# Change the comps for the next increment
Expand Down