diff --git a/exogenous_canadian_trade/Canadian_import_export_formatter.py b/exogenous_canadian_trade/Canadian_import_export_formatter.py index 7e5454d..efc68fd 100644 --- a/exogenous_canadian_trade/Canadian_import_export_formatter.py +++ b/exogenous_canadian_trade/Canadian_import_export_formatter.py @@ -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, @@ -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')) @@ -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) ######################################## @@ -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.") \ No newline at end of file +print(f"Run complete. See the '{Output_folder}' directory for outputs.") \ No newline at end of file diff --git a/exogenous_canadian_trade/README.md b/exogenous_canadian_trade/README.md index 54e264b..8756071 100644 --- a/exogenous_canadian_trade/README.md +++ b/exogenous_canadian_trade/README.md @@ -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/. @@ -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). \ No newline at end of file diff --git a/exogenous_canadian_trade/create_province_to_county_map.py b/exogenous_canadian_trade/create_province_to_county_map.py index 4466b0d..b5df615 100644 --- a/exogenous_canadian_trade/create_province_to_county_map.py +++ b/exogenous_canadian_trade/create_province_to_county_map.py @@ -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): @@ -58,12 +63,8 @@ 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()) @@ -71,11 +72,11 @@ def main(): ) 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 @@ -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)) diff --git a/exogenous_canadian_trade/data/EIA_usa_can_lines.csv b/exogenous_canadian_trade/data/EIA_usa_can_lines.csv index d175d22..75079b5 100644 --- a/exogenous_canadian_trade/data/EIA_usa_can_lines.csv +++ b/exogenous_canadian_trade/data/EIA_usa_can_lines.csv @@ -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 diff --git a/exogenous_canadian_trade/data/line_id_certificate_map.json b/exogenous_canadian_trade/data/line_id_certificate_map.json index 1925db6..32555bd 100644 --- a/exogenous_canadian_trade/data/line_id_certificate_map.json +++ b/exogenous_canadian_trade/data/line_id_certificate_map.json @@ -96,5 +96,8 @@ ], "Courtright-St. Claire_345": [ "EC-III-6" + ], + "Hertel-Astoria Annex_400": [ + "EP-306" ] } \ No newline at end of file diff --git a/exogenous_canadian_trade/data/province_to_county_map.csv b/exogenous_canadian_trade/data/province_to_county_map.csv index 3fb970d..3a860e9 100644 --- a/exogenous_canadian_trade/data/province_to_county_map.csv +++ b/exogenous_canadian_trade/data/province_to_county_map.csv @@ -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,,,,,, diff --git a/exogenous_canadian_trade/data/raw_inputs/CER_usa_can_lines.xlsx b/exogenous_canadian_trade/data/raw_inputs/CER_usa_can_lines.xlsx index 4336684..6e4fad7 100644 Binary files a/exogenous_canadian_trade/data/raw_inputs/CER_usa_can_lines.xlsx and b/exogenous_canadian_trade/data/raw_inputs/CER_usa_can_lines.xlsx differ diff --git a/exogenous_canadian_trade/data/raw_inputs/Electricity_Interchange.xlsx b/exogenous_canadian_trade/data/raw_inputs/Electricity_Interchange.xlsx index 84960ac..ebd0cd7 100644 Binary files a/exogenous_canadian_trade/data/raw_inputs/Electricity_Interchange.xlsx and b/exogenous_canadian_trade/data/raw_inputs/Electricity_Interchange.xlsx differ diff --git a/exogenous_canadian_trade/data/raw_inputs/electricity-trade-summary-resume-echanges-commerciaux-electricite.xlsx b/exogenous_canadian_trade/data/raw_inputs/electricity-trade-summary-resume-echanges-commerciaux-electricite.xlsx index 50aecc3..8773f58 100644 Binary files a/exogenous_canadian_trade/data/raw_inputs/electricity-trade-summary-resume-echanges-commerciaux-electricite.xlsx and b/exogenous_canadian_trade/data/raw_inputs/electricity-trade-summary-resume-echanges-commerciaux-electricite.xlsx differ diff --git a/exogenous_canadian_trade/data/raw_inputs/manual_usa_can_lines.csv b/exogenous_canadian_trade/data/raw_inputs/manual_usa_can_lines.csv new file mode 100644 index 0000000..d079988 --- /dev/null +++ b/exogenous_canadian_trade/data/raw_inputs/manual_usa_can_lines.csv @@ -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 diff --git a/exogenous_canadian_trade/process_eia_lines.py b/exogenous_canadian_trade/process_eia_lines.py index f19eef2..35e5e2d 100644 --- a/exogenous_canadian_trade/process_eia_lines.py +++ b/exogenous_canadian_trade/process_eia_lines.py @@ -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.")