Skip to content

Commit

Permalink
Merge pull request #96 from DeltaE/clarify-techs-vs-fuels
Browse files Browse the repository at this point in the history
Renamed mine_techs to mine_fuels in config.yaml
  • Loading branch information
trevorb1 authored Jan 11, 2022
2 parents 93b5086 + d7a9fb7 commit a2d6e4f
Show file tree
Hide file tree
Showing 19 changed files with 15,393 additions and 71,415 deletions.
14 changes: 7 additions & 7 deletions scripts/CapacityToActivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def main():
regions = functions.openYaml().get('regions')

techsMaster = functions.openYaml().get('techs_master')
rnwTechs = functions.openYaml().get('rnw_techs')
mineTechs = functions.openYaml().get('mine_techs')
rnwFuels = functions.openYaml().get('rnw_fuels')
mineFuels = functions.openYaml().get('mine_fuels')
countries = functions.getRegionDictionary('CAN')

df = functions.createTechDataframe(countries, techsMaster, mineTechs, rnwTechs, '../dataSources/Trade.csv', True)
df = functions.createTechDataframe(countries, techsMaster, mineFuels, rnwFuels, '../dataSources/Trade.csv', True)
technologies = df['VALUE'].tolist()

###########################################
Expand Down Expand Up @@ -69,8 +69,8 @@ def getUsaCapToActivityUnit():
# OUTPUT: dfOut = dataframe to be written to a csv

techsMaster = functions.openYaml().get('techs_master')
rnwTechs = functions.openYaml().get('rnw_techs')
mineTechs = functions.openYaml().get('mine_techs')
rnwFuels = functions.openYaml().get('rnw_fuels')
mineFuels = functions.openYaml().get('mine_fuels')
countries = functions.getRegionDictionary('USA')

#This one is easier to manually do...
Expand All @@ -81,8 +81,8 @@ def getUsaCapToActivityUnit():
# If 1 GW of capacity works constantly throughout the year, it produced 31.536 PJ
capToAct = 31.536

#Technologies to print over
df = functions.createTechDataframe(countries, techsMaster, mineTechs, rnwTechs, '../dataSources/USA_Trade.csv', False)
#Technologies and fuels to print over
df = functions.createTechDataframe(countries, techsMaster, mineFuels, rnwFuels, '../dataSources/USA_Trade.csv', False)
techs = df['VALUE'].tolist()

#populate list
Expand Down
2 changes: 1 addition & 1 deletion scripts/Costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def getUsaVariableCost():
df.reset_index()

#Fuels that have international trade options
intFuel = functions.openYaml().get('mine_techs')
intFuel = functions.openYaml().get('mine_fuels')

#holds output data
outData = []
Expand Down
2 changes: 1 addition & 1 deletion scripts/EmissionActivityRatio.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def getUsaEmissionActivityRatio():
outData = []

#Fuels that have international trade options
intFuel = functions.openYaml().get('mine_techs')
intFuel = functions.openYaml().get('mine_fuels')

#map data
for year in years:
Expand Down
50 changes: 25 additions & 25 deletions scripts/InOutActivityRatio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def main():
# Tech to Fuel Mapping
techToFuel = functions.openYaml().get('tech_to_fuel')

# Renewable, Mining, Power Techs
rnwTechs = functions.openYaml().get('rnw_techs')
minTechs = functions.openYaml().get('mine_techs')
# Renewable, Mining Fuels, Power Techs
rnwFuels = functions.openYaml().get('rnw_fuels')
minFuels = functions.openYaml().get('mine_fuels')
pwrTechs = functions.openYaml().get('techs_master')

###########################################
Expand All @@ -39,26 +39,26 @@ def main():
for region in regions:
for year in years:
for subregion in subregions:
for tech in rnwTechs:
techName = 'RNW' + tech + 'CAN' + subregion
fuelOut = tech + 'CAN' + subregion
for fuel in rnwFuels:
techName = 'RNW' + fuel + 'CAN' + subregion
fuelOut = fuel + 'CAN' + subregion
masterOARList.append([region, techName, fuelOut, 1, year, 1])

# OAR Domestic Mining
for region in regions:
for year in years:
for tech in minTechs:
techName = 'MIN' + tech + 'CAN'
fuelOut = tech + 'CAN'
for fuel in minFuels:
techName = 'MIN' + fuel + 'CAN'
fuelOut = fuel + 'CAN'
masterOARList.append([region, techName, fuelOut, 1, year, 1])

# IAR and OAR International Mining
for region in regions:
for year in years:
for tech in minTechs:
techName = 'MIN' + tech + 'INT'
fuelIn = tech
fuelOut = tech + 'INT'
for fuel in minFuels:
techName = 'MIN' + fuel + 'INT'
fuelIn = fuel
fuelOut = fuel + 'INT'
masterIARList.append([region, techName, fuelIn, 1, year, 1])
masterOARList.append([region, techName, fuelOut, 1, year, 1])

