From eba498a7ca6bb0a2668f92dacd07e41497f0d449 Mon Sep 17 00:00:00 2001 From: GregorRyb Date: Thu, 16 May 2024 15:04:34 +0200 Subject: [PATCH] add create_ref.py --- src/main/python/create_ref.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/python/create_ref.py diff --git a/src/main/python/create_ref.py b/src/main/python/create_ref.py new file mode 100644 index 0000000..f14677d --- /dev/null +++ b/src/main/python/create_ref.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from matsim.scenariogen.data import TripMode, run_create_ref_data + + +def person_filter(df): + """ Default person filter for reference data. """ + return df[df.reporting_day <= 5] + + +def trip_filter(df): + # Motorcycles are counted as cars + df.loc[df.main_mode == TripMode.MOTORCYCLE, "main_mode"] = TripMode.CAR + + # Other modes are ignored in the total share + # Long distance mode are ignored as well + return df[(df.main_mode != "other") & (df.gis_length < 100)] + + +if __name__ == "__main__": + person, trips, share = run_create_ref_data.create("../../../../shared-svn/projects/NaMAV/data/SrV_2018", + person_filter, trip_filter, + run_create_ref_data.InvalidHandling.REMOVE_PERSONS) + + print(share)