Skip to content

Commit

Permalink
refactor: parameter specification, indexing refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuldrew committed Feb 8, 2023
1 parent 0cbde94 commit 8a60120
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def smart_charging(
kwhmi=None,
trip_strategy=1,
input_day=None,
debug_printout=False,
):
"""Smart charging function
Expand All @@ -74,12 +75,10 @@ def smart_charging(
last trip (2)
:param numpy.ndarray input_day: daily list which specifies 1 if the day is a weekend,
and 2 if the day is a weekday
:param bool debug_printout: specify if additional model parameters will be printed
:return: (*numpy.ndarray*) -- charging profiles.
"""

# for code developer debugging printouts (1 = yes, 0 = no)
debug_printout = 0

# load NHTS data from function
if veh_type.lower() == "ldv":
newdata = data_helper.remove_ldt(data_helper.load_data(census_region, filepath))
Expand Down Expand Up @@ -139,6 +138,8 @@ def smart_charging(
newdata["trip_allowed"] = True
elif trip_strategy == 2:
newdata["trip_allowed"] = newdata["trip_number"] == newdata["total_trips"]
else:
raise ValueError(f"trip_strategy parameter is not valid, i.e. either 1 or 2")

# Add booleans for whether the dwell time is long enough to allow charging
newdata["dwell_allowed"] = newdata["dwell_time"] > 0.2
Expand Down Expand Up @@ -281,12 +282,9 @@ def smart_charging(
individual = newdata.iloc[i : i + total_trips].copy()

individual_vmt += float(
individual.iloc[
0, individual.columns.get_loc("total vehicle miles traveled")
]
individual["total vehicle miles traveled"].iloc[0]
)
individual_trip_miles += float(
individual.iloc[:, individual.columns.get_loc("trip_miles")].sum()
individual_trip_miles += float(individual["trip_miles"].sum()
)

individual["rates"] = individual.apply(
Expand Down Expand Up @@ -467,7 +465,7 @@ def smart_charging(
* bev_vmt
)

if debug_printout == 1:
if debug_printout == True:
output_check_array = (
outputelectricload
/ kwhmi
Expand Down

0 comments on commit 8a60120

Please sign in to comment.