Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new OperationalLife.py file #117

Open
Kiel-SFU opened this issue Feb 3, 2022 · 2 comments
Open

Create new OperationalLife.py file #117

Kiel-SFU opened this issue Feb 3, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@Kiel-SFU
Copy link
Collaborator

Kiel-SFU commented Feb 3, 2022

Currently, ResidualCapacity.py generates ResidualCapacity.csv and OperationalLife.csv. This is because variables created when making OperationalLife.csv are needed to make ResidualCapacity.csv. We could have ResidualCapacity.py rely upon a new OperationalLife.py file that does its work separately.

For example, the data from the variable opLife are used in both the Operational Life and Residual Capacity parts of ResidualCapacity.py.

#Create a dictionary from the tech, year values for use with residual capacity
techs = dfOperationalLife['TECHNOLOGY'].tolist()
opLifeYears = dfOperationalLife['YEARS'].tolist()
opLife = {}
for i in range(len(techs)):
opLife[techs[i]] = opLifeYears[i]

@Kiel-SFU Kiel-SFU added the enhancement New feature or request label Feb 3, 2022
@trevorb1
Copy link
Member

trevorb1 commented Feb 3, 2022

Good idea! We will also need to make sure that ResidualCapacity.py is dependent on OperationalLife.py in the snakefile

@trevorb1
Copy link
Member

trevorb1 commented Feb 4, 2022

For reference on what we should break into the new operational_life.py file...

def getCanOperationalLife():
# PURPOSE: Creates opertionalLife file from USA data
# INPUT: N/A
# OUTPUT: opLifeData = Canadian Operational Life Data
# opLife = Dictionary from the tech, year values for use with residual capacity
# techs = List of technologies pertaining to Operational Life
# techListTrade = Trade names without duplicates
# dfTrade = Raw Trade datafile
continent = functions.getFromYaml('continent')
canSubregions = functions.getFromYaml('regions_dict')['CAN'] # Canadian subregions
#read in raw operational life values
dfOperationalLife = pd.read_csv('../dataSources/OperationalLifeTechnology.csv')
#remove P2G and FCL columns
rowsToDrop = []
for i in range(len(dfOperationalLife)):
tech = dfOperationalLife['TECHNOLOGY'].iloc[i]
if (tech == 'P2G') or (tech == 'FCL'):
rowsToDrop.append(i)
dfOperationalLife = dfOperationalLife.drop(rowsToDrop)
dfOperationalLife.reset_index()
#Create a dictionary from the tech, year values for use with residual capacity
techs = dfOperationalLife['TECHNOLOGY'].tolist()
opLifeYears = dfOperationalLife['YEARS'].tolist()
opLife = {}
for i in range(len(techs)):
opLife[techs[i]] = opLifeYears[i]
#List to hold output operational life values
#columns = region, technology, value
opLifeData = []
#save operational life to list
for subregion in canSubregions:
for tech, value in opLife.items():
techName = 'PWR' + tech + 'CAN' + subregion + '01'
opLifeData.append([continent,techName,value])
# get trade tech names and save operational life values
dfTrade = pd.read_csv('../dataSources/Trade.csv')
# get list of all the trade technologies
techListTrade = dfTrade['TECHNOLOGY'].tolist()
techListTrade = list(set(techListTrade)) #remove duplicates
# hardcode in operational life of 100 years
for tech in techListTrade:
opLifeData.append([continent,tech,100])
return opLifeData, opLife, techs, techListTrade, dfTrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants