Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate charging profiles for smart charging HDV #301

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that veh_range values are as expected

daily_vmt_total = sum(range_vmt) * np.ones(365)

return daily_vmt_total
Loading