Skip to content

Commit

Permalink
rm obsolete imports
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-galataud committed Oct 31, 2023
1 parent 3d71ea0 commit af649cc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions grafener/energyplus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging
import os
from datetime import datetime, timedelta
from typing import Optional

Expand All @@ -8,8 +6,7 @@


def process_csv(df: DataFrame, sim_year: int) -> DataFrame:
"""
applies necessary transformations to E+ csv output
"""Applies necessary transformations to E+ csv output.
:param df:
:param sim_year:
Expand All @@ -18,7 +15,8 @@ def process_csv(df: DataFrame, sim_year: int) -> DataFrame:
# make a nice datetime format out of Date/Time column
output = df.copy()
output["Date/Time"] = output["Date/Time"].apply(
lambda strd: process_energyplus_datetime(strdate=strd, sim_year=sim_year))
lambda strd: process_energyplus_datetime(strdate=strd, sim_year=sim_year)
)
output["Date/Time"] = pd.to_datetime(output["Date/Time"], format="%Y/%m/%d %H:%M:%S", utc=True)
output.index = output["Date/Time"]
# last column has a trailing space
Expand All @@ -41,13 +39,13 @@ def process_energyplus_datetime(strdate: str, sim_year: int) -> str:
:return:
"""
if month := is_month_full_name(strdate):
return "{:04d}/{:02d}/{:02d} 00:00:00".format(sim_year, month.month, 1)
return f"{sim_year:04d}/{month.month:02d}/{1:02d} 00:00:00"
elif "24:00" in strdate:
date = strdate.strip().split(" ")[0]
new_date = datetime.strptime(date, "%m/%d") + timedelta(days=1)
return "{:04d}/{:02d}/{:02d} 00:00:00".format(sim_year, new_date.month, new_date.day)
return f"{sim_year:04d}/{new_date.month:02d}/{new_date.day:02d} 00:00:00"
else:
concat = "{:04d}/{}".format(sim_year, strdate.strip())
concat = f"{sim_year:04d}/{strdate.strip()}"
# manage 'daily' reporting frequency
if " " not in concat:
concat += " 00:00:00"
Expand All @@ -56,6 +54,6 @@ def process_energyplus_datetime(strdate: str, sim_year: int) -> str:

def is_month_full_name(strdate: str) -> Optional[datetime]:
try:
return datetime.strptime(strdate, '%B')
return datetime.strptime(strdate, "%B")
except ValueError:
return None

0 comments on commit af649cc

Please sign in to comment.