Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename portfolio to cluster recovery #569

Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [Unreleased]

### Changed
- Rename Building Portfolio Analysis to Building Cluster Recovery Analysis [#559](https://github.com/IN-CORE/pyincore/issues/559)


## [1.18.1] - 2024-04-30

### Changed
Expand Down
10 changes: 10 additions & 0 deletions pyincore/analyses/buildingclusterrecovery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2018 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/


from pyincore.analyses.buildingclusterrecovery.buildingclusterrecovery import BuildingClusterRecovery
from pyincore.analyses.buildingclusterrecovery.buildingdamage import BuildingDamage
from pyincore.analyses.buildingclusterrecovery.buildingdata import BuildingData
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright (c) 2018 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/
Expand All @@ -10,11 +12,11 @@
import scipy.stats
import concurrent.futures

from pyincore.analyses.buildingportfolio.BuildingData import BuildingData
from pyincore.analyses.buildingclusterrecovery.buildingdata import BuildingData
from pyincore import BaseAnalysis, Dataset


class BuildingPortfolioRecoveryAnalysis(BaseAnalysis):
class BuildingClusterRecovery(BaseAnalysis):
"""The Building Portfolio Recovery analysis uses damage probabilities of structural components,
nonstructural drift-sensitive components, and nonstructural acceleration-sensitive components
to calculate building’s initial functionality loss.
Expand All @@ -24,12 +26,12 @@ class BuildingPortfolioRecoveryAnalysis(BaseAnalysis):

"""
def __init__(self, incore_client):
super(BuildingPortfolioRecoveryAnalysis, self).__init__(incore_client)
super(BuildingClusterRecovery, self).__init__(incore_client)

def get_spec(self):
return {
'name': 'building-portfolio-damage-analysis',
'description': 'Building Portfolio Damage Analysis (with uncertainty)',
'name': 'building-cluster-recovery-analysis',
'description': 'Building Cluster Recovery Analysis (with uncertainty)',
'input_parameters': [
{
'id': 'result_name',
Expand Down Expand Up @@ -116,9 +118,9 @@ def get_spec(self):
'output_datasets': [
{
'id': 'result',
'parent_type': 'buildingPortfolio',
'description': 'Building portfolio recovery result.',
'type': 'incore:portfolioRecovery'
'parent_type': 'buildingClusterRecovery',
'description': 'Building cluster recovery result.',
'type': 'incore:clusterRecovery'
}
]
}
Expand Down Expand Up @@ -343,7 +345,7 @@ def run(self):
upper_bound95[t] = 1

# END: Additional Code for uncertainty Analysis
with open(output_base_name + '_portfolio-recovery.csv', 'w+', newline='') as output_file:
with open(output_base_name + '_cluster-recovery.csv', 'w+', newline='') as output_file:
spam_writer = csv.writer(output_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
spam_writer.writerow(['Week', 'Recovery_Percent_Func_Probability', '75P_Upper_Bound',
'75P_Lower_Bound', '95P_Upper_Bound', '95P_Lower_Bound',
Expand All @@ -354,14 +356,14 @@ def run(self):
lower_bound95[i], upper_bound95[i]] + list(mean_recovery[i]) +
[pdf[i]])
else:
with open(output_base_name + '_portfolio-recovery.csv', 'w+', newline='') as output_file:
with open(output_base_name + '_cluster-recovery.csv', 'w+', newline='') as output_file:
spam_writer = csv.writer(output_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
spam_writer.writerow(['Week', 'Recovery_Percent_Func_Probability', 'RecPercent_RE',
'RecPercent_RU', 'RecPercent_RO', 'RecPercent_BF', 'RecPercent_FF'])
for i in range(time_steps):
spam_writer.writerow([i + 1, mean_recovery_output[i]] + list(mean_recovery[i]))

self.set_output_dataset("result", Dataset.from_file(output_base_name + '_portfolio-recovery.csv',
self.set_output_dataset("result", Dataset.from_file(output_base_name + '_cluster-recovery.csv',
data_type=self.output_datasets["result"]["spec"]["type"]))

print("INFO: Finished executing Building Portfolio Recovery Analysis")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Copyright (c) 2018 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/


class BuildingDamage(object):

def __init__(self, distance_to_center, restricted_entry, restricted_use, reoccupancy, best_line_functionality,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Copyright (c) 2018 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/


class BuildingData:
def __init__(self, tract_id, lon, lat, structural, code_level, epsa_node_id, pwsa_node_id, tep_id, build_id_x,
epsa_id, pwsa_id, finance, ep_pw_id, occupation_code):
Expand Down
3 changes: 0 additions & 3 deletions pyincore/analyses/buildingportfolio/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/


from pyincore.analyses.buildingclusterrecovery import BuildingClusterRecovery
from pyincore import IncoreClient
import pyincore.globals as pyglobals

if __name__ == "__main__":
cred = None
try:
client = IncoreClient(pyglobals.INCORE_API_PROD_URL)
bldg_data_dataset = "5c756966c11bb369a33a0b0a"
occupancy_dataset = "5c7569f9c11bb369a33a0b16"
bldg_damage_dataset = "5c756a2fc11bb369a33a0b22"
mean_repair_dataset = "5c756ac5c11bb369a33a0b34"
utility_dataset = "5c756af4c11bb369a33a0b40"
utility_partial_dataset = "5c756b1ec11bb369a33a0b4c"
coefFL_dataset = "5c756b56c11bb369a33a0b58"

bldg_cluster_recovery = BuildingClusterRecovery(client)
bldg_cluster_recovery.set_parameter("uncertainty", True)
bldg_cluster_recovery.set_parameter("sample_size", 35) # default none. Gets size form input dataset
bldg_cluster_recovery.set_parameter("random_sample_size", 50) # default 10000
bldg_cluster_recovery.set_parameter("no_of_weeks", 100) # default 250
bldg_cluster_recovery.set_parameter("num_cpu", 1)
bldg_cluster_recovery.set_parameter("result_name", "memphis")

bldg_cluster_recovery.load_remote_input_dataset("building_data", bldg_data_dataset)
bldg_cluster_recovery.load_remote_input_dataset("occupancy_mapping", occupancy_dataset)
bldg_cluster_recovery.load_remote_input_dataset("building_damage", bldg_damage_dataset)
bldg_cluster_recovery.load_remote_input_dataset("dmg_ratios", mean_repair_dataset)
bldg_cluster_recovery.load_remote_input_dataset("utility", utility_dataset)
bldg_cluster_recovery.load_remote_input_dataset("utility_partial", utility_partial_dataset)
bldg_cluster_recovery.load_remote_input_dataset("coefFL", coefFL_dataset)

bldg_cluster_recovery.run_analysis()
print(bldg_cluster_recovery.get_output_dataset("result").get_dataframe_from_csv().head())

except EnvironmentError:
raise
# traceback.print_exc()

This file was deleted.

Loading