Functions to download ERA5/SARAH data and build the atlite cutout for the atlite. These functions linked to the build_cutout rule.
cutout_timespan(config)
build the cutout timespan. Note that the coutout requests are in UTC (TBC)
Parameters: |
|
---|
Returns: |
|
---|
Source code in workflow/scripts/build_cutout.py
def cutout_timespan(config: dict) -> list:
"""build the cutout timespan. Note that the coutout requests are in UTC (TBC)
Args:
config (dict): the snakemake config
Returns:
tuple: end and start of the cutout timespan
"""
snapshot_cfg = config["snapshots"]
# make snapshots for TZ and then convert to naive UTC for atlite
snapshots = (
make_periodic_snapshots(
year=config["atlite"]["weather_year"],
freq=snapshot_cfg["freq"],
start_day_hour=snapshot_cfg["start"],
end_day_hour=snapshot_cfg["end"],
bounds=snapshot_cfg["bounds"],
tz=TIMEZONE,
end_year=(
None if not snapshot_cfg["end_year_plus1"] else config["atlite"]["weather_year"] + 1
),
)
.tz_convert("UTC")
.tz_localize(None)
)
return [snapshots[0], snapshots[-1]]