-
Notifications
You must be signed in to change notification settings - Fork 28
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
refactor: standardize trip filtering; add an invariant model integration test #343
refactor: standardize trip filtering; add an invariant model integration test #343
Conversation
You might want to change the target branch to |
prereise/gather/demanddata/transportation_electrification/data_helper.py
Show resolved
Hide resolved
@@ -207,6 +250,8 @@ def immediate_charging( | |||
flag_translation = {1: "weekend", 2: "weekday"} | |||
for i, weekday_flag in enumerate(input_day): | |||
daily_profile = daily_resampled_profiles[flag_translation[weekday_flag]] | |||
# print(f"day: {i}") | |||
# print(f"daily sum: {np.sum(daily_profile)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep these comments?
prereise/gather/demanddata/transportation_electrification/smart_charging.py
Outdated
Show resolved
Hide resolved
prereise/gather/demanddata/transportation_electrification/smart_charging.py
Outdated
Show resolved
Hide resolved
prereise/gather/demanddata/transportation_electrification/smart_charging.py
Outdated
Show resolved
Hide resolved
prereise/gather/demanddata/transportation_electrification/smart_charging.py
Outdated
Show resolved
Hide resolved
return daily_vmt_total | ||
|
||
|
||
def get_total_hdv_daily_vmt(data: pd.DataFrame, veh_range): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, we move the vehicle range logic into the charging function for immediate charging which mirrors what we do for smart charging, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. When this function is called, the vehicle range filter has already been applied and thus is no longer used in this function.
@@ -109,6 +110,7 @@ def immediate_charging( | |||
veh_type, | |||
filepath, | |||
trip_strategy=1, | |||
input_day=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to update the doc strings for this parameter below.
prereise/gather/demanddata/transportation_electrification/immediate.py
Outdated
Show resolved
Hide resolved
prereise/gather/demanddata/transportation_electrification/immediate.py
Outdated
Show resolved
Hide resolved
prereise/gather/demanddata/transportation_electrification/immediate.py
Outdated
Show resolved
Hide resolved
prereise/gather/demanddata/transportation_electrification/smart_charging.py
Outdated
Show resolved
Hide resolved
) | ||
|
||
|
||
def test_immediate_charging_hdv_1day(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can merge this test with the previous one simply by plugging in different veh_type
and kwhmi
?
@@ -42,7 +153,7 @@ def test_immediate_charging_region1(): | |||
|
|||
daily_values = generate_daily_weighting(2017) | |||
|
|||
final_result = adjust_bev( | |||
adjust_bev( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we just run it without checking the results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question below. If we keep these tests for integration test purpose given "unit" tests are added above, should we mark it as integration test with @pytest.mark.integration
?
...ather/demanddata/transportation_electrification/tests/test_immediate_charging_integration.py
Show resolved
Hide resolved
) | ||
|
||
|
||
def test_smart_charging(): | ||
def test_smart_charging_ldv_2days(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to merge the three tests by looping through several parameters but not sure that's worth the effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed with @dmuldrew and @danlivengood during the meeting, this is good to go at this point after the linter is happy and the commit history is cleaned up. Thanks.
fix: separate trip filter ops to pass integration test
fix: missed_vehicles concatenation refactor: refine filtering; unneeded print statements fix: add nd_len back where needed refactor: parameter specification, indexing refinement chore: linter complaints resolved
8a60120
to
69f1e0d
Compare
…ntegration_test refactor: standardize trip filtering; add an invariant model integration test
Pull Request doc
Purpose
Incorporates changes from @danlivengood to match “immediate” and “smart charging” daily charging output results. Replaces existing integration test with a dimensionless invariant calculation that should equal 1 for the model.
What the code is doing
Standardizes the trip filtering between immediate and smart charging implementations.
Also adds the following automated test:
which checks that the daily load output over the trip window (adjusted by charging efficiency) equals the vehicles miles travel times a kWh per mile factor.
Testing
Manual and automated testing
Where to look
Files in the transportation electrification folder
Time estimate
~1hr