Skip to content

Commit

Permalink
working on carbon nan append problem
Browse files Browse the repository at this point in the history
fixed and re-ran the ember electricity file scraping code, now generates a 2050 and 2100 baseline for carbon.
  • Loading branch information
heathermirletz committed Jan 13, 2025
1 parent 5824190 commit d9ff400
Show file tree
Hide file tree
Showing 9 changed files with 2,805 additions and 530 deletions.
57 changes: 57 additions & 0 deletions PV_ICE/baselines/CarbonLayer/baseline2050_countrygridmix.csv

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions PV_ICE/baselines/CarbonLayer/baseline2100_countrygridmix.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion PV_ICE/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ def calculateCarbonFlows(self, scenarios=None, materials_input=None,
carbonfolder = Path(DATA_PATH) / 'CarbonLayer'

if countrygridmixes is None:
countrygridmixes = pd.read_csv(os.path.join(carbonfolder,'baseline_countrygridmix.csv'))
countrygridmixes = pd.read_csv(os.path.join(carbonfolder,'baseline2100_countrygridmix.csv'))
else:
if isinstance(countrygridmixes, str):
countrygridmixes = pd.read_csv(countrygridmixes)
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 @@ -35,13 +35,13 @@
#print("PV_ICE version ", PV_ICE.__version__)


# In[4]:
# In[6]:


url = 'https://ember-climate.org/app/uploads/2022/07/yearly_full_release_long_format.csv'
url = 'https://storage.googleapis.com/emb-prod-bkt-publicdata/public-downloads/yearly_full_release_long_format.csv'


# In[5]:
# In[7]:


storage_options = {'User-Agent': 'Mozilla/5.0'}
Expand All @@ -50,7 +50,7 @@
emberdata_raw.head()


# In[6]:
# In[8]:


#down select for only columsn of interest
Expand All @@ -68,13 +68,13 @@
emberdata_vars_perc


# In[7]:
# In[9]:


emberdata_vars_perc['Area'].unique()


# In[8]:
# In[10]:


#munge the Area strings into a more usable format (this takes a while!)
Expand All @@ -100,20 +100,20 @@ def remove_substrings_regex(text, substrings):
#emberdata_vars_perc['Area'].unique()


# In[9]:
# In[11]:


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


# In[10]:
# In[12]:


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


# In[11]:
# In[13]:


#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[12]:
# In[14]:


#add in the 1995 to 2000 and present to 2050, ffill and bfill
Expand All @@ -146,10 +146,26 @@ def remove_substrings_regex(text, substrings):
gridmix_bycountry_1995to2050_full.filter(like=areaofinterest).plot(kind='area', legend='reverse').legend(bbox_to_anchor=(1, 0.5))


# In[14]:
# In[16]:


gridmix_bycountry_1995to2050_full.to_csv(os.path.join(baselinesFolder,'CarbonLayer','baseline2050_countrygridmix.csv'))


# In[17]:


#add in the 1995 to 2000 and present to 2100, ffill and bfill
indx_temp = pd.Series(range(1995,2101,1))
gridmix_bycountry_1995to2100 = gridmix_bycountry_2000topresent.reindex(indx_temp, method='nearest') #still leaving NaN if 2023 value NaN
gridmix_bycountry_1995to2100_full = gridmix_bycountry_1995to2100.fillna(method='ffill') #fix nan values throughout
gridmix_bycountry_1995to2100_full


# In[18]:


gridmix_bycountry_1995to2050_full.to_csv(os.path.join(baselinesFolder,'CarbonLayer','baseline_countrygridmix.csv'))
gridmix_bycountry_1995to2100_full.to_csv(os.path.join(baselinesFolder,'CarbonLayer','baseline2100_countrygridmix.csv'))


# In[ ]:
Expand Down
Loading

0 comments on commit d9ff400

Please sign in to comment.