From 2e3224e04a2eb5dca9262936e99058f3022d80ed Mon Sep 17 00:00:00 2001 From: rakow Date: Tue, 31 Oct 2023 11:31:06 +0100 Subject: [PATCH] script for extracting commuter --- src/main/python/extract_commuter.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/python/extract_commuter.py diff --git a/src/main/python/extract_commuter.py b/src/main/python/extract_commuter.py new file mode 100644 index 00000000..8ea8cdbd --- /dev/null +++ b/src/main/python/extract_commuter.py @@ -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) \ No newline at end of file