Skip to content

Commit

Permalink
updated mode shares and scripts so that R and python is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Oct 16, 2023
1 parent 50d35e5 commit d0e251e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<parent>
<groupId>org.matsim</groupId>
<artifactId>matsim-all</artifactId>
<version>16.0-PR2745</version>
<!-- <version>16.0-SNAPSHOT</version>-->
<!-- <version>16.0-PR2745</version>-->
<version>16.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
8 changes: 4 additions & 4 deletions src/main/R/Analysis/srv.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ library(ggsci)
library(sf)


# setwd("C:/Users/chris/Development/matsim-scenarios/matsim-leipzig/src/main/R")
# setwd("~/Development/matsim-scenarios/matsim-leipzig/src/main/R")

# Person data from srv
############################

persons <- read_delim("../../../../../shared-svn/projects/NaMAV/data/SrV_2018/SrV2018_Einzeldaten_Leipzig_LE_SciUse_P2018.csv", delim = ";",
persons <- read_delim("../../../../shared-svn/projects/NaMAV/data/SrV_2018/SrV2018_Einzeldaten_Leipzig_LE_SciUse_P2018.csv", delim = ";",
locale = locale(decimal_mark = ",")) %>%
filter(ST_CODE_NAME=="Leipzig") %>%
filter(STICHTAG_WTAG <= 5) %>%
Expand All @@ -29,7 +29,7 @@ tt <- per_day * 600000
# Trip data from srV
#############################

trips <- read_delim("../../../../../shared-svn/projects/NaMAV/data/SrV_2018/SrV2018_Einzeldaten_Leipzig_LE_SciUse_W2018.csv", delim = ";",
trips <- read_delim("../../../../shared-svn/projects/NaMAV/data/SrV_2018/SrV2018_Einzeldaten_Leipzig_LE_SciUse_W2018.csv", delim = ";",
col_types = cols(
V_ZIEL_LAND = col_character(),
GIS_LAENGE = col_double(),
Expand All @@ -52,7 +52,7 @@ relevant <- trips %>%
filter(ST_CODE_NAME=="Leipzig") %>%
filter(E_HVM < 70) %>%
filter(V_VM_LAENG < 70) %>%
filter(GIS_LAENGE >= 0 & GIS_LAENGE_GUELTIG == -1) %>%
filter(GIS_LAENGE >= 0 & E_DAUER > 0) %>%
filter(STICHTAG_WTAG <= 5) %>%
mutate(dist_group = cut(GIS_LAENGE, breaks=breaks, labels=levels, right=T))

Expand Down
10 changes: 5 additions & 5 deletions src/main/python/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

# Target from SrV
target = {
"walk": 0.2278,
"bike": 0.2179,
"pt": 0.1669,
"car": 0.2966,
"ride": 0.0908
"walk": 0.272564,
"bike": 0.190819,
"pt": 0.170200,
"car": 0.284754,
"ride": 0.081662
}

city = gpd.read_file("../scenarios/input/leipzig-utm32n/leipzig-utm32n.shp")
Expand Down
15 changes: 12 additions & 3 deletions src/main/python/create_ref.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from matsim.scenariogen.data import run_create_ref_data
from matsim.scenariogen.data import TripMode, run_create_ref_data


def person_filter(df):
""" Default person filter for reference data. """
return df[df.present_on_day & (df.reporting_day <= 4)]
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
return df[df.main_mode != "other"]


if __name__ == "__main__":
person, trips, share = run_create_ref_data.create("../../../../shared-svn/projects/NaMAV/data/SrV_2018",
person_filter)
person_filter, trip_filter,
run_create_ref_data.InvalidHandling.REMOVE_TRIPS)

print(share)

0 comments on commit d0e251e

Please sign in to comment.