Expand Down Expand Up @@ -92,13 +92,13 @@ def main():
for region in regions:
for year in years:
for subregion in subregions:
for tech in pwrTechs:
techName = 'PWR' + tech + 'CAN' + subregion + '01'
iar = dfIAR.loc[year,tech]
oar = dfOAR.loc[year,tech]
fuelName = techToFuel[tech]
for fuel in pwrTechs:
techName = 'PWR' + fuel + 'CAN' + subregion + '01'
iar = dfIAR.loc[year,fuel]
oar = dfOAR.loc[year,fuel]
fuelName = techToFuel[fuel]
# if has international imports
if fuelName in minTechs:
if fuelName in minFuels:
inFuelModeOne = fuelName + 'CAN'
inFuelModeTwo = fuelName + 'INT'
outFuel = 'ELC' + 'CAN' + subregion + '01'
Expand All @@ -107,15 +107,15 @@ def main():
masterOARList.append([region, techName, outFuel, 1, year, oar])
masterOARList.append([region, techName, outFuel, 2, year, oar])
# edge case of storage. This is super hacked together... will need to update
elif tech == 'P2G' or tech == 'FCL':
elif fuel == 'P2G' or fuel == 'FCL':
# P2G will only have input activity ratio
if tech == 'P2G':
if fuel == 'P2G':
inFuel = 'ELC' + 'CAN' + subregion + '02'
outFuel = 'HY2' + 'CAN' + subregion + '01'
masterIARList.append([region, techName, inFuel, 1, year, iar])
masterOARList.append([region, techName, outFuel, 1, year, 0])
# P2G will only have output activity ratio
elif tech == 'FCL':
elif fuel == 'FCL':
inFuel = 'HY2' + 'CAN' + subregion + '01'
outFuel = 'ELC' + 'CAN' + subregion + '02'
masterIARList.append([region, techName, inFuel, 1, year, 0])
Expand Down Expand Up @@ -146,8 +146,8 @@ def getUsaOutputActivityRatio():
subregions = functions.getRegionDictionary('USA')

#Fuels that have international trade options
intFuel = functions.openYaml().get('mine_techs')
rnwFuel = functions.openYaml().get('rnw_techs')
intFuel = functions.openYaml().get('mine_fuels')
rnwFuel = functions.openYaml().get('rnw_fuels')

#holds output data
outData = []
Expand Down Expand Up @@ -233,7 +233,7 @@ def getUsaInputActivityRatio():
df.reset_index()

#Fuels that have international trade options
intFuel = functions.openYaml().get('mine_techs')
intFuel = functions.openYaml().get('mine_fuels')

#holds output data
outData = []
Expand Down
12 changes: 6 additions & 6 deletions scripts/MakeSets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def main():
regions = functions.openYaml().get('regions')
emissions = functions.openYaml().get('emissions')
techsMaster = functions.openYaml().get('techs_master')
rnwTechs = functions.openYaml().get('rnw_techs')
mineTechs = functions.openYaml().get('mine_techs')
rnwFuels = functions.openYaml().get('rnw_fuels')
mineFuels = functions.openYaml().get('mine_fuels')
stoTechs = functions.openYaml().get('sto_techs')
years = functions.getYears()
canCountries = functions.getRegionDictionary('CAN')
Expand Down Expand Up @@ -50,17 +50,17 @@ def main():
## CREATE TECHNOLOGY SET
####################################

canadaDfOut = functions.createTechDataframe(canCountries, techsMaster, mineTechs, rnwTechs, '../dataSources/Trade.csv', True)
usaDfOut = functions.createTechDataframe(usaCountries, techsMaster, mineTechs, rnwTechs, '../dataSources/USA_Trade.csv', False)
canadaDfOut = functions.createTechDataframe(canCountries, techsMaster, mineFuels, rnwFuels, '../dataSources/Trade.csv', True)
usaDfOut = functions.createTechDataframe(usaCountries, techsMaster, mineFuels, rnwFuels, '../dataSources/USA_Trade.csv', False)
df = canadaDfOut.append(usaDfOut)
df.to_csv('../src/data/TECHNOLOGY.csv', index=False)

####################################
## CREATE FUEL SET
####################################

canadaDfOut = functions.createFuelDataframe(canCountries, rnwTechs, mineTechs, True)
usaDfOut = functions.createFuelDataframe(usaCountries, rnwTechs, mineTechs, False)
canadaDfOut = functions.createFuelDataframe(canCountries, rnwFuels, mineFuels, True)
usaDfOut = functions.createFuelDataframe(usaCountries, rnwFuels, mineFuels, False)
df = canadaDfOut.append(usaDfOut)
df.to_csv('../src/data/FUEL.csv', index=False)

Expand Down
14 changes: 7 additions & 7 deletions scripts/RETags.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def main():
subregions = (functions.openYaml().get('subregions_dictionary')).keys()
years = functions.getYears()

#Techs to tag
techs = functions.openYaml().get('rnw_techs')
#Fuels to tag
fuels = functions.openYaml().get('rnw_fuels')

###########################################
# Compile RE Tags
Expand All @@ -30,8 +30,8 @@ def main():
for region in regions:
for year in years:
for subregion in subregions:
for tech in techs:
techName = 'PWR' + tech + 'CAN' + subregion + '01'
for fuel in fuels:
techName = 'PWR' + fuel + 'CAN' + subregion + '01'
dataOut.append([region, techName, year, 1])

