Skip to content

Commit

Permalink
script for extracting commuter
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Oct 31, 2023
1 parent b975750 commit 2e3224e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/python/extract_commuter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from matsim.scenariogen.data import read_all
from matsim.scenariogen.data.preparation import calc_commute


if __name__ == "__main__":
hh, persons, trips = read_all("../../../../shared-svn/projects/matsim-berlin/data/SrV/Berlin+Umland")

berlin = hh[hh.location == "Berlin"]
bb = hh[hh.location != "Berlin"]

be_persons = persons[persons.hh_id.isin(berlin.index)]
bb_persons = persons[persons.hh_id.isin(bb.index)]

print("Berlin: %s" % len(be_persons))
print("Brandenburg: %s" % len(bb_persons))

berlin_work, berlin_edu = calc_commute(be_persons, trips)
bb_work, bb_edu = calc_commute(bb_persons, trips)

berlin_work.to_csv("berlin_work_commute.csv", index=False)
berlin_edu.to_csv("berlin_edu_commute.csv", index=False)
bb_work.to_csv("bb_work_commute.csv", index=False)
bb_edu.to_csv("bb_edu_commute.csv", index=False)

0 comments on commit 2e3224e

Please sign in to comment.