Skip to content

Commit

Permalink
Merge pull request #154 from davide-f/master
Browse files Browse the repository at this point in the history
Add Status filter to GCPT and improve performances
  • Loading branch information
davide-f authored Apr 4, 2024
2 parents ffbe902 + ace40f7 commit c331a3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions doc/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ History of Changes
.. Upcoming Version
.. ----------------
* fix the filtering of GCPT/GEM coal database by Status.
* add add technology renaming for GWPT/GEM wind dataset.
* improve performances of GEM data processing.

Version 0.5.11 (05.02.2024)
---------------------------

Expand Down
16 changes: 9 additions & 7 deletions powerplantmatching/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,16 +1752,17 @@ def GCPT(raw=False, update=False, config=None):
.pipe(set_column_name, "GCPT")
.pipe(convert_to_short_name)
.dropna(subset="Capacity")
.pipe(lambda x: x.replace({"Fueltype": fueltype_dict}))
.pipe(lambda x: x.assign(Technology="Steam Turbine"))
.pipe(lambda x: x.assign(Set="PP"))
.assign(
DateIn=df["DateIn"].apply(pd.to_numeric, errors="coerce"),
DateOut=df["DateOut"].apply(pd.to_numeric, errors="coerce"),
lat=df["lat"].apply(pd.to_numeric, errors="coerce"),
lon=df["lon"].apply(pd.to_numeric, errors="coerce"),
)
.query("Status in ['operating','mothballed','construction']")
.pipe(lambda x: x[df.columns.intersection(config.get("target_columns"))])
.pipe(lambda x: x.replace({"Fueltype": fueltype_dict}))
.pipe(lambda x: x.assign(Technology="Steam Turbine"))
.pipe(lambda x: x.assign(Set="PP"))
.pipe(config_filter, config)
)

Expand Down Expand Up @@ -1873,6 +1874,7 @@ def GWPT(raw=False, update=False, config=None):
)
.query("Status in ['operating','mothballed','construction']")
.pipe(lambda x: x[df.columns.intersection(config.get("target_columns"))])
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.assign(Fueltype="Wind")
.assign(Set="PP")
.pipe(config_filter, config)
Expand Down Expand Up @@ -1925,7 +1927,6 @@ def GSPT(raw=False, update=False, config=None):
.pipe(set_column_name, "GSPT")
.pipe(convert_to_short_name)
.dropna(subset="Capacity")
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.assign(
DateIn=df["DateIn"].apply(pd.to_numeric, errors="coerce"),
DateOut=df["DateOut"].apply(pd.to_numeric, errors="coerce"),
Expand All @@ -1934,6 +1935,7 @@ def GSPT(raw=False, update=False, config=None):
)
.query("Status in ['operating','mothballed','construction']")
.pipe(lambda x: x[df.columns.intersection(config.get("target_columns"))])
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.assign(Fueltype="Solar")
.assign(Set="PP")
.pipe(config_filter, config)
Expand Down Expand Up @@ -2004,10 +2006,10 @@ def GGPT(raw=False, update=False, config=None):
lon=df["lon"].apply(pd.to_numeric, errors="coerce"),
Capacity=lambda df: pd.to_numeric(df.Capacity, "coerce"),
)
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.pipe(lambda x: x.replace({"Set": set_dict}))
.query("Status in ['operating','mothballed','construction']")
.pipe(lambda x: x[df.columns.intersection(config.get("target_columns"))])
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.pipe(lambda x: x.replace({"Set": set_dict}))
.assign(Fueltype="Natural Gas")
.pipe(config_filter, config)
)
Expand Down Expand Up @@ -2067,8 +2069,8 @@ def GHPT(raw=False, update=False, config=None):
lon=df["lon"].apply(pd.to_numeric, errors="coerce"),
)
.query("Status in ['operating','construction']")
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.pipe(lambda x: x[df.columns.intersection(config.get("target_columns"))])
.pipe(lambda x: x.replace({"Technology": technology_dict}))
.assign(Fueltype="Hydro")
.assign(Set="PP")
.pipe(config_filter, config)
Expand Down
2 changes: 1 addition & 1 deletion powerplantmatching/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def cross_matches(sets_of_pairs, labels=None):
else:
matches = pd.concat([matches, match_base], sort=True)

if matches.empty:
if matches is None or matches.empty:
logger.warn("No matches found")
return pd.DataFrame(columns=labels)

Expand Down

0 comments on commit c331a3a

Please sign in to comment.