remove remaining {weather_year} wildcard usages
This commit is contained in:
parent
1f7d4da3e6
commit
249cfab429
@ -805,14 +805,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
n = pypsa.Network(snakemake.input.base_network)
|
n = pypsa.Network(snakemake.input.base_network)
|
||||||
|
|
||||||
weather_year = snakemake.wildcards.weather_year
|
n.set_snapshots(pd.date_range(freq="h", **snakemake.params.snapshots))
|
||||||
if weather_year:
|
|
||||||
snapshots = dict(
|
|
||||||
start=weather_year, end=str(int(weather_year) + 1), inclusive="left"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.config["snapshots"]
|
|
||||||
n.set_snapshots(pd.date_range(freq="h", **snapshots))
|
|
||||||
|
|
||||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||||
|
|
||||||
|
@ -20,14 +20,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
weather_year = snakemake.wildcards.weather_year
|
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
if weather_year:
|
|
||||||
snapshots = dict(
|
|
||||||
start=weather_year, end=str(int(weather_year) + 1), inclusive="left"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.config["snapshots"]
|
|
||||||
snapshots = pd.date_range(freq="h", **snapshots)
|
|
||||||
|
|
||||||
fixed_year = snakemake.config["load"].get("fixed_year", False)
|
fixed_year = snakemake.config["load"].get("fixed_year", False)
|
||||||
years = (
|
years = (
|
||||||
|
@ -25,11 +25,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
cutout_name = snakemake.input.cutout
|
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||||
year = snakemake.wildcards.weather_year
|
|
||||||
if year:
|
|
||||||
cutout_name = cutout_name.format(weather_year=year)
|
|
||||||
cutout = atlite.Cutout(cutout_name)
|
|
||||||
|
|
||||||
clustered_regions = (
|
clustered_regions = (
|
||||||
gpd.read_file(snakemake.input.regions_onshore).set_index("name").buffer(0)
|
gpd.read_file(snakemake.input.regions_onshore).set_index("name").buffer(0)
|
||||||
|
@ -109,10 +109,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
cutout_params = snakemake.params.cutouts[snakemake.wildcards.cutout]
|
cutout_params = snakemake.params.cutouts[snakemake.wildcards.cutout]
|
||||||
|
|
||||||
if hasattr(snakemake.wildcards, "weather_year"):
|
|
||||||
time = snakemake.wildcards.weather_year
|
|
||||||
cutout_params["time"] = [time, time]
|
|
||||||
|
|
||||||
if "time" not in cutout_params:
|
if "time" not in cutout_params:
|
||||||
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
cutout_params["time"] = [snapshots[0], snapshots[-1]]
|
cutout_params["time"] = [snapshots[0], snapshots[-1]]
|
||||||
|
@ -31,16 +31,9 @@ if __name__ == "__main__":
|
|||||||
client = Client(cluster, asynchronous=True)
|
client = Client(cluster, asynchronous=True)
|
||||||
|
|
||||||
cutout_name = snakemake.input.cutout
|
cutout_name = snakemake.input.cutout
|
||||||
year = snakemake.wildcards.weather_year
|
|
||||||
|
|
||||||
if year:
|
time = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
snapshots = dict(start=year, end=str(int(year) + 1), inclusive="left")
|
daily = pd.date_range(freq="D", **snakemake.params.snapshots)
|
||||||
cutout_name = cutout_name.format(weather_year=year)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.params.snapshots
|
|
||||||
|
|
||||||
time = pd.date_range(freq="h", **snapshots)
|
|
||||||
daily = pd.date_range(freq="D", **snapshots)
|
|
||||||
if snakemake.params.drop_leap_day:
|
if snakemake.params.drop_leap_day:
|
||||||
time = time[~((time.month == 2) & (time.day == 29))]
|
time = time[~((time.month == 2) & (time.day == 29))]
|
||||||
daily = daily[~((daily.month == 2) & (daily.day == 29))]
|
daily = daily[~((daily.month == 2) & (daily.day == 29))]
|
||||||
|
@ -263,14 +263,7 @@ if __name__ == "__main__":
|
|||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
weather_year = snakemake.wildcards.weather_year
|
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
if weather_year:
|
|
||||||
snapshots = dict(
|
|
||||||
start=weather_year, end=str(int(weather_year) + 1), inclusive="left"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.params.snapshots
|
|
||||||
snapshots = pd.date_range(freq="h", **snapshots)
|
|
||||||
|
|
||||||
fixed_year = snakemake.config["load"].get("fixed_year", False)
|
fixed_year = snakemake.config["load"].get("fixed_year", False)
|
||||||
years = (
|
years = (
|
||||||
|
@ -24,14 +24,7 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
year = snakemake.wildcards.weather_year
|
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
|
|
||||||
if year:
|
|
||||||
snapshots = dict(start=year, end=str(int(year) + 1), inclusive="left")
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.params.snapshots
|
|
||||||
|
|
||||||
snapshots = pd.date_range(freq="h", **snapshots)
|
|
||||||
if snakemake.params.drop_leap_day:
|
if snakemake.params.drop_leap_day:
|
||||||
snapshots = snapshots[~((snapshots.month == 2) & (snapshots.day == 29))]
|
snapshots = snapshots[~((snapshots.month == 2) & (snapshots.day == 29))]
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ import atlite
|
|||||||
import country_converter as coco
|
import country_converter as coco
|
||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from _helpers import configure_logging, set_scenario_config
|
|
||||||
from numpy.polynomial import Polynomial
|
from numpy.polynomial import Polynomial
|
||||||
|
from _helpers import configure_logging, set_scenario_config
|
||||||
|
|
||||||
cc = coco.CountryConverter()
|
cc = coco.CountryConverter()
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ if __name__ == "__main__":
|
|||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
snakemake = mock_snakemake("build_hydro_profile", weather_year="")
|
snakemake = mock_snakemake("build_hydro_profile")
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
@ -197,12 +197,12 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
eia_stats.to_csv(snakemake.output.eia_hydro)
|
eia_stats.to_csv(snakemake.output.eia_hydro)
|
||||||
|
|
||||||
weather_year = snakemake.wildcards.weather_year
|
contained_years = pd.date_range(freq="YE", **snakemake.params.snapshots).year
|
||||||
norm_year = config_hydro.get("eia_norm_year")
|
norm_year = config_hydro.get("eia_norm_year")
|
||||||
if norm_year:
|
if norm_year:
|
||||||
eia_stats.loc[weather_year] = eia_stats.loc[norm_year]
|
eia_stats.loc[contained_years] = eia_stats.loc[norm_year]
|
||||||
elif weather_year and weather_year not in eia_stats.index:
|
elif missing_years := eia_stats.index.difference(contained_years):
|
||||||
eia_stats.loc[weather_year] = eia_stats.median()
|
eia_stats.loc[missing_years] = eia_stats.median()
|
||||||
|
|
||||||
inflow = cutout.runoff(
|
inflow = cutout.runoff(
|
||||||
shapes=country_shapes,
|
shapes=country_shapes,
|
||||||
|
@ -28,11 +28,7 @@ if __name__ == "__main__":
|
|||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
cutout_name = snakemake.input.cutout
|
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||||
year = snakemake.wildcards.weather_year
|
|
||||||
if year:
|
|
||||||
cutout_name = cutout_name.format(weather_year=year)
|
|
||||||
cutout = atlite.Cutout(cutout_name)
|
|
||||||
|
|
||||||
grid_cells = cutout.grid.geometry
|
grid_cells = cutout.grid.geometry
|
||||||
|
|
||||||
|
@ -21,9 +21,13 @@ if __name__ == "__main__":
|
|||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
config = snakemake.config["energy"]
|
config = snakemake.config["energy"]
|
||||||
data_year = int(config["energy_totals_year"])
|
|
||||||
if snakemake.wildcards.weather_year and snakemake.wildcards.kind == "heat":
|
if snakemake.wildcards.kind == "heat":
|
||||||
data_year = int(snakemake.wildcards.weather_year)
|
years = pd.date_range(freq="YE", **snakemake.config["snapshots"]).year
|
||||||
|
assert len(years) == 1, "Currently only works for single year."
|
||||||
|
data_year = years[0]
|
||||||
|
else:
|
||||||
|
data_year = int(config["energy_totals_year"])
|
||||||
|
|
||||||
pop_layout = pd.read_csv(snakemake.input.clustered_pop_layout, index_col=0)
|
pop_layout = pd.read_csv(snakemake.input.clustered_pop_layout, index_col=0)
|
||||||
|
|
||||||
|
@ -229,14 +229,7 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
client = None
|
client = None
|
||||||
|
|
||||||
weather_year = snakemake.wildcards.weather_year
|
sns = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
if weather_year:
|
|
||||||
snapshots = dict(
|
|
||||||
start=weather_year, end=str(int(weather_year) + 1), inclusive="left"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.params.snapshots
|
|
||||||
sns = pd.date_range(freq="h", **snapshots)
|
|
||||||
|
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=sns)
|
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=sns)
|
||||||
regions = gpd.read_file(snakemake.input.regions)
|
regions = gpd.read_file(snakemake.input.regions)
|
||||||
|
@ -32,20 +32,11 @@ if __name__ == "__main__":
|
|||||||
config = snakemake.params.solar_thermal
|
config = snakemake.params.solar_thermal
|
||||||
config.pop("cutout", None)
|
config.pop("cutout", None)
|
||||||
|
|
||||||
cutout_name = snakemake.input.cutout
|
time = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
year = snakemake.wildcards.weather_year
|
|
||||||
|
|
||||||
if year:
|
|
||||||
snapshots = dict(start=year, end=str(int(year) + 1), inclusive="left")
|
|
||||||
cutout_name = cutout_name.format(weather_year=year)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.params.snapshots
|
|
||||||
|
|
||||||
time = pd.date_range(freq="h", **snapshots)
|
|
||||||
if snakemake.params.drop_leap_day:
|
if snakemake.params.drop_leap_day:
|
||||||
time = time[~((time.month == 2) & (time.day == 29))]
|
time = time[~((time.month == 2) & (time.day == 29))]
|
||||||
|
|
||||||
cutout = atlite.Cutout(cutout_name).sel(time=time)
|
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||||
|
|
||||||
clustered_regions = (
|
clustered_regions = (
|
||||||
gpd.read_file(snakemake.input.regions_onshore).set_index("name").buffer(0)
|
gpd.read_file(snakemake.input.regions_onshore).set_index("name").buffer(0)
|
||||||
|
@ -20,7 +20,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake(
|
snakemake = mock_snakemake(
|
||||||
"build_temperature_profiles",
|
"build_temperature_profiles",
|
||||||
weather_year="",
|
|
||||||
simpl="",
|
simpl="",
|
||||||
clusters=48,
|
clusters=48,
|
||||||
)
|
)
|
||||||
@ -29,20 +28,12 @@ if __name__ == "__main__":
|
|||||||
nprocesses = int(snakemake.threads)
|
nprocesses = int(snakemake.threads)
|
||||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||||
client = Client(cluster, asynchronous=True)
|
client = Client(cluster, asynchronous=True)
|
||||||
cutout_name = snakemake.input.cutout
|
|
||||||
year = snakemake.wildcards.weather_year
|
|
||||||
|
|
||||||
if year:
|
time = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||||
snapshots = dict(start=year, end=str(int(year) + 1), inclusive="left")
|
|
||||||
cutout_name = cutout_name.format(weather_year=year)
|
|
||||||
else:
|
|
||||||
snapshots = snakemake.params.snapshots
|
|
||||||
|
|
||||||
time = pd.date_range(freq="h", **snapshots)
|
|
||||||
if snakemake.params.drop_leap_day:
|
if snakemake.params.drop_leap_day:
|
||||||
time = time[~((time.month == 2) & (time.day == 29))]
|
time = time[~((time.month == 2) & (time.day == 29))]
|
||||||
|
|
||||||
cutout = atlite.Cutout(cutout_name).sel(time=time)
|
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||||
|
|
||||||
clustered_regions = (
|
clustered_regions = (
|
||||||
gpd.read_file(snakemake.input.regions_onshore).set_index("name").buffer(0)
|
gpd.read_file(snakemake.input.regions_onshore).set_index("name").buffer(0)
|
||||||
|
@ -183,13 +183,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
options = snakemake.params.sector
|
options = snakemake.params.sector
|
||||||
|
|
||||||
year = snakemake.wildcards.weather_year
|
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots, tz="UTC")
|
||||||
snapshots = (
|
|
||||||
dict(start=year, end=str(int(year) + 1), inclusive="left")
|
|
||||||
if year
|
|
||||||
else snakemake.params.snapshots
|
|
||||||
)
|
|
||||||
snapshots = pd.date_range(freq="h", **snapshots, tz="UTC")
|
|
||||||
if snakemake.params.drop_leap_day:
|
if snakemake.params.drop_leap_day:
|
||||||
leap_day = (snapshots.month == 2) & (snapshots.day == 29)
|
leap_day = (snapshots.month == 2) & (snapshots.day == 29)
|
||||||
snapshots = snapshots[~leap_day]
|
snapshots = snapshots[~leap_day]
|
||||||
|
Loading…
Reference in New Issue
Block a user