Hopefully fix transmission reinforcement bug
@@ -10,7 +10,11 @@ import pandas as pd
import powergenome
from powergenome.fuels import fuel_cost_table
-from powergenome.generators import GeneratorClusters, load_ipm_shapefile
+from powergenome.generators import (
+ GeneratorClusters,
+ load_ipm_shapefile,
+ add_fuel_labels,
+)
from powergenome.GenX import (
add_emission_policies,
make_genx_settings_file,
@@ -280,6 +284,7 @@ def main():
scenario_settings = build_scenario_settings(settings, scenario_definitions)
i = 0
+ model_regions_gdf = None
for year in scenario_settings.keys():
for case_id, _settings in scenario_settings[year].items():
case_folder = (
@@ -354,25 +359,25 @@ def main():
# )
i += 1
- if args.transmission:
- if args.gens is False:
- model_regions_gdf = load_ipm_shapefile(_settings)
- else:
- model_regions_gdf = gc.model_regions_gdf
- transmission = agg_transmission_constraints(
- pudl_engine=pudl_engine, settings=_settings
- )
- transmission = (
- transmission.pipe(
- transmission_line_distance,
- ipm_shapefile=model_regions_gdf,
- settings=_settings,
- units="mile",
- )
- .pipe(network_line_loss, settings=_settings)
- .pipe(network_max_reinforcement, settings=_settings)
- .pipe(network_reinforcement_cost, settings=_settings)
- )
+ # if args.transmission:
+ # if args.gens is False:
+ # model_regions_gdf = load_ipm_shapefile(_settings)
+ # else:
+ # model_regions_gdf = gc.model_regions_gdf
+ # transmission = agg_transmission_constraints(
+ # pudl_engine=pudl_engine, settings=_settings
+ # )
+ # transmission = (
+ # transmission.pipe(
+ # transmission_line_distance,
+ # ipm_shapefile=model_regions_gdf,
+ # settings=_settings,
+ # units="mile",
+ # )
+ # .pipe(network_line_loss, settings=_settings)
+ # .pipe(network_max_reinforcement, settings=_settings)
+ # .pipe(network_reinforcement_cost, settings=_settings)
+ # )
genx_settings = make_genx_settings_file(pudl_engine, _settings)
write_case_settings_file(
@@ -457,6 +462,25 @@ def main():
)
if args.transmission:
+ if not model_regions_gdf:
+ if args.gens is False:
+ model_regions_gdf = load_ipm_shapefile(_settings)
+ else:
+ model_regions_gdf = gc.model_regions_gdf
+ transmission = agg_transmission_constraints(
+ pudl_engine=pudl_engine, settings=_settings
+ )
+ transmission = (
+ transmission.pipe(
+ transmission_line_distance,
+ ipm_shapefile=model_regions_gdf,
+ settings=_settings,
+ units="mile",
+ )
+ .pipe(network_line_loss, settings=_settings)
+ .pipe(network_max_reinforcement, settings=_settings)
+ .pipe(network_reinforcement_cost, settings=_settings)
+ )
network = add_emission_policies(transmission, _settings)
write_results_file(
df=network,
