-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add get_bus_demand method #311
Conversation
I ran the following script:
I killed it after 30 min. How long does it take to run on your machine? |
@rouille I refactored but forgot to push the fix. It runs in <10 seconds now. |
Indeed: --- 7.498027086257935 seconds --- |
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.
Looks good.
powersimdata/scenario/helpers.py
Outdated
zone_idx = zone_idx_lookup[bus.loc[b, "zone_id"]] | ||
bus_to_zone[zone_idx, bus_idx] = bus_zone_share.loc[b] | ||
bus_demand = pd.DataFrame( | ||
np.dot(demand.to_numpy(), bus_to_zone), index=demand.index, columns=bus.index |
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.
To be fancier, we can do demand.to_numpy()@bus_to_zone
here.
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.
Aha! Thanks for pointing this out, it looks much cleaner.
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.
Thanks.
2c07448
to
90eaf9b
Compare
Purpose
Add a method to calculate demand by bus. This came up in some analysis work we've been doing, it'll probably come up again sometime.
What is the code doing
In
helpers.py
: adding a new helper function to decompose zone demand to bus demand.In
create.py
andanalyze.py
: adding a method to use this function.Demonstration / Validation
So the sum looks good, and the shape looks good, what happens if we try to sum back to zone?
Time to review
15 minutes. This is a low priority.