From 5cb712ad6a9cc58b558a64ec15720ac4939f6c7d Mon Sep 17 00:00:00 2001 From: rakow Date: Tue, 24 Oct 2023 16:01:49 +0200 Subject: [PATCH] update config and added number of missing short distance trips --- Makefile | 27 +++++---- input/shp/lausitz.cpg | 1 + input/shp/lausitz.dbf | Bin 0 -> 119 bytes input/shp/lausitz.prj | 1 + input/shp/lausitz.qpj | 1 + input/shp/lausitz.shp | Bin 0 -> 1004 bytes input/shp/lausitz.shx | Bin 0 -> 108 bytes input/v1.0/lausitz-v1.0-100pct.config.xml | 55 ++++++++++++------ .../org/matsim/run/RunLausitzScenario.java | 27 ++++++--- src/main/python/create_ref.py | 20 ++++++- 10 files changed, 90 insertions(+), 42 deletions(-) create mode 100644 input/shp/lausitz.cpg create mode 100644 input/shp/lausitz.dbf create mode 100644 input/shp/lausitz.prj create mode 100644 input/shp/lausitz.qpj create mode 100644 input/shp/lausitz.shp create mode 100644 input/shp/lausitz.shx diff --git a/Makefile b/Makefile index 24629ae..742efa1 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ input/plans-longHaulFreight.xml.gz: input/$V/$N-$V-network.xml.gz --network ../public-svn/matsim/scenarios/countries/de/german-wide-freight/v2/germany-europe-network.xml.gz\ --input-crs $(CRS)\ --target-crs $(CRS)\ - --shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\ + --shp input/shp/lausitz.shp --shp-crs $(CRS)\ --cut-on-boundary\ --output $@ @@ -104,19 +104,20 @@ input/$V/prepare-100pct.plans.xml.gz: input/$V/prepare-100pct.plans.xml.gz\ --input-crs $(CRS)\ --grid-resolution 300\ - --landuse ../shared-svn/projects/matsim-germany/landuse/landuse.shp\ + --landuse $(germany)/landuse/landuse.shp\ --output $@ -input/$V/$N-$V-100pct.plans.xml.gz: input/plans-longHaulFreight.xml.gz input/$V/prepare-100pct.plans.xml.gz +input/$V/$N-$V-100pct.plans-initial.xml.gz: input/plans-longHaulFreight.xml.gz input/$V/prepare-100pct.plans.xml.gz $(sc) prepare generate-short-distance-trips\ --population input/$V/prepare-100pct.plans.xml.gz\ --input-crs $(CRS)\ - --shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\ - --num-trips 1 # TODO + --shp input/shp/lausitz.shp --shp-crs $(CRS)\ + --range 1500\ + --num-trips 795513 $(sc) prepare adjust-activity-to-link-distances input/$V/prepare-100pct.plans-with-trips.xml.gz\ - --shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\ + --shp input/shp/lausitz.shp --shp-crs $(CRS)\ --scale 1.15\ --input-crs $(CRS)\ --network input/$V/$N-$V-network.xml.gz\ @@ -126,13 +127,11 @@ input/$V/$N-$V-100pct.plans.xml.gz: input/plans-longHaulFreight.xml.gz input/$V/ $(sc) prepare merge-populations $@ $< --output $@ - # TODO: set home coordinates attributes - $(sc) prepare extract-home-coordinates $@ --output $@ --csv input/$V/$N-$V-homes.csv $(sc) prepare downsample-population $@\ --sample-size 1\ - --samples 0.25 0.01\ + --samples 0.25 0.1 0.01\ input/$V/$N-$V-counts-car-bast.xml.gz: input/2019_A_S.zip input/2019_B_S.zip input/Jawe2019.csv input/$V/$N-$V-network-with-pt.xml.gz @@ -142,22 +141,22 @@ input/$V/$N-$V-counts-car-bast.xml.gz: input/2019_A_S.zip input/2019_B_S.zip inp --primary-data input/2019_B_S.zip\ --station-data input/Jawe2019.csv\ --year 2019\ - --shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\ + --shp input/shp/lausitz.shp --shp-crs $(CRS)\ --car-output $@\ --freight-output $(subst car,freight,$@) -check: input/$V/$N-$V-100pct.plans.xml.gz +check: input/$V/$N-$V-100pct.plans-initial.xml.gz $(sc) analysis commuter\ --population $<\ --input-crs $(CRS)\ - --shp ../shared-svn/projects/matsim-germany/vg5000/vg5000_ebenen_0101/VG5000_GEM.shp\ + --shp $(germany)/vg5000/vg5000_ebenen_0101/VG5000_GEM.shp\ --attr ARS\ --output input/$V/$N-$V-commuter.csv $(sc) analysis check-population $<\ --input-crs $(CRS)\ - --shp $(shared)/data/shp/$N.shp --shp-crs $(CRS) + --shp input/shp/lausitz.shp --shp-crs $(CRS) # Aggregated target -prepare: input/$V/$N-$V-100pct.plans.xml.gz input/$V/$N-$V-network-with-pt.xml.gz input/$V/$N-$V-counts-car-bast.xml.gz +prepare: input/$V/$N-$V-100pct.plans-initial.xml.gz input/$V/$N-$V-network-with-pt.xml.gz input/$V/$N-$V-counts-car-bast.xml.gz echo "Done" \ No newline at end of file diff --git a/input/shp/lausitz.cpg b/input/shp/lausitz.cpg new file mode 100644 index 0000000..3ad133c --- /dev/null +++ b/input/shp/lausitz.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/input/shp/lausitz.dbf b/input/shp/lausitz.dbf new file mode 100644 index 0000000000000000000000000000000000000000..8803237354702b751d7e12a9daf72521ae72943f GIT binary patch literal 119 zcmZRsX5?jLU|>jO5CxK$ATtFn<_BVN!MPAdUSe)4RLB`bqs#Luz=1(dVrg+^Nfl5) F3IJ+$2^s(Z literal 0 HcmV?d00001 diff --git a/input/shp/lausitz.prj b/input/shp/lausitz.prj new file mode 100644 index 0000000..5aeba93 --- /dev/null +++ b/input/shp/lausitz.prj @@ -0,0 +1 @@ +PROJCS["ETRS89_UTM_zone_32N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]] \ No newline at end of file diff --git a/input/shp/lausitz.qpj b/input/shp/lausitz.qpj new file mode 100644 index 0000000..3d0b220 --- /dev/null +++ b/input/shp/lausitz.qpj @@ -0,0 +1 @@ +PROJCS["ETRS89 / UTM zone 32N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","25832"]] diff --git a/input/shp/lausitz.shp b/input/shp/lausitz.shp new file mode 100644 index 0000000000000000000000000000000000000000..98bd7cb1a843da14243f340a40af9d2deed1513e GIT binary patch literal 1004 zcma)*e^8Tk9LFEnaZ`{=2n0n41by~AkM2B=AC0nmTZjacbM5;ail!0?re_x8hZVNV zZ9qT=)4|1LF(i?=B6ml}idE*1n&81{cgwZu2&N(+jEum-dj2T8I{)bV-|PGNzP>*` z_kB~;szBZfu%@f>zYJhD^u1XpaI)X1Ya7`A1)r0)^1 z2PHwqU=BsPM`nks2_gqJjHdp^;^!n2>8~OjxU3M|f<4aR5RC79rDZJT+U0dLK8 zt6B)M?l|5&xrYIr+1hflm7ufh+vB{PL3E`jbwYTL_0s8~Who5SBwH6Zwh?$@iXGla z!O!91+5~3rohed?8O$}VS1Ugx_)PJsTRbVjveSv1;@b&CtLG1?ToMEv+@F`&L7=&A zPWn*; zdU~E9LX&2zZlj?w-!;wrLEw#$Y8QV;V`Ni@%3s7|l8R~l<*Wo}u3lZ38_Gi=em;E2 zEmin0L-RrwijD)1)l5r!kl^ceH;m@Tz8m zL7T;3q;PxSif|tCn>#G_Yz8)eX}DhCE^n<|TFStBF~4ATIgdu4DKhpj150+5uP>Sh zzbZ&vzUD)@1`Q2hlST~-KSt-5JmJf2F4t=db^KV;BK5{f$I&rC=+0`jFh}g# MQACXx7#I%#01n>{Gynhq literal 0 HcmV?d00001 diff --git a/input/v1.0/lausitz-v1.0-100pct.config.xml b/input/v1.0/lausitz-v1.0-100pct.config.xml index 03844e3..a984991 100644 --- a/input/v1.0/lausitz-v1.0-100pct.config.xml +++ b/input/v1.0/lausitz-v1.0-100pct.config.xml @@ -6,9 +6,9 @@ - + - + @@ -23,28 +23,30 @@ - + + value="./lausitz-v1.0-100pct.plans-initial.xml.gz"/> - + - - + + + + + + @@ -60,7 +62,7 @@ - + @@ -72,6 +74,20 @@ + + + + + + + + + + + + + + @@ -87,12 +103,12 @@ - + - + @@ -136,25 +152,28 @@ - + - + + + - - + + - + + - + diff --git a/src/main/java/org/matsim/run/RunLausitzScenario.java b/src/main/java/org/matsim/run/RunLausitzScenario.java index 746a206..56d5650 100644 --- a/src/main/java/org/matsim/run/RunLausitzScenario.java +++ b/src/main/java/org/matsim/run/RunLausitzScenario.java @@ -18,11 +18,12 @@ import org.matsim.application.prepare.pt.CreateTransitScheduleFromGtfs; import org.matsim.contrib.vsp.scenario.SnzActivities; import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.RoutingConfigGroup; -import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.run.analysis.CommuterAnalysis; +import org.matsim.simwrapper.SimWrapperConfigGroup; import org.matsim.simwrapper.SimWrapperModule; import picocli.CommandLine; @@ -41,10 +42,10 @@ }) public class RunLausitzScenario extends MATSimApplication { - static final String VERSION = "1.0"; + public static final String VERSION = "1.0"; @CommandLine.Mixin - private final SampleOptions sample = new SampleOptions(100, 25, 1); + private final SampleOptions sample = new SampleOptions(100, 25, 10, 1); public RunLausitzScenario(@Nullable Config config) { @@ -66,14 +67,22 @@ protected Config prepareConfig(Config config) { // Add all activity types with time bins SnzActivities.addScoringParams(config); - config.controller().setOutputDirectory(sample.adjustName(config.controller().getOutputDirectory())); - config.plans().setInputFile(sample.adjustName(config.plans().getInputFile())); - config.controller().setRunId(sample.adjustName(config.controller().getRunId())); + SimWrapperConfigGroup simWrapper = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class); - config.qsim().setFlowCapFactor(sample.getSize() / 100.0); - config.qsim().setStorageCapFactor(sample.getSize() / 100.0); + // Path is relative to config + simWrapper.defaultParams().shp = "../shp/lausitz.shp"; + simWrapper.defaultParams().mapCenter = "14.3463,51.5626"; + simWrapper.defaultParams().mapZoomLevel = 9.0; + + if (sample.isSet()) { + config.controller().setOutputDirectory(sample.adjustName(config.controller().getOutputDirectory())); + config.plans().setInputFile(sample.adjustName(config.plans().getInputFile())); + config.controller().setRunId(sample.adjustName(config.controller().getRunId())); + + config.qsim().setFlowCapFactor(sample.getSize() / 100.0); + config.qsim().setStorageCapFactor(sample.getSize() / 100.0); + } - config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.info); config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); // TODO: Config options diff --git a/src/main/python/create_ref.py b/src/main/python/create_ref.py index 5306896..ea5b5a7 100644 --- a/src/main/python/create_ref.py +++ b/src/main/python/create_ref.py @@ -2,8 +2,9 @@ # -*- coding: utf-8 -*- import geopandas as gpd - +import pandas as pd from matsim.scenariogen.data import run_create_ref_data +from matsim.scenariogen.data.preparation import calc_needed_short_distance_trips def person_filter(df): @@ -29,3 +30,20 @@ def trip_filter(df): print("Filtered %s trips" % len(trips)) print(share) + + # Simulated trips + sim_persons = pd.read_csv("../../../output/output-lausitz-100pct/lausitz-100pct.output_persons.csv.gz", + delimiter=";", dtype={"person": "str"}) + sim_persons = sim_persons[sim_persons.subpopulation == "person"] + sim_persons = gpd.GeoDataFrame(sim_persons, + geometry=gpd.points_from_xy(sim_persons.home_x, sim_persons.home_y)).set_crs("EPSG:25832") + + sim_persons = gpd.sjoin(sim_persons, region, how="inner", predicate="intersects") + + sim = pd.read_csv("../../../output/output-lausitz-100pct/lausitz-100pct.output_trips.csv.gz", + delimiter=";", dtype={"person": "str"}) + + sim = pd.merge(sim, sim_persons, how="inner", left_on="person", right_on="person") + + share, add_trips = calc_needed_short_distance_trips(trips, sim, max_dist=1500) + print("Short distance trip missing: ", add_trips)