merge master
This commit is contained in:
parent
30beee0959
commit
e16fa286ec
@ -8,4 +8,4 @@ interpolate_limit,hours,integer,"Maximum gap size (consecutive nans) which inter
|
||||
time_shift_for_large_gaps,string,string,"Periods which are used for copying time-slices in order to fill large gaps of nans. Have to be valid ``pandas`` period strings."
|
||||
manual_adjustments,bool,"{true, false}","Whether to adjust the load data manually according to the function in :func:`manual_adjustment`."
|
||||
scaling_factor,--,float,"Global correction factor for the load time series."
|
||||
fixed_year,--,Year or False,"To specify a fixed year for the load time series that deviates from the snapshots' year"
|
||||
fixed_year,--,Year or False,"To specify a fixed year for the load time series that deviates from the snapshots' year"
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -22,20 +22,25 @@ rule all:
|
||||
|
||||
rule cluster_networks:
|
||||
input:
|
||||
expand(RESOURCES + "networks/elec{weather_year}_s{simpl}_{clusters}.nc", **config["scenario"]),
|
||||
expand(
|
||||
RESOURCES + "networks/elec{weather_year}_s{simpl}_{clusters}.nc",
|
||||
**config["scenario"]
|
||||
),
|
||||
|
||||
|
||||
rule extra_components_networks:
|
||||
input:
|
||||
expand(
|
||||
RESOURCES + "networks/elec{weather_year}_s{simpl}_{clusters}_ec.nc", **config["scenario"]
|
||||
RESOURCES + "networks/elec{weather_year}_s{simpl}_{clusters}_ec.nc",
|
||||
**config["scenario"]
|
||||
),
|
||||
|
||||
|
||||
rule prepare_elec_networks:
|
||||
input:
|
||||
expand(
|
||||
RESOURCES + "networks/elec{weather_year}_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||
RESOURCES
|
||||
+ "networks/elec{weather_year}_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||
**config["scenario"]
|
||||
),
|
||||
|
||||
@ -52,7 +57,8 @@ rule prepare_sector_networks:
|
||||
rule solve_elec_networks:
|
||||
input:
|
||||
expand(
|
||||
RESULTS + "networks/elec{weather_year}_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||
RESULTS
|
||||
+ "networks/elec{weather_year}_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||
**config["scenario"]
|
||||
),
|
||||
|
||||
|
@ -701,19 +701,20 @@ def add_nice_carrier_names(n, config):
|
||||
n.carriers["color"] = colors
|
||||
|
||||
|
||||
|
||||
def drop_leap_day(n):
|
||||
if not n.snapshots.is_leap_year.any(): return
|
||||
if not n.snapshots.is_leap_year.any():
|
||||
return
|
||||
leap_days = (n.snapshots.day == 29) & (n.snapshots.month == 2)
|
||||
n.set_snapshots(n.snapshots[~leap_days])
|
||||
n.snapshot_weightings[:] = 8760/len(n.snapshots)
|
||||
n.snapshot_weightings[:] = 8760 / len(n.snapshots)
|
||||
logger.info("Dropped February 29 from leap year.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
snakemake = mock_snakemake('add_electricity', weather_year='')
|
||||
|
||||
snakemake = mock_snakemake("add_electricity", weather_year="")
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.base_network)
|
||||
@ -721,15 +722,13 @@ if __name__ == "__main__":
|
||||
weather_year = snakemake.wildcards.weather_year
|
||||
if weather_year:
|
||||
snapshots = dict(
|
||||
start=weather_year,
|
||||
end=str(int(weather_year)+1),
|
||||
closed="left"
|
||||
start=weather_year, end=str(int(weather_year) + 1), closed="left"
|
||||
)
|
||||
else:
|
||||
snapshots = snakemake.config['snapshots']
|
||||
n.set_snapshots(pd.date_range(freq='h', **snapshots))
|
||||
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.
|
||||
snapshots = snakemake.config["snapshots"]
|
||||
n.set_snapshots(pd.date_range(freq="h", **snapshots))
|
||||
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||
|
||||
costs = load_costs(
|
||||
snakemake.input.tech_costs,
|
||||
@ -855,7 +854,7 @@ if __name__ == "__main__":
|
||||
|
||||
add_nice_carrier_names(n, snakemake.config)
|
||||
|
||||
if snakemake.config['enable'].get('drop_leap_days', True):
|
||||
if snakemake.config["enable"].get("drop_leap_days", True):
|
||||
drop_leap_day(n)
|
||||
|
||||
n.meta = snakemake.config
|
||||
|
@ -230,8 +230,10 @@ def attach_hydrogen_pipelines(n, costs, elec_opts):
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
snakemake = mock_snakemake('add_extra_components', weather_year='',
|
||||
simpl='', clusters=5)
|
||||
|
||||
snakemake = mock_snakemake(
|
||||
"add_extra_components", weather_year="", simpl="", clusters=5
|
||||
)
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.network)
|
||||
|
@ -108,15 +108,15 @@ if __name__ == "__main__":
|
||||
|
||||
cutout_params = snakemake.config["atlite"]["cutouts"][snakemake.wildcards.cutout]
|
||||
|
||||
if hasattr(snakemake.wildcards, 'weather_year'):
|
||||
if hasattr(snakemake.wildcards, "weather_year"):
|
||||
time = snakemake.wildcards.weather_year
|
||||
cutout_params["time"] = [time, time]
|
||||
|
||||
if "time" not in cutout_params:
|
||||
snapshots = pd.date_range(freq='h', **snakemake.config['snapshots'])
|
||||
cutout_params["time"] = [snapshots[0], snapshots[-1]]
|
||||
snapshots = pd.date_range(freq="h", **snakemake.config["snapshots"])
|
||||
cutout_params["time"] = [snapshots[0], snapshots[-1]]
|
||||
|
||||
cutout_params['time'] = slice(*cutout_params['time'])
|
||||
cutout_params["time"] = slice(*cutout_params["time"])
|
||||
|
||||
if {"x", "y", "bounds"}.isdisjoint(cutout_params):
|
||||
# Determine the bounds from bus regions with a buffer of two grid cells
|
||||
|
@ -275,23 +275,25 @@ if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
||||
snakemake = mock_snakemake("build_electricity_demand", weather_year='')
|
||||
snakemake = mock_snakemake("build_electricity_demand", weather_year="")
|
||||
|
||||
configure_logging(snakemake)
|
||||
|
||||
weather_year = snakemake.wildcards.weather_year
|
||||
if weather_year:
|
||||
snapshots = dict(
|
||||
start=weather_year,
|
||||
end=str(int(weather_year)+1),
|
||||
closed="left"
|
||||
start=weather_year, end=str(int(weather_year) + 1), closed="left"
|
||||
)
|
||||
else:
|
||||
snapshots = snakemake.config['snapshots']
|
||||
snapshots = pd.date_range(freq='h', **snapshots)
|
||||
snapshots = snakemake.config["snapshots"]
|
||||
snapshots = pd.date_range(freq="h", **snapshots)
|
||||
|
||||
fixed_year = snakemake.config["load"].get("fixed_year", False)
|
||||
years = slice(str(fixed_year), str(fixed_year)) if fixed_year else slice(snapshots[0], snapshots[-1])
|
||||
years = (
|
||||
slice(str(fixed_year), str(fixed_year))
|
||||
if fixed_year
|
||||
else slice(snapshots[0], snapshots[-1])
|
||||
)
|
||||
|
||||
powerstatistics = snakemake.config["load"]["power_statistics"]
|
||||
interpolate_limit = snakemake.config["load"]["interpolate_limit"]
|
||||
|
@ -65,9 +65,8 @@ import atlite
|
||||
import country_converter as coco
|
||||
import geopandas as gpd
|
||||
import pandas as pd
|
||||
from numpy.polynomial import Polynomial
|
||||
from _helpers import configure_logging
|
||||
|
||||
from numpy.polynomial import Polynomial
|
||||
|
||||
cc = coco.CountryConverter()
|
||||
|
||||
@ -132,11 +131,10 @@ def correct_eia_stats_by_capacity(eia_stats, fn, countries, baseyear=2019):
|
||||
eia_stats_corrected = eia_stats / ratio
|
||||
to_keep = ["AL", "AT", "CH", "DE", "GB", "NL", "RS", "RO", "SK"]
|
||||
to_correct = eia_stats_corrected.columns.difference(to_keep)
|
||||
eia_stats.loc[:,to_correct] = eia_stats_corrected.loc[:,to_correct]
|
||||
eia_stats.loc[:, to_correct] = eia_stats_corrected.loc[:, to_correct]
|
||||
|
||||
|
||||
def approximate_missing_eia_stats(eia_stats, runoff_fn, countries):
|
||||
|
||||
runoff = pd.read_csv(runoff_fn, index_col=0).T[countries]
|
||||
|
||||
# fix ES, PT data points
|
||||
@ -147,7 +145,6 @@ def approximate_missing_eia_stats(eia_stats, runoff_fn, countries):
|
||||
eia_stats_approximated = {}
|
||||
|
||||
for c in countries:
|
||||
|
||||
X = runoff_eia[c]
|
||||
Y = eia_stats[c]
|
||||
|
||||
@ -168,7 +165,8 @@ logger = logging.getLogger(__name__)
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
snakemake = mock_snakemake('build_hydro_profile', weather_year='')
|
||||
|
||||
snakemake = mock_snakemake("build_hydro_profile", weather_year="")
|
||||
configure_logging(snakemake)
|
||||
|
||||
config_hydro = snakemake.config["renewable"]["hydro"]
|
||||
@ -185,18 +183,18 @@ if __name__ == "__main__":
|
||||
fn = snakemake.input.eia_hydro_generation
|
||||
eia_stats = get_eia_annual_hydro_generation(fn, countries)
|
||||
|
||||
if config_hydro.get('eia_correct_by_capacity'):
|
||||
if config_hydro.get("eia_correct_by_capacity"):
|
||||
fn = snakemake.input.eia_hydro_capacity
|
||||
correct_eia_stats_by_capacity(eia_stats, fn, countries)
|
||||
|
||||
if config_hydro.get('eia_approximate_missing'):
|
||||
if config_hydro.get("eia_approximate_missing"):
|
||||
fn = snakemake.input.era5_runoff
|
||||
eia_stats = approximate_missing_eia_stats(eia_stats, fn, countries)
|
||||
|
||||
eia_stats.to_csv(snakemake.output.eia_hydro)
|
||||
|
||||
weather_year = snakemake.wildcards.weather_year
|
||||
norm_year = config_hydro.get('eia_norm_year')
|
||||
norm_year = config_hydro.get("eia_norm_year")
|
||||
if norm_year:
|
||||
eia_stats.loc[weather_year] = eia_stats.loc[norm_year]
|
||||
elif weather_year and weather_year not in eia_stats.index:
|
||||
|
@ -199,7 +199,9 @@ if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
||||
snakemake = mock_snakemake("build_renewable_profiles", technology="solar", weather_year="")
|
||||
snakemake = mock_snakemake(
|
||||
"build_renewable_profiles", technology="solar", weather_year=""
|
||||
)
|
||||
configure_logging(snakemake)
|
||||
|
||||
nprocesses = int(snakemake.threads)
|
||||
|
@ -457,7 +457,9 @@ if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
||||
snakemake = mock_snakemake("cluster_network", simpl="", clusters="5", weather_year="")
|
||||
snakemake = mock_snakemake(
|
||||
"cluster_network", simpl="", clusters="5", weather_year=""
|
||||
)
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.network)
|
||||
|
@ -243,7 +243,12 @@ if __name__ == "__main__":
|
||||
from _helpers import mock_snakemake
|
||||
|
||||
snakemake = mock_snakemake(
|
||||
"prepare_network", weather_year="", simpl="", clusters="40", ll="v0.3", opts="Co2L-24H"
|
||||
"prepare_network",
|
||||
weather_year="",
|
||||
simpl="",
|
||||
clusters="40",
|
||||
ll="v0.3",
|
||||
opts="Co2L-24H",
|
||||
)
|
||||
configure_logging(snakemake)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user