Skip to content

Commit

Permalink
Update wrt master.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jul 5, 2023
1 parent 01c424f commit 43f761b
Show file tree
Hide file tree
Showing 8 changed files with 9,528 additions and 34 deletions.
1,448 changes: 1,438 additions & 10 deletions dev/Untitled.ipynb

Large diffs are not rendered by default.

7,862 changes: 7,862 additions & 0 deletions premise/data/electricity/coal_power_emissions_2012_v1.csv

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions premise/data/utils/logging/reporting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,39 @@ premise_electricity:
name: Renewable share
description: Share of renewable electricity (i.e., solar, wind, hydro, wave, geothermal) in the mix
unit: 0-1
efficiency change:
name: Efficiency change
description: Change in efficiency of electricity generation
unit: 0-1
CO2 scaling factor:
name: CO2 scaling factor
description: Scaling factor the initial CO2 emissions are multiplied by
unit: 0-1
SO2 scaling factor:
name: SO2 scaling factor
description: Scaling factor the initial SO2 emissions are multiplied by
unit: 0-1
CH4 scaling factor:
name: CH4 scaling factor
description: Scaling factor the initial CH4 emissions are multiplied by
unit: 0-1
NOx scaling factor:
name: NOx scaling factor
description: Scaling factor the initial NOx emissions are multiplied by
unit: 0-1
PM<2.5 scaling factor:
name: PM<2.5 scaling factor
description: Scaling factor the initial PM<2.5 emissions are multiplied by
unit: 0-1
PM 2.5-10 scaling factor:
name: PM 2.5-10 scaling factor
description: Scaling factor the initial PM 2.510 emissions are multiplied by
unit: 0-1
PM>10 scaling factor:
name: PM>10 scaling factor
description: Scaling factor the initial PM>10 emissions are multiplied by
unit: 0-1

tab: Electricity

premise_steel:
Expand Down
70 changes: 70 additions & 0 deletions premise/data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
IAM_CARBON_CAPTURE_VARS = VARIABLES_DIR / "carbon_capture_variables.yaml"
CROPS_PROPERTIES = VARIABLES_DIR / "crops_variables.yaml"
GAINS_GEO_MAP = VARIABLES_DIR / "gains_regions_mapping.yaml"
COAL_POWER_PLANTS_DATA = DATA_DIR / "electricity" / "coal_power_emissions_2012_v1.csv"


def get_delimiter(data=None, filepath=None):
Expand Down Expand Up @@ -568,6 +569,8 @@ def __init__(
},
)

self.coal_power_plants = self.fetch_external_data_coal_power_plants()

def __get_iam_variable_labels(
self, filepath: Path, variable: str
) -> Dict[str, Union[str, List[str]]]:
Expand Down Expand Up @@ -1111,3 +1114,70 @@ def get_external_data(self, datapackages):
data[i]["efficiency"] = array

return data

def fetch_external_data_coal_power_plants(self):
"""
Fetch data on coal power plants from external sources.
Source:
Oberschelp, C., Pfister, S., Raptis, C.E. et al.
Global emission hotspots of coal power generation.
Nat Sustain 2, 113–121 (2019).
https://doi.org/10.1038/s41893-019-0221-6
"""

df = pd.read_csv(COAL_POWER_PLANTS_DATA, sep=",", index_col=False)
# rename columns
new_cols = {
"ISO2": "country",
"NET_ELECTRICITY_GENERATION_MWH": "generation",
"FUEL_INPUT_LHV_MJ": "fuel input",
"NET_ELECTRICAL_EFFICIENCY": "efficiency",
"CHP_PLANT": "CHP",
"PLANT_FUEL": "fuel",
"PLANT_EMISSION_CO2_KG": "CO2",
"PLANT_EMISSION_CH4_KG": "CH4",
"PLANT_EMISSION_SO2_KG": "SO2",
"PLANT_EMISSION_NOX_KG": "NOx",
"PLANT_EMISSION_PM_2.5_KG": "PM <2.5",
"PLANT_EMISSION_PM_10_TO_2.5_KG": "PM 10 - 2.5",
"PLANT_EMISSION_PM_GR_10_KG": "PM > 10",
"PLANT_EMISSION_HG_0_KG": "HG0",
"PLANT_EMISSION_HG_2P_KG": "HG2",
"PLANT_EMISSION_HG_P_KG": "HGp",
}
df = df.rename(
columns=new_cols
)

