pypsa-usa
pypsa-usa copied to clipboard
Create utility function for creating snapshots
Feature Request
We have this bit of code in a few places:
snapshot_config = snakemake.config["snapshots"]
sns_start = pd.to_datetime(snapshot_config["start"])
sns_end = pd.to_datetime(snapshot_config["end"])
sns_inclusive = snapshot_config["inclusive"]
snapshots = pd.date_range(
freq="h",
start=sns_start,
end=sns_end,
inclusive=sns_inclusive,
)
We should probably turn it into a utility function that we just pass in the snapshot_config variable and we get the datetime out
Suggested Solution
def create_snapshots(snapshot_config: Dict[str,str]) -> pd.date_range
return pd.date_range(
freq="h",
start=pd.to_datetime(snapshot_config["start"]),
end=pd.to_datetime(snapshot_config["end"]),
inclusive=snapshot_config["inclusive"],
)
Additional Info
No response