Skip to content

Commit

Permalink
debugging carbon code naming tweaks
Browse files Browse the repository at this point in the history
there was a "materials" vs "materials_input" bug on the calcFlows. Also catching last mis-named countries. it runs, there might be an indexing error, getting 55 appended NaNs, not sure, TO DO Debug
  • Loading branch information
heathermirletz committed Sep 13, 2024
1 parent 37c45b8 commit aacd90b
Show file tree
Hide file tree
Showing 13 changed files with 2,113 additions and 3,449 deletions.
2 changes: 1 addition & 1 deletion PV_ICE/baselines/CarbonLayer/baseline_countrygridmix.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Coal,0.3487,0.82,0.3215,0.338
Gas,0.2291,0.49,0.1805,0.181
Hydro,0,0.024,0,0
Nuclear,0,0.012,0,0
OtherFossil,0.2671,0.7,0.2413,0
OtherRenewables,0,0.038,0,0
Other Fossil,0.2671,0.7,0.2413,0
Other Renewables,0,0.038,0,0
Solar,0,0.048,0,0
Wind,0,0.011,0,0
SteamAndHeat,0,0,0,0.2266
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
,China,India,Taiwan,Germany,Japan,SKorea,Canada,Mexico,USA,VietNam,Malaysia,Thailand,Singapore,Turkey,Poland,Switzerland,Brazil,SouthAfrica,Philippines,ElSalvador
,China,India,Taiwan,Germany,Japan,South Korea,Canada,Mexico,USA,Viet Nam,Malaysia,Thailand,Singapore,Turkey,Poland,Switzerland,Brazil,South Africa,Philippines,El Salvador
1995,39.62264151,24.21383648,4.716981132,15.09433962,0,0,11.00628931,0,0,0,0,0,0,0,0,4.716981132,0,0,0,0
1996,39.62264151,24.21383648,4.716981132,15.09433962,0,0,11.00628931,0,0,0,0,0,0,0,0,4.716981132,0,0,0,0
1997,39.62264151,24.21383648,4.716981132,15.09433962,0,0,11.00628931,0,0,0,0,0,0,0,0,4.716981132,0,0,0,0
Expand Down
7 changes: 4 additions & 3 deletions PV_ICE/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,17 @@ def calculateFlows(self, scenarios=None, materials_input=None,
# return


self.calculateMassFlow(scenarios=scenarios, materials_input=materials,
self.calculateMassFlow(scenarios=scenarios, materials_input=None,
weibullInputParams=weibullInputParams,
bifacialityfactors=bifacialityfactors,
reducecapacity=reducecapacity,
debugflag=debugflag,
installByArea=installByArea,
nameplatedeglimit=nameplatedeglimit)

self.calculateEnergyFlow(scenarios=scenarios, materials=materials)
self.calculateEnergyFlow(scenarios=scenarios, materials_input=None)

#self.calculateCarbonFlows(scenarios=scenarios,materials=materials)
#self.calculateCarbonFlows(scenarios=scenarios,materials_input=materials)

def calculateMassFlow(self, scenarios=None, materials_input=None,
weibullInputParams=None, bifacialityfactors=None,
Expand Down Expand Up @@ -1681,6 +1681,7 @@ def calculateCarbonFlows(self, scenarios=None, materials_input=None,
temp_country_carbon = []
for fuel in fuellist:
fuelemitfactor = gridemissionfactors[gridemissionfactors['Energy Source']==fuel]['CO2eq_gpWh_IPCC2006']
#print(fuelemitfactor)
fuelemitfactor = list(fuelemitfactor)[0]
if str(country+'_'+fuel) in countrygridmixes:
countryfuel = countrygridmixes[str(country+'_'+fuel)]
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
emberdata_vars_perc['Area'].unique()


# In[9]:
# In[8]:


#munge the Area strings into a more usable format (this takes a while!)
Expand All @@ -93,27 +93,27 @@ def remove_substrings_regex(text, substrings):
emberdata_vars_perc_rename.loc[emberdata_vars_perc['Area']=="Lao People's Democratic Republic (the)", "Area"] = "Laos"

substrings = [" (the)", " (Islamic Republic of)", " (Bolivarian Republic of)", "n Federation",
", State of", "n Arab Republic", ", the United Republic of"]
", State of", "n Arab Republic", ", the United Republic of", " Herzegovina"]
for row in range(0,len(emberdata_vars_perc_rename['Area'])):
emberdata_vars_perc_rename.iloc[row,0] = remove_substrings_regex(emberdata_vars_perc_rename.iloc[row,0], substrings)

#emberdata_vars_perc['Area'].unique()


# In[18]:
# In[9]:


emberdata_vars_perc_rename.loc[emberdata_vars_perc_rename['Area']=="Laos"]


# In[15]:
# In[10]:


#emberdata_vars_perc.loc[emberdata_vars_perc['Area']=="Bahamas (the)"]
emberdata_vars_perc_rename['Area'].unique()


# In[28]:
# In[11]:


#for unique values of renamed area, do a pivot table with year on index, variable on column, and value in thingy
Expand All @@ -128,7 +128,7 @@ def remove_substrings_regex(text, substrings):
gridmix_bycountry_2000topresent


# In[29]:
# In[12]:


#add in the 1995 to 2000 and present to 2050, ffill and bfill
Expand All @@ -138,15 +138,15 @@ def remove_substrings_regex(text, substrings):
gridmix_bycountry_1995to2050_full


# In[32]:
# In[15]:


#emberdata_vars_perc_rename['Area'].unique()
areaofinterest = 'Laos'
areaofinterest = 'Bosnia'
gridmix_bycountry_1995to2050_full.filter(like=areaofinterest).plot(kind='area', legend='reverse').legend(bbox_to_anchor=(1, 0.5))


# In[31]:
# In[14]:


gridmix_bycountry_1995to2050_full.to_csv(os.path.join(baselinesFolder,'CarbonLayer','baseline_countrygridmix.csv'))
Expand Down
391 changes: 325 additions & 66 deletions docs/baseline development documentation/CarbonCalcDev.html

Large diffs are not rendered by default.

Loading

0 comments on commit aacd90b

Please sign in to comment.