# drop columns
df = df.drop(columns=[c for c in df.columns if c not in new_cols.values()])

# rename Bituminous fuel type as Anthracite
df.loc[:, "fuel"] = df.loc[:, "fuel"].replace("Bituminous coal", "Anthracite coal")

# rename Subbituminous and Coal blend fuel type as Lignite
df["fuel"] = df["fuel"].replace("Subbituminous coal", "Lignite coal")
df["fuel"] = df["fuel"].replace("Coal blend", "Lignite coal")

# convert to xarray
# with dimensions: country and CHP
# with variables as avergage: generation, efficiency, CO2, CH4, SO2,
# NOx, PM <2.5, PM 10 - 2.5, PM > 10, HG0, HG2, HGp
# and ignore the following variables: fuel input

df = df.drop(columns=["fuel input"])
array = (
df.melt(
id_vars=["country", "CHP", "fuel", ],
var_name="variable",
value_name="value",
)
.groupby(["country", "CHP", "fuel", "variable"])["value"]
.mean()
.to_xarray()
)

return array


2 changes: 2 additions & 0 deletions premise/ecoinvent_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ def update_electricity(self) -> None:
modified_datasets=self.modified_datasets,
)

electricity.adjust_coal_power_plant_emissions()

# datasets in 3.9 have been updated
if self.version not in ["3.9", "3.9.1"]:
electricity.update_ng_production_ds()
Expand Down
117 changes: 116 additions & 1 deletion premise/electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,113 @@ def update_electricity_efficiency(self) -> None:

self.write_log(dataset=dataset, status="updated")

def adjust_coal_power_plant_emissions(self) -> None:
"""
Based on:
Fetch data on coal power plants from external sources.
Source:
Oberschelp, C., Pfister, S., Raptis, C.E. et al.
Global emission hotspots of coal power generation.
Nat Sustain 2, 113–121 (2019).
https://doi.org/10.1038/s41893-019-0221-6
We djust efficiency and emissions of coal power plants,
including coal-fired CHPs.
"""

print("Adjust efficiency and emissions of coal power plants...")

coal_techs = [
"Coal PC",
"Coal CHP",
]

for tech in coal_techs:
datasets = ws.get_many(
self.database,
ws.either(*[ws.contains("name", n) for n in self.powerplant_map[tech]]),
ws.equals("unit", "kilowatt hour"),
ws.doesnt_contain_any("name", ["mine", "critical"]),
)

for dataset in datasets:
loc = dataset["location"][:2]
if loc in self.iam_data.coal_power_plants.country.values:
# Find current efficiency
ei_eff = self.find_fuel_efficiency(
dataset, self.powerplant_fuels_map[tech], 3.6
)

new_eff = self.iam_data.coal_power_plants.sel(
country=loc,
fuel="Anthracite coal" if "hard coal" in dataset["name"] else "Lignite coal",
CHP=True if "co-generation" in dataset["name"] else False,
variable="efficiency",
)

if not np.isnan(new_eff.values.item(0)):

wurst.change_exchanges_by_constant_factor(
dataset,
new_eff.values.item(0) / ei_eff,
)

if "log parameters" not in dataset:
dataset["log parameters"] = {}

dataset["log parameters"].update(
{
f"efficiency change": new_eff.values.item(0) / ei_eff,
}
)

substances = [
("CO2", "Carbon dioxide, fossil"),
("SO2", "Sulfur dioxide"),
("CH4", "Methane, fossil"),
("NOx", "Nitrogen oxides"),
("PM <2.5", "Particulate Matter, < 2.5 um"),
("PM 10 - 2.5", "Particulate Matter, > 2.5 um and < 10um"),
("PM > 10", "Particulate Matter, > 10 um"),
]

for substance in substances:
species, flow = substance

emission_factor = (
self.iam_data.coal_power_plants.sel(
country=loc,
fuel="Anthracite coal" if "hard coal" in dataset["name"] else "Lignite coal",
CHP=True if "co-generation" in dataset["name"] else False,
variable=species,
) /
(self.iam_data.coal_power_plants.sel(
country=loc,
fuel="Anthracite coal" if "hard coal" in dataset["name"] else "Lignite coal",
CHP=True if "co-generation" in dataset["name"] else False,
variable="generation",
) * 1e3)
)

