-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
Conversation
-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
There was a problem hiding this 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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing type hint!
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]: |
def calculate_emission_intensity( | ||
production: pd.DataFrame, emissions: pd.DataFrame | ||
production: pd.DataFrame, | ||
emissions: pd.DataFrame, | ||
country: bool | ||
) -> pd.DataFrame: |
There was a problem hiding this comment.
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:
...
df1 = df.copy()[ | ||
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN")) | ||
] |
There was a problem hiding this comment.
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!
df1 = df.copy()[ | |
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN")) | |
] | |
df1 = df[ | |
(df.index.get_level_values("TECHNOLOGY").str.startswith("TRN")) | |
].copy() |
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() | ||
) |
There was a problem hiding this comment.
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. :)
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')] |
There was a problem hiding this comment.
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?
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.