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

Updates to result-summaries #245

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

maartenbrinkerink
Copy link
Collaborator

@maartenbrinkerink maartenbrinkerink commented Dec 11, 2024

Description

-Added global level gen-shares
-Added CCS to 'clean' technologies in constants
-Added filter to gen share calculations to only include 'ELC' fuels in the calculations. Contributions of technologies to other fuels (e.g. RES generation targets (e.g. T01)) led to double counting of generation values.
-Added TRN to costs calculations.

-Added global level gen-shares
-Added CCS to 'clean' technologies in constants
-Added filter to gen share calculations to only include 'ELC' fuels in the calculations. Contributions of technologies to other fuels (e.g. mining and/or RES generation targets (e.g. T01) led to double counting of generation values.
-Filter on ELC fuels only to prevent double counting
-Added global level emission intensity
Copy link
Member

@trevorb1 trevorb1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No required changes from me. Everything looks good and runs fine! :)

Only question is the need of the following filtering in some of the scripts. See comments for context

df = df.loc[df.index.get_level_values("FUEL").str.startswith('ELC')]

@@ -40,24 +41,35 @@ def format_emissions(annual_emissions: pd.DataFrame) -> pd.DataFrame:
df["COUNTRY"] = df.EMISSION.str[3:6]
return df.groupby(["REGION", "EMISSION", "COUNTRY", "YEAR"]).sum()

def format_global_values(production: pd.DataFrame, emissions: pd.DataFrame):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing type hint!

Suggested change
def format_global_values(production: pd.DataFrame, emissions: pd.DataFrame):
def format_global_values(production: pd.DataFrame, emissions: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame]:

Comment on lines 53 to 57
def calculate_emission_intensity(
production: pd.DataFrame, emissions: pd.DataFrame
production: pd.DataFrame,
emissions: pd.DataFrame,
country: bool
) -> pd.DataFrame:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to change country to an optional argument, as there is no else condition applied to it.

def calculate_emission_intensity(
    production: pd.DataFrame, emissions: pd.DataFrame
    production: pd.DataFrame, 
    emissions: pd.DataFrame,
    Optional[country]: bool = False
) -> pd.DataFrame:
...

Comment on lines +54 to +56
df1 = df.copy()[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to create a copy of the filtered data, not the pre-filtered data!

Suggested change
df1 = df.copy()[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
]
df1 = df[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
].copy()

Comment on lines +50 to +85
def get_transmission_cost(discounted_cost_tech: pd.DataFrame, country: bool) -> pd.DataFrame:

df = discounted_cost_tech.copy()

df1 = df.copy()[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
]

if country:
r = "COUNTRY"
df1[r] = df1.index.get_level_values("TECHNOLOGY").str[3:6]
else:
r = "NODE"
df1[r] = df1.index.get_level_values("TECHNOLOGY").str[3:8]

df2 = df.copy()[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
]

if country:
r = "COUNTRY"
df2[r] = df2.index.get_level_values("TECHNOLOGY").str[8:11]
else:
r = "NODE"
df2[r] = df2.index.get_level_values("TECHNOLOGY").str[8:13]

for df in [df1, df2]:
df['VALUE'] = df['VALUE'] / 2

df = pd.concat([df1, df2])

return (
df.reset_index()[["REGION", r, "YEAR", "VALUE"]]
.groupby(["REGION", r, "YEAR"])
.sum()
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find grouping the logic in the if else statement together easier to read, but Im not fussed either way. Here is a suggestion if you do want to apply it. :)

Suggested change
def get_transmission_cost(discounted_cost_tech: pd.DataFrame, country: bool) -> pd.DataFrame:
df = discounted_cost_tech.copy()
df1 = df.copy()[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
]
if country:
r = "COUNTRY"
df1[r] = df1.index.get_level_values("TECHNOLOGY").str[3:6]
else:
r = "NODE"
df1[r] = df1.index.get_level_values("TECHNOLOGY").str[3:8]
df2 = df.copy()[
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
]
if country:
r = "COUNTRY"
df2[r] = df2.index.get_level_values("TECHNOLOGY").str[8:11]
else:
r = "NODE"
df2[r] = df2.index.get_level_values("TECHNOLOGY").str[8:13]
for df in [df1, df2]:
df['VALUE'] = df['VALUE'] / 2
df = pd.concat([df1, df2])
return (
df.reset_index()[["REGION", r, "YEAR", "VALUE"]]
.groupby(["REGION", r, "YEAR"])
.sum()
)
def get_transmission_cost(discounted_cost_tech: pd.DataFrame, country: bool) -> pd.DataFrame:
cost = discounted_cost_tech[
(discounted_cost_tech.index.get_level_values("TECHNOLOGY").str.startswith("TRN"))
].copy()
df1 = cost.copy()
df2 = cost.copy()
if country:
r = "COUNTRY"
df1[r] = df1.index.get_level_values("TECHNOLOGY").str[3:6]
df2[r] = df2.index.get_level_values("TECHNOLOGY").str[8:11]
else:
r = "NODE"
df1[r] = df1.index.get_level_values("TECHNOLOGY").str[3:8]
df2[r] = df2.index.get_level_values("TECHNOLOGY").str[8:13]
for df in [df1, df2]:
df['VALUE'] = df['VALUE'] / 2
df = pd.concat([df1, df2])
return (
df.reset_index()[["REGION", r, "YEAR", "VALUE"]]
.groupby(["REGION", r, "YEAR"])
.sum()
)

@@ -12,6 +12,7 @@ def _get_gen_by_node(
) -> pd.DataFrame:

df = production.copy()
df = df.loc[df.index.get_level_values("FUEL").str.startswith('ELC')]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the need of this filtering?

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

Successfully merging this pull request may close these issues.

2 participants