diff --git a/config.default.yaml b/config.default.yaml index 936dadea..186226b2 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -34,7 +34,14 @@ electricity: battery: 6 H2: 168 - conventional_carriers: [] # [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass] + # estimate_renewable_capacities_from_capacity_stats: + # # Wind is the Fueltype in ppm.data.Capacity_stats, onwind, offwind-{ac,dc} the carrier in PyPSA-Eur + # Wind: [onwind, offwind-ac, offwind-dc] + # Solar: [solar] + + conventional_carriers: [] # nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass] + custom_powerplants: replace #replace or add + restrict_buildyear: 2015 #delete generators built after 2015 atlite: nprocesses: 4 diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index 1539f806..444eef64 100644 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -52,6 +52,28 @@ def country_alpha_2(name): cntry = pyc.countries.get(official_name=name) return cntry.alpha_2 +def add_custom_carriers(ppl): + switch = snakemake.config['electricity']['custom_powerplants'] + if switch not in ('replace', 'add'): + logger.warning('custom_carriers is invalid keyword, try "replace" or "add"]. powerplants remain unchanged.') + return ppl + dirname = os.path.abspath(os.path.join(os.path.dirname(__file__),"..")) + add_ppls = pd.read_csv(dirname + "/data/custom_powerplants.csv", index_col=0) + if switch == 'replace': + countries = add_ppls.Country.unique().tolist() + carriers = add_ppls.Fueltype.unique().tolist() + logger.info('replacing ' + str(carriers) + ' in ' + str(countries) + '...') + ppl.query('Fueltype != @carriers or Country != @countries',inplace=True) + logger.info('adding custom carriers...') + return ppl.append(add_ppls, sort='False') + +def restrict_buildyear(ppl): + year = snakemake.config['electricity']['restrict_buildyear'] + logger.info('restricting build year of generators to ' + str(year) + '...') + ppl.YearCommissioned = ppl.YearCommissioned.fillna(0).astype(int) #in case of bad arrangement + ppl.YearCommissioned = ppl.YearCommissioned.astype(int) + ppl.query('YearCommissioned <= @year',inplace=True) + if __name__ == "__main__": if 'snakemake' not in globals(): from vresutils.snakemake import MockSnakemake, Dict @@ -74,6 +96,8 @@ if __name__ == "__main__": df.Fueltype.where(df.Fueltype != 'Natural Gas', df.Technology.replace('Steam Turbine', 'OCGT').fillna('OCGT')))) .pipe(ppm.utils.fill_geoposition)) + ppl = add_custom_carriers(ppl) # add carriers from own powerplant files + restrict_buildyear(ppl) # ppl.loc[(ppl.Fueltype == 'Other') & ppl.Technology.str.contains('CCGT'), 'Fueltype'] = 'CCGT' # ppl.loc[(ppl.Fueltype == 'Other') & ppl.Technology.str.contains('Steam Turbine'), 'Fueltype'] = 'CCGT'