allow usage of own powerplants for selected country
This commit is contained in:
parent
07143fb2cd
commit
c4fd099cc8
@ -43,6 +43,9 @@ electricity:
|
|||||||
# Solar: [solar]
|
# Solar: [solar]
|
||||||
|
|
||||||
conventional_carriers: [] # nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass]
|
conventional_carriers: [] # nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass]
|
||||||
|
my_carriers_for_countries: ['DE'] # will replace generators in Germany by those saved in resources/powerplants_DE.csv
|
||||||
|
my_carriers_switch: replace-selection #replace-all, replace-selection or add (replace whole country/replace carriertype within country/add and do not delete from original generators)
|
||||||
|
restrict_buildyear: 2050 #delete generators built in between x-2050
|
||||||
|
|
||||||
atlite:
|
atlite:
|
||||||
nprocesses: 4
|
nprocesses: 4
|
||||||
|
@ -18,6 +18,31 @@ def country_alpha_2(name):
|
|||||||
cntry = pyc.countries.get(official_name=name)
|
cntry = pyc.countries.get(official_name=name)
|
||||||
return cntry.alpha_2
|
return cntry.alpha_2
|
||||||
|
|
||||||
|
def add_my_carriers(ppl):
|
||||||
|
switch = snakemake.config['electricity']['my_carriers_switch']
|
||||||
|
if switch == 'replace-all' or switch == 'replace-selection' or switch == 'add':
|
||||||
|
countries_dict = snakemake.config['countries_dict'] # dictionary, eg. GB: United Kindgom
|
||||||
|
for country in snakemake.config['electricity']['my_carriers_for_countries']:
|
||||||
|
dirname = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
|
||||||
|
add_ppls = pd.read_csv(dirname + "/resources/powerplants_" + country + ".csv", index_col=0)
|
||||||
|
if switch == 'replace-all' or switch == 'replace-selection':
|
||||||
|
to_drop = ppl[ppl.Country == countries_dict[country]]
|
||||||
|
if switch == 'replace-selection':
|
||||||
|
to_drop = to_drop[to_drop.Fueltype.isin(add_ppls.groupby('Fueltype').mean().index)]
|
||||||
|
ppl = ppl.drop(to_drop.index)
|
||||||
|
ppl = ppl.append(add_ppls, sort='False')
|
||||||
|
else:
|
||||||
|
logger.warning('my_carriers_switch is invalid keyword, try one of [add, replace-all, replace-selection]. powerplants remain unchanged.')
|
||||||
|
return ppl
|
||||||
|
|
||||||
|
def restrict_buildyear(ppl):
|
||||||
|
year = snakemake.config['electricity']['restrict_buildyear']
|
||||||
|
search_pattern = [str(int(year)+x) for x in range(1,2050-int(year))]
|
||||||
|
logger.info('restricting build year of generators to ' + str(year) + '...')
|
||||||
|
for pattern in search_pattern: #do it in forloop+contains instead of map as YearCommissioned might have the weirdest formats
|
||||||
|
ppl = ppl[ppl['YearCommissioned'].str.contains(pattern) == False]
|
||||||
|
return ppl
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if 'snakemake' not in globals():
|
if 'snakemake' not in globals():
|
||||||
from vresutils.snakemake import MockSnakemake, Dict
|
from vresutils.snakemake import MockSnakemake, Dict
|
||||||
@ -38,6 +63,8 @@ if __name__ == "__main__":
|
|||||||
df.Fueltype.where(df.Fueltype != 'Natural Gas',
|
df.Fueltype.where(df.Fueltype != 'Natural Gas',
|
||||||
df.Technology.replace('Steam Turbine', 'OCGT').fillna('OCGT'))))
|
df.Technology.replace('Steam Turbine', 'OCGT').fillna('OCGT'))))
|
||||||
.pipe(ppm.utils.fill_geoposition))
|
.pipe(ppm.utils.fill_geoposition))
|
||||||
|
ppl = add_my_carriers(ppl) # add carriers from own powerplant files
|
||||||
|
ppl = restrict_buildyear(ppl)
|
||||||
|
|
||||||
# ppl.loc[(ppl.Fueltype == 'Other') & ppl.Technology.str.contains('CCGT'), 'Fueltype'] = 'CCGT'
|
# 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'
|
# ppl.loc[(ppl.Fueltype == 'Other') & ppl.Technology.str.contains('Steam Turbine'), 'Fueltype'] = 'CCGT'
|
||||||
|
Loading…
Reference in New Issue
Block a user