Skip to content

Commit

Permalink
Manual formatting of DataFrame definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannis-vm committed Oct 24, 2024
1 parent ba9b0c2 commit bd69d61
Showing 1 changed file with 42 additions and 50 deletions.
92 changes: 42 additions & 50 deletions pelicun/resources/auto/Hazus_Earthquake_IM.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,12 @@ def auto_populate(aim): # noqa: C901
else:
lf = f'LF.{bt}.{dl}'

comp = pd.DataFrame(
{f'{lf}': ['ea', 1, 1, 1, 'N/A']},
index=['Units', 'Location', 'Direction', 'Theta_0', 'Family'],
).T
# fmt: off
comp = pd.DataFrame( # noqa
{f'{LF}': ['ea', 1, 1, 1, 'N/A']}, # noqa
index = ['Units','Location','Direction','Theta_0','Family'] # noqa
).T # noqa
# fmt: on

# if needed, add components to simulate damage from ground failure
if ground_failure:
Expand All @@ -363,15 +365,15 @@ def auto_populate(aim): # noqa: C901
fg_gf_h = f'GF.H.{foundation_type}'
fg_gf_v = f'GF.V.{foundation_type}'

CMP_GF = pd.DataFrame(
{
f'{fg_gf_h}': ['ea', 1, 1, 1, 'N/A'],
f'{fg_gf_v}': ['ea', 1, 3, 1, 'N/A'],
},
index=['Units', 'Location', 'Direction', 'Theta_0', 'Family'],
).T
# fmt: off
comp_gf = pd.DataFrame( # noqa
{f'{FG_GF_H}':[ 'ea', 1, 1, 1, 'N/A'], # noqa
f'{FG_GF_V}':[ 'ea', 1, 3, 1, 'N/A']}, # noqa
index = [ 'Units','Location','Direction','Theta_0','Family'] # noqa
).T # noqa
# fmt: on

comp = pd.concat([comp, CMP_GF], axis=0)
comp = pd.concat([comp, comp_gf], axis=0)

# set the number of stories to 1
# there is only one component in a building-level resolution
Expand Down Expand Up @@ -412,13 +414,13 @@ def auto_populate(aim): # noqa: C901
bt = convertBridgeToHAZUSclass(gi)
gi_ap['BridgeHazusClass'] = bt

comp = pd.DataFrame(
{
f'HWB.GS.{bt[3:]}': ['ea', 1, 1, 1, 'N/A'],
'HWB.GF': ['ea', 1, 1, 1, 'N/A'],
},
index=['Units', 'Location', 'Direction', 'Theta_0', 'Family'],
).T
# fmt: off
comp = pd.DataFrame( # noqa
{f'HWB.GS.{bt[3:]}': [ 'ea', 1, 1, 1, 'N/A'], # noqa
f'HWB.GF': [ 'ea', 1, 1, 1, 'N/A']}, # noqa
index = [ 'Units','Location','Direction','Theta_0','Family'] # noqa
).T # noqa
# fmt: on

dl_ap = {
'Asset': {
Expand All @@ -445,13 +447,13 @@ def auto_populate(aim): # noqa: C901
tt = convertTunnelToHAZUSclass(gi)
gi_ap['TunnelHazusClass'] = tt

comp = pd.DataFrame(
{
f'HTU.GS.{tt[3:]}': ['ea', 1, 1, 1, 'N/A'],
'HTU.GF': ['ea', 1, 1, 1, 'N/A'],
},
index=['Units', 'Location', 'Direction', 'Theta_0', 'Family'],
).T
# fmt: off
comp = pd.DataFrame( # noqa
{f'HTU.GS.{tt[3:]}': [ 'ea', 1, 1, 1, 'N/A'], # noqa
f'HTU.GF': [ 'ea', 1, 1, 1, 'N/A']}, # noqa
index = [ 'Units','Location','Direction','Theta_0','Family'] # noqa
).T # noqa
# fmt: on

dl_ap = {
'Asset': {
Expand All @@ -477,10 +479,12 @@ def auto_populate(aim): # noqa: C901
rt = convertRoadToHAZUSclass(gi)
gi_ap['RoadHazusClass'] = rt

comp = pd.DataFrame(
{f'HRD.GF.{rt[3:]}': ['ea', 1, 1, 1, 'N/A']},
index=['Units', 'Location', 'Direction', 'Theta_0', 'Family'],
).T
# fmt: off
comp = pd.DataFrame( # noqa
{f'HRD.GF.{rt[3:]}':[ 'ea', 1, 1, 1, 'N/A']}, # noqa
index = [ 'Units','Location','Direction','Theta_0','Family'] # noqa
).T # noqa
# fmt: on

dl_ap = {
'Asset': {
Expand Down Expand Up @@ -602,26 +606,14 @@ def auto_populate(aim): # noqa: C901
location_string = f'1--{num_segments}' if num_segments > 1 else '1'

# Define performance model
comp = pd.DataFrame(
{
f'PWP.{pipe_flexibility}.GS': [
'ea',
location_string,
'0',
1,
'N/A',
],
f'PWP.{pipe_flexibility}.GF': [
'ea',
location_string,
'0',
1,
'N/A',
],
'aggregate': ['ea', location_string, '0', 1, 'N/A'],
},
index=['Units', 'Location', 'Direction', 'Theta_0', 'Family'],
).T
# fmt: off
comp = pd.DataFrame( # noqa
{f'PWP.{pipe_flexibility}.GS': ['ea', location_string, '0', 1, 'N/A'], # noqa
f'PWP.{pipe_flexibility}.GF': ['ea', location_string, '0', 1, 'N/A'], # noqa
'aggregate': ['ea', location_string, '0', 1, 'N/A']}, # noqa
index = ['Units','Location','Direction','Theta_0','Family'] # noqa
).T # noqa
# fmt: on

# Set up the demand cloning configuration for the pipe
# segments, if required.
Expand Down

0 comments on commit bd69d61

Please sign in to comment.