Skip to content
Open
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
8 changes: 4 additions & 4 deletions exogenous_canadian_trade/Canadian_import_export_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Canada_Projection_FN = 'Electricity_Interchange.xlsx' # From https://apps.cer-rec.gc.ca/ftrppndc/dflt.aspx?GoCTemplateCulture=en-CA

# Ensure the headers for the provinces match the excel file
Province_header_dict = {'Newfoundland and Labrador':6,
Province_header_dict = {'Newfoundland and Labrador':15,
'Prince Edward Island':24,
'Nova Scotia':33,
'New Brunswick':42,
Expand Down Expand Up @@ -70,7 +70,7 @@
Import_Season_Fractions.sort_values(by = 'order',inplace = True)
Import_Season_Fractions.drop('order',axis = 1, inplace = True)
Import_Season_Fractions.columns = ['*szn','frac']
Import_Season_Fractions.round(4).to_csv(os.path.join(Output_folder, 'can_imports_quarter_frac.csv'), index = False)
Import_Season_Fractions.round(5).to_csv(os.path.join(Output_folder, 'can_imports_quarter_frac.csv'), index = False)

# generating the Exports season fractions from available years
Export_Season_Fractions = pd.DataFrame(pd.pivot_table(Historical, values = ['Export_Month_Fraction'], index = 'Season', aggfunc = 'sum'))
Expand All @@ -81,7 +81,7 @@
Export_Season_Fractions.sort_values(by = 'order',inplace = True)
Export_Season_Fractions.drop('order',axis = 1, inplace = True)
Export_Season_Fractions.columns = ['*szn','frac']
Export_Season_Fractions.round(4).to_csv(os.path.join(Output_folder, 'can_exports_szn_frac.csv'), index = False)
Export_Season_Fractions.round(5).to_csv(os.path.join(Output_folder, 'can_exports_szn_frac.csv'), index = False)


########################################
Expand Down Expand Up @@ -151,4 +151,4 @@

Imports.round(1).to_csv(os.path.join(Output_folder, 'can_imports.csv'))

print(f"Run complete. See outputs folder for outputs which are inputs to ReEDS.")
print(f"Run complete. See the '{Output_folder}' directory for outputs.")
3 changes: 3 additions & 0 deletions exogenous_canadian_trade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Option 2 has been deprecated in the current version of ReEDS (2024.4.0), so the
To update the province-to-county map:
- Download the "Border Crossings - Electric Transmission Line" dataset from the EIA: https://www.eia.gov/trilateral/#!/maps.
- Move and rename the file to "data/raw_inputs/EIA_trilateral_lines.csv".
- If there are known lines that are not included in the EIA dataset, add them to "data/raw_inputs/manual_usa_can_lines.csv".
- Run process_eia_lines.py to create "data/EIA_usa_can_lines.csv".

- Download the "Sheet 1" Excel file from the Canadian government's "International Power Lines" dashboard: https://www.cer-rec.gc.ca/en/data-analysis/facilities-we-regulate/international-power-lines-dashboard/.
Expand All @@ -37,3 +38,5 @@ To update the province-to-county map:
-- In cases where the U.S. state listed in the datasets do not match, we use EIA's provided location, as it has county-level information.

- Run create_province_to_county_map.py in the "Exogenous_Canadian_Trade" directory.

Note: The entry of "data/raw_inputs/CER_usa_can_lines.xlsx" corresponding to the CHPE Quebec-New York City line (https://chpexpress.com/construction/), which has original regulatory instrument ID "EP-306", was updated manually to change its status from "Approved" to "Operating" because the line's completion was not reflected in the CER dataset at the time of writing (August 2026).
21 changes: 11 additions & 10 deletions exogenous_canadian_trade/create_province_to_county_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

import pandas as pd
import json
import sys

reeds_path = '' # User should specify path to ReEDS repository here
sys.path.append(reeds_path)
import reeds


def get_line_data(line_id_certificate_map):
Expand Down Expand Up @@ -58,24 +63,20 @@ def main():
)
county_capacities = county_capacities.loc[county_capacities.Capacity > 0].copy()

# Rename counties to match ReEDS counties file and merge to get corresponding pFIPS
reeds_counties = pd.read_excel(
'../Region_Disaggregation/processing_scripts/county_reeds_corrected0310.xlsx',
header=0,
usecols=['NAME','STATE_NAME','pFIPS']
)
# Rename counties to match ReEDS counties file and merge to get corresponding FIPS code
reeds_counties = reeds.io.get_countymap()[['NAME', 'STATE', 'rb']]
county_capacities['County'] = county_capacities['County'].str.replace('Saint', 'St.')
assert (
len(reeds_counties.loc[reeds_counties.NAME.isin(county_capacities.County)].NAME.unique())
== len(county_capacities.County.sort_values().unique())
)
county_capacities = (
county_capacities.merge(
reeds_counties[['NAME', 'STATE_NAME', 'pFIPS']],
reeds_counties,
left_on=['County', 'State'],
right_on=['NAME', 'STATE_NAME']
right_on=['NAME', 'STATE']
)
[['Province', 'pFIPS', 'Capacity']]
[['Province', 'rb', 'Capacity']]
)

# Calculate proportion of each province's transmission capacity going to each county
Expand All @@ -87,7 +88,7 @@ def main():
province_to_county_map = pd.pivot_table(
county_capacities,
index='Province',
columns='pFIPS',
columns='rb',
values='proportion_of_province_capacity'
)
assert(all(province_to_county_map.sum(axis=1) == 1))
Expand Down
1 change: 1 addition & 0 deletions exogenous_canadian_trade/data/EIA_usa_can_lines.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Ontario,Minnesota,Hydro One Networks Inc.,Fort Frances IPL_115,Fort Frances,Inte
Ontario,Michigan,Hydro One Networks Inc.,Sarnia Scott-Bunce Creek B3N IPL_230,FroomField,Marysville,Saint Clair,230.0,1,FroomField-Marysville_230
Ontario,Michigan,Hydro One Networks Inc.,Lambton-St. Clair L51D IPL_235,Courtright,St. Claire,Saint Clair,235.0,1,Courtright-St. Claire_235
Ontario,Michigan,Hydro One Networks Inc.,Lambton-St. Clair L4D IPL_345,Courtright,St. Claire,Saint Clair,345.0,1,Courtright-St. Claire_345
Quebec,New York,Quebec Hydro - Hydro-Quebec,CHPE_400,Hertel,Astoria Annex,Queens,400.0,1,Hertel-Astoria Annex_400
3 changes: 3 additions & 0 deletions exogenous_canadian_trade/data/line_id_certificate_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@
],
"Courtright-St. Claire_345": [
"EC-III-6"
],
"Hertel-Astoria Annex_400": [
"EP-306"
]
}
16 changes: 8 additions & 8 deletions exogenous_canadian_trade/data/province_to_county_map.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Province,p23003,p26147,p26163,p27071,p27135,p30035,p36063,p36089,p38023,p38079,p50009,p50011,p50019,p53051,p53073
Alberta,,,,,,1.0,,,,,,,,,
British Columbia,,,,,,,,,,,,,,0.24324324324324326,0.7567567567567568
Manitoba,,,,,0.5694294940796556,,,,,0.43057050592034446,,,,,
New Brunswick,1.0,,,,,,,,,,,,,,
Ontario,,0.363659401926001,0.14445007602635582,0.03801317790167258,,,0.4538773441459706,,,,,,,,
Quebec,,,,,,,,0.7092198581560284,,,0.19574468085106383,0.06382978723404255,0.031205673758865248,,
Saskatchewan,,,,,,,,,1.0,,,,,,
Province,p23003,p26147,p26163,p27071,p27135,p30035,p36063,p36081,p36089,p38023,p38079,p50009,p50011,p50019,p53051,p53073
Alberta,,,,,,1.0,,,,,,,,,,
British Columbia,,,,,,,,,,,,,,,0.17647058823529413,0.8235294117647058
Manitoba,,,,,0.5694294940796556,,,,,,0.43057050592034446,,,,,
New Brunswick,1.0,,,,,,,,,,,,,,,
Ontario,,0.37654159013382316,0.11414326948307531,0.039359748097612175,,,0.4699553922854894,,,,,,,,,
Quebec,,,,,,,,0.2617801047120419,0.5235602094240838,,,0.14450261780104712,0.04712041884816754,0.023036649214659685,,
Saskatchewan,,,,,,,,,,1.0,,,,,,
Binary file modified exogenous_canadian_trade/data/raw_inputs/CER_usa_can_lines.xlsx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Origin,Destination,Company,LineName,CanadianSite,AmericanSite,County,voltage,num_lines,line_ID
Quebec,New York,Quebec Hydro - Hydro-Quebec,CHPE_400,Hertel,Astoria Annex,Queens,400,1,Hertel-Astoria Annex_400
4 changes: 4 additions & 0 deletions exogenous_canadian_trade/process_eia_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def main():
)
df_eia['LineName'] = df_eia.LineName + '_' + df_eia.voltage.astype(int).astype(str)

# Append manually specified lines that aren't included in the EIA dataset
df_manual = pd.read_csv("data/raw_inputs/manual_usa_can_lines.csv")
df_eia = pd.concat([df_eia, df_manual], ignore_index=True)

out_fpath = "data/EIA_usa_can_lines.csv"
df_eia.to_csv(out_fpath, index=False)
print(f"Run complete. See {out_fpath} for outputs.")
Expand Down