Skip to content

Commit

Permalink
Spell-check performREC/pyrecodes, exclude from ruff lint and format t…
Browse files Browse the repository at this point in the history
…emporarily
  • Loading branch information
JustinBonus committed Jan 21, 2025
1 parent 4df9bcf commit 450f4d0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
# calculate_road_capacity,
# )

## The below functions are mannually copied from brails to avoid importing brails
## The below functions are manually copied from brails to avoid importing brails

ROADLANES_MAP = {'S1100': 4, "S1200": 2, "S1400": 1, "S1500": 1, "S1630": 1,
"S1640": 1, "S1710": 1, "S1720": 1, "S1730": 1, "S1740": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def set_new_demand(self, state):
node_new_demand = 0

for bldg_id in building_name_list:
# Nikola: We take the demand directly from the buidling general information, not based on population ratio.
# Nikola: We take the demand directly from the building general information, not based on population ratio.
# cur_bldg_initial_demand = self.buildings[bldg_id]['initial_demand']

# cur_bldg_deamnd_ratio = building[bldg_id]['GeneralInformation'][
Expand Down
20 changes: 10 additions & 10 deletions modules/performREC/pyrecodes/run_pyrecodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ def run_one_realization(main_file, rlz, rwhale_run_dir, system_config):
if 'PotableWater' in system_config['Resources']:
resources_to_plot.append('PotableWater')
units_to_plot.append(system_config['Resources']['PotableWater'].get('Unit', 'unit_PotableWater'))
for recource, unit in zip(resources_to_plot, units_to_plot):
y_axis_label = f'{recource} {unit} | {system.resilience_calculators[0].scope}'
for resource, unit in zip(resources_to_plot, units_to_plot):
y_axis_label = f'{resource} {unit} | {system.resilience_calculators[0].scope}'
x_axis_label = 'Time step [day]'
axis_object = plotter_object.setup_lor_plot_fig(x_axis_label, y_axis_label)
time_range = system.time_step+1
time_steps_before_event = 10
plotter_object.plot_single_resource(list(range(-time_steps_before_event, time_range)), system.resilience_calculators[0].system_supply[recource][:time_range],
system.resilience_calculators[0].system_demand[recource][:time_range],
system.resilience_calculators[0].system_consumption[recource][:time_range], axis_object, warmup=time_steps_before_event,
plotter_object.plot_single_resource(list(range(-time_steps_before_event, time_range)), system.resilience_calculators[0].system_supply[resource][:time_range],
system.resilience_calculators[0].system_demand[resource][:time_range],
system.resilience_calculators[0].system_consumption[resource][:time_range], axis_object, warmup=time_steps_before_event,
show = False
)
plotter_object.save_current_figure(savename = f'{recource}_supply_demand_consumption.png')
plotter_object.save_current_figure(savename = f'{resource}_supply_demand_consumption.png')
return True

def modify_system_config_conent(system_config, input_data_dir, rwhale_run_dir):
Expand Down Expand Up @@ -395,7 +395,7 @@ def run_pyrecodes( # noqa: C901
with Path(system_config_file).open() as f:
system_config = json.load(f)

# Modify the file pathes in the Content part of the system configuration
# Modify the file paths in the Content part of the system configuration
system_config = modify_system_config_conent(system_config, input_data_dir,
run_dir)

Expand Down Expand Up @@ -461,15 +461,15 @@ def run_pyrecodes( # noqa: C901
if 'Loss' in asset_id_dict:
loss_dist = asset_id_dict['Loss']
for comp in loss_dist['Repair']['Cost']:
# A minmum cost of 0.00001 is set to avoid division by zero
# A minimum cost of 0.00001 is set to avoid division by zero
loss_dist['Repair']['Cost'][comp] = max(loss_dist['Repair']['Cost'][comp], 0.00001)
for comp in loss_dist['Repair']['Time']:
# A minmum time of 0.00001 is set to avoid division by zero
# A minimum time of 0.00001 is set to avoid division by zero
loss_dist['Repair']['Time'][comp] = max(loss_dist['Repair']['Time'][comp], 0.00001)
with Path(run_dir / f'Results_{rlz}.json').open('w') as f:
json.dump(results_rlz, f)

# Modify the file pathes in the REWETDistributionModel part of the system configuration
# Modify the file paths in the REWETDistributionModel part of the system configuration
system_config = modify_system_config_rewet_distribution(system_config, input_data_dir, rlz_run_dir)
system_config = modify_system_config_residual_demand_distribution(system_config, input_data_dir, rlz_run_dir)
# Write the modified system configuration to a file
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ line-length = 85
#
# - JustinBonus, 2025-01-20
extend-exclude = ["modules/createEVENT/TaichiEvent",
"modules/performREC/pyrecodes",
"modules/performRegionalEventSimulation/regionalGroundMotion",
"modules/performSIMULATION/capacitySpectrum",
"modules/Workflow/whale/main.py",
Expand Down

0 comments on commit 450f4d0

Please sign in to comment.