small clean up

This commit is contained in:
lisazeyen 2022-08-09 21:30:45 +02:00
parent 1920c2bae1
commit b42e76040d
2 changed files with 17 additions and 12 deletions

View File

@ -42,7 +42,12 @@ scenario:
# decay with initial growth rate 0 # decay with initial growth rate 0
planning_horizons: # investment years for myopic and perfect; or costs year for overnight planning_horizons: # investment years for myopic and perfect; or costs year for overnight
- 2030 - 2030
# for example, set to [2020, 2030, 2040, 2050] for myopic foresight # for example, set to
# - 2020
# - 2030
# - 2040
# - 2050
# for myopic foresight
# CO2 budget as a fraction of 1990 emissions # CO2 budget as a fraction of 1990 emissions
# this is over-ridden if CO2Lx is set in sector_opts # this is over-ridden if CO2Lx is set in sector_opts

View File

@ -157,12 +157,12 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
# Intermediate fix for DateIn & DateOut # Intermediate fix for DateIn & DateOut
# Fill missing DateIn # Fill missing DateIn
Biomass = df_agg.loc[df_agg.Fueltype=='urban central solid biomass CHP'].index biomass_i = df_agg.loc[df_agg.Fueltype=='urban central solid biomass CHP'].index
mean = df_agg.loc[Biomass, 'DateIn'].mean() mean = df_agg.loc[biomass_i, 'DateIn'].mean()
df_agg.loc[Biomass, 'DateIn'] = df_agg.loc[Biomass, 'DateIn'].fillna(int(mean)) df_agg.loc[biomass_i, 'DateIn'] = df_agg.loc[biomass_i, 'DateIn'].fillna(int(mean))
# Fill missing DateOut # Fill missing DateOut
dateout = df_agg.loc[Biomass, 'DateIn'] + snakemake.config['costs']['lifetime'] dateout = df_agg.loc[biomass_i, 'DateIn'] + snakemake.config['costs']['lifetime']
df_agg.loc[Biomass, 'DateOut'] = df_agg.loc[Biomass, 'DateOut'].fillna(dateout) df_agg.loc[biomass_i, 'DateOut'] = df_agg.loc[biomass_i, 'DateOut'].fillna(dateout)
# drop assets which are already phased out / decomissioned # drop assets which are already phased out / decomissioned
@ -442,10 +442,10 @@ def add_heating_capacities_installed_before_baseyear(n, baseyear, grouping_years
for i, grouping_year in enumerate(grouping_years): for i, grouping_year in enumerate(grouping_years):
if int(grouping_year) + default_lifetime <= int(baseyear): if int(grouping_year) + default_lifetime <= int(baseyear):
ratio = 0 continue
else:
# installation is assumed to be linear for the past 25 years (default lifetime) # installation is assumed to be linear for the past 25 years (default lifetime)
ratio = (int(grouping_year) - int(grouping_years[i-1])) / default_lifetime ratio = (int(grouping_year) - int(grouping_years[i-1])) / default_lifetime
n.madd("Link", n.madd("Link",
nodes[name], nodes[name],
@ -509,7 +509,7 @@ def add_heating_capacities_installed_before_baseyear(n, baseyear, grouping_years
# delete links with p_nom=nan corresponding to extra nodes in country # delete links with p_nom=nan corresponding to extra nodes in country
n.mremove("Link", [index for index in n.links.index.to_list() if str(grouping_year) in index and np.isnan(n.links.p_nom[index])]) n.mremove("Link", [index for index in n.links.index.to_list() if str(grouping_year) in index and np.isnan(n.links.p_nom[index])])
# delete links if their lifetime is over and p_nom=0 # delete links with capacities below threshold
threshold = snakemake.config['existing_capacities']['threshold_capacity'] threshold = snakemake.config['existing_capacities']['threshold_capacity']
n.mremove("Link", [index for index in n.links.index.to_list() if str(grouping_year) in index and n.links.p_nom[index] < threshold]) n.mremove("Link", [index for index in n.links.index.to_list() if str(grouping_year) in index and n.links.p_nom[index] < threshold])
@ -524,7 +524,7 @@ if __name__ == "__main__":
lv=1.0, lv=1.0,
opts='', opts='',
sector_opts='365H-T-H-B-I-A-solar+p3-dist1', sector_opts='365H-T-H-B-I-A-solar+p3-dist1',
planning_horizons=2020, planning_horizons=2030,
) )
logging.basicConfig(level=snakemake.config['logging_level']) logging.basicConfig(level=snakemake.config['logging_level'])