Skip to content

Commit

Permalink
feat: generate charging profiles for smart charging HDV (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuldrew authored and rouille committed Jan 12, 2023
1 parent 46e0d5e commit 4c48918
Show file tree
Hide file tree
Showing 3 changed files with 624 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ def load_data(census_region: int, filepath: str = "nhts_census_updated.mat"):
return census_data


def load_hdv_data(veh_type, filepath: str = "fdata_v10st.mat"):
def load_hdv_data(
veh_type,
filepath=os.path.join(
os.path.dirname(inspect.getsourcefile(prereise)),
"gather",
"demanddata",
"transportation_electrification",
"data",
"fdata_v10st.mat",
),
):
"""Load the data at fdata_v10st.mat.
:param str filepath: the path to the matfile.
Expand Down Expand Up @@ -324,19 +334,22 @@ def get_total_daily_vmt(data: pd.DataFrame, input_day, daily_values):
return daily_vmt_total


def get_hdv_daily_vmt_total(
data: pd.DataFrame,
):
def get_total_hdv_daily_vmt(data: pd.DataFrame, veh_range):
"""Calculates the total VMT and total vehicles for for each day of the model year,
based on if the day is a weekend (1) or weekday (2).
based on vehicle range.
:param pandas.DataFrame data: the data returned from :func:`load_data`.
:param int veh_range: 100, 200, or 300, represents how far vehicle can travel on single charge.
:return: (*np.array*) -- an array where each element is the daily VMT and total
vehicles for that day.
:raises ValueError: if ``veh_range`` is not 100, 200, or 300
"""
allowable_ranges = {100, 200, 300}
if veh_range not in allowable_ranges:
raise ValueError(f"veh_range must be one of {allowable_ranges}")

range_vmt = data["Trip Distance"].copy()
range_vmt[data["Total Vehicle Miles"] > veh_range] = 0
daily_vmt_total = sum(range_vmt) * np.ones(365)

return daily_vmt_total
Loading

0 comments on commit 4c48918

Please sign in to comment.