#write to a csv
Expand All @@ -47,16 +47,16 @@ def getUsaRETagTechnology():

subregions = functions.getRegionDictionary('USA')

techs = functions.openYaml().get('rnw_techs')
fuels = functions.openYaml().get('rnw_fuels')
years = functions.getYears()

outData = []

for year in years:
for subregion in subregions['USA']:
for tech in techs:
for fuel in fuels:
region = 'NAmerica'
techName = 'PWR' + tech + 'USA' + subregion + '01'
techName = 'PWR' + fuel + 'USA' + subregion + '01'
outData.append([region, techName, year, 1])

# create and return datafram
Expand Down
10 changes: 5 additions & 5 deletions scripts/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ techs_master:
#'P2G' # Power to Gas
#'FCL' # Fuel Cell

# list of renewable technologies
rnw_techs:
# list of renewable fuels
rnw_fuels:
- 'HYD' # Hydro
- 'SPV' # Solar
- 'WND' # Wind
- 'BIO' # Biomass

# list of mining technologies
mine_techs:
# list of mining fuels
mine_fuels:
- 'COA' # Coal
- 'GAS' # Gas
- 'URN' # Nuclear

# list of variable technologies
# list of variable techs
variable_techs:
- 'SPV'
- 'WND'
Expand Down
28 changes: 14 additions & 14 deletions scripts/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def getRNWfuels(regions, techs):
return outList

def getMINfuels(regions, techs, generateInternational):
# PURPOSE: Creates Fuel names for Min technologies
# PURPOSE: Creates Fuel names for Mined Fuels
# INPUT: regions = Dictionary holding region as the key and subregion as the values in a list
# techs = List of the technologies to print over
# generateInternational = True/False for whether function needs to create all
Expand Down Expand Up @@ -301,20 +301,20 @@ def getELCfuels(regions):
# Return list of electricty fuels
return outList

def createFuelDataframe(countries, rnwTechs, mineTechs, generateInternational):
def createFuelDataframe(countries, rnwFuels, mineFuels, generateInternational):
# PURPOSE: Appends all fuel name lists together and writes them to a CSV
# INPUT: countries = Dictionary holding countries as the key and subregion as the values in a list
# rnwTechs = List of the technologies to print over for getRNWfuels
# mineTechs = List of the technologies to print over for getMINfuels
# rnwFuels = List of the fuels to print over for getRNWfuels
# mineFuels = List of the fuels to print over for getMINfuels
# generateInternational = True/False for whether getMINfuels function needs to create all
# technology names for international import/export
# OUTPUT: dfOut = fuel set dataframe

# Renewable fuels
rnwFuelList = getRNWfuels(countries, rnwTechs)
rnwFuelList = getRNWfuels(countries, rnwFuels)

# Mining fuels
minFuelList = getMINfuels(countries, mineTechs, generateInternational)
minFuelList = getMINfuels(countries, mineFuels, generateInternational)

#ELC fuels
elcFuelList = getELCfuels(countries)
Expand All @@ -328,13 +328,13 @@ def createFuelDataframe(countries, rnwTechs, mineTechs, generateInternational):
dfOut = pd.DataFrame(outputFuels, columns=['VALUE'])
return dfOut

def createTechDataframe(countries, techsMaster, mineTechs, rnwTechs, trnTechsCsvPath, generateInternational):
# PURPOSE: Appends all technology name lists together and returns them as a CSV dataframe
def createTechDataframe(countries, techsMaster, mineFuels, rnwFuels, trnTechsCsvPath, generateInternational):
# PURPOSE: Appends technology and fuel name lists together and returns them as a CSV dataframe
# INPUT: countries = Dictionary holding countries as the key
# and subregion as the values in a list
# techsMaster = List of the technologies to print over for getPWRtechs
# mineTechs = List of the technologies to print over for getMINtechs
# rnwTechs = List of the technologies to print over for getRNWtechs
# mineFuels = List of the fuels to print over for getMINfuels
# rnwFuels = List of the fuels to print over for getRNWfuels
# trnTechsCsvPath = Trade csv dataframe location
# generateInternational = True/False for whether function should
# create all international mining techs
Expand All @@ -345,11 +345,11 @@ def createTechDataframe(countries, techsMaster, mineTechs, rnwTechs, trnTechsCsv
# get grid distribution technology list (PWRTRN<Reg><SubReg>)
pwrTrnList = getPWRTRNtechs(countries)

# get Mining technology list
minList = getMINtechs(countries, mineTechs, generateInternational)
# get Mining techs list
minList = getMINtechs(countries, mineFuels, generateInternational)

# get Renewables technology list
rnwList = getRNWtechs(countries, rnwTechs)
# get Renewables fuels list
rnwList = getRNWtechs(countries, rnwFuels)

# get trade technology list
trnList = getTRNtechs(trnTechsCsvPath)
Expand Down
Loading

0 comments on commit a2d6e4f

Please sign in to comment.