if not np.isnan(emission_factor.values.item(0)):
for exc in ws.biosphere(dataset):
if exc["name"] == flow:
scaling_factor = emission_factor.values.item(0) / exc['amount']
exc["amount"] = float(emission_factor.values.item(0))

if "log parameters" not in dataset:
dataset["log parameters"] = {}

dataset["log parameters"].update(
{
f"{species} scaling factor": scaling_factor,
}
)

self.write_log(dataset=dataset, status="updated")



def update_electricity_markets(self) -> None:
"""
Delete electricity markets. Create high, medium and low voltage market groups for electricity.
Expand Down Expand Up @@ -1903,5 +2010,13 @@ def write_log(self, dataset, status="created"):
f"{dataset.get('log parameters', {}).get('biomass share', '')}|"
f"{dataset.get('log parameters', {}).get('transformation loss', '')}|"
f"{dataset.get('log parameters', {}).get('distribution loss', '')}|"
f"{dataset.get('log parameters', {}).get('renewable share', '')}"
f"{dataset.get('log parameters', {}).get('renewable share', '')}|"
f"{dataset.get('log parameters', {}).get('efficiency change', '')}|"
f"{dataset.get('log parameters', {}).get('CO2 scaling factor', '')}|"
f"{dataset.get('log parameters', {}).get('SO2 scaling factor', '')}|"
f"{dataset.get('log parameters', {}).get('CH4 scaling factor', '')}|"
f"{dataset.get('log parameters', {}).get('NOx scaling factor', '')}|"
f"{dataset.get('log parameters', {}).get('PM <2.5 scaling factor', '')}|"
f"{dataset.get('log parameters', {}).get('PM 10 - 2.5 scaling factor', '')}|"
f"{dataset.get('log parameters', {}).get('PM > 10 scaling factor', '')}"
)
8 changes: 0 additions & 8 deletions premise/iam_variables_mapping/electricity_variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Biomass ST:
ecoinvent_fuel_aliases:
fltr:
- Wood chips, burned in power plant 20 MW, truck 25km, no CCS

Biomass IGCC CCS:
iam_aliases:
remind: SE|Electricity|Biomass|++|Gasification Combined Cycle w/ CC
Expand All @@ -63,7 +62,6 @@ Biomass IGCC CCS:
- Hydrogen, gaseous, 25 bar, from dual fluidised bed gasification of woody biomass with CCS, at gasification plant
- market for wood chips
- market for biomass, used as fuel

Biomass IGCC:
iam_aliases:
remind: SE|Electricity|Biomass|++|Gasification Combined Cycle w/o CC
Expand All @@ -78,7 +76,6 @@ Biomass IGCC:
fltr:
- market for wood chips
- market for biomass, used as fuel

Coal PC:
iam_aliases:
remind: SE|Electricity|Coal|++|Pulverised Coal w/o CC
Expand All @@ -103,7 +100,6 @@ Coal PC:
- plant
- briquettes
- ash

Coal IGCC:
iam_aliases:
remind: SE|Electricity|Coal|++|Gasification Combined Cycle w/o CC
Expand All @@ -120,7 +116,6 @@ Coal IGCC:
fltr:
- Hard coal, burned in power plant/IGCC, no CCS
- Lignite, burned in power plant/IGCC, no CCS

Coal PC CCS:
iam_aliases:
remind: SE|Electricity|Coal|++|Pulverised Coal w/ CC
Expand All @@ -139,7 +134,6 @@ Coal PC CCS:
- Hard coal, burned in power plant/pre
- Lignite, burned in power plant/post
- Lignite, burned in power plant/pre

Coal IGCC CCS:
iam_aliases:
remind: SE|Electricity|Coal|++|Gasification Combined Cycle w/ CC
Expand All @@ -160,7 +154,6 @@ Coal IGCC CCS:
- Hard coal, burned in power plant/post
- Lignite, burned in power plant/pre
- Lignite, burned in power plant/post

Coal CHP:
iam_aliases:
remind: SE|Electricity|Coal|++|Combined Heat and Power w/o CC
Expand All @@ -185,7 +178,6 @@ Coal CHP:
- plant
- briquettes
- ash

Coal CHP CCS:
iam_aliases:
image: Secondary Energy|Electricity|Coal|w/ CCS|2
Expand Down
Loading

0 comments on commit 43f761b

Please sign in to comment.