Skip to content

Commit

Permalink
Merge branch 'master' into drt-fleet-sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
luchengqi7 committed Sep 13, 2024
2 parents 6e9f226 + b4c1713 commit 3608c1b
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 61 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ This scenario contains a 25pct sample of Kelheim and its surrounding area; road

The **MATSim program code** in this repository is distributed under the terms of the [GNU General Public License as published by the Free Software Foundation (version 2)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html). The MATSim program code are files that reside in the `src` directory hierarchy and typically end with `*.java`.

The **MATSim input files, output files, analysis data and visualizations** are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a><br /> MATSim input files are those that are used as input to run MATSim. They often, but not always, have a header pointing to matsim.org. They typically reside in the `scenarios` directory hierarchy. MATSim output files, analysis data, and visualizations are files generated by MATSim runs, or by postprocessing. They typically reside in a directory hierarchy starting with `output`.
The **MATSim input files, output files, analysis data and visualizations** are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution 4.0 International License</a>.
<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/80x15.png" /></a><br /> MATSim input files are those that are used as input to run MATSim. They often, but not always, have a header pointing to matsim.org. They typically reside in the `input` directory hierarchy. MATSim output files, analysis data, and visualizations are files generated by MATSim runs, or by postprocessing. They typically reside in a directory hierarchy starting with `output`.

**Other data files**, in particular in `original-input-data`, have their own individual licenses that need to be individually clarified with the copyright holders.

Expand Down
2 changes: 1 addition & 1 deletion src/main/R/drtAnalysis/plotRunSummaries.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(tidyr)

mainDir <- "E:/matsim-kelheim/v3.1.1/output-KEXI-2.45-AV--0.0/"

transposed_result <- read.csv(paste(mainDir, "results-deutsch.csv", sep=""), check.names = FALSE, sep =";")
transposed_result <- read.csv(paste(mainDir, "results-deutsch.csv", sep=""), check.names = FALSE, sep =",")
#names(transposed_result) <- make.names(names(transposed_result), unique = TRUE, allow_ = FALSE)

# Betriebszeiten umschreiben
Expand Down
2 changes: 1 addition & 1 deletion src/main/R/drtAnalysis/readValuesFromRunSummaries.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ read_stats <- function(folder_path, file_name) {
csv_path <- file.path(folder_path, "analysis/drt-drt-av", file_name)

if (file.exists(csv_path)) {
df <- read_csv(csv_path)
df <- read_csv(csv_path, show_col_types = FALSE)
mean_values <- df %>% select(parameter, mean)
return(mean_values)
} else {
Expand Down
116 changes: 65 additions & 51 deletions src/main/R/drtDemandAnalysis/VIA-data/KEXI-plot-time-series-VIA.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ library(hrbrthemes)

# set working directory
#setwd("C:/Users/Simon/Documents/shared-svn/projects/KelRide/data/KEXI/")
setwd("D:/Module/vsp/shared-svn/")
setwd("D:/shared-svn/projects/KelRide/data/KEXI/")

# read data
VIAdata2021 <- read.csv2("Via_data_2022-02-08/Data_request_TUB_for_Kelheim-Actual_Data-VIA_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2022_1 <- read.csv2("Via_data_2022-10-10/Data_request_TUB_for_Kelheim-Actual_Data-VIA_Feb_to_Oct_2022_edited_cleaned.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2022_2 <- read.csv2("Via_data_2023-01-17/Data_request_TUB_for_Kelheim-Actual_Data-Oct-Dec_2022-Data_TUB_for_Kelheim-Actual_Data-Oct_to_Dec_22_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2023_1 <- read.csv2("Via_data_2023-04-19/Data_request_TUB_for_Kelheim-Actual_Data-Jan-Mar_2023-Kelheim-Actual_Data-Jan-Mar_2023_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2023_2 <- read.csv2("Via_data_2023-07-10/Data_request_TUB_for_Kelheim-Actual_Data-Apr-Jul_2023-Kelheim-Actual_Data-Apr-Jul_23_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2023_3 <- read.csv2("Via_data_2023-10-24/Data_request_TUB_for_Kelheim-Actual_Data-Jul-Oct_2023-Kelheim-Actual_Data-Jul-Oct_23_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2021 <- read.csv2("VIA_data/zz__previous-data-samples/Via_data_2022-02-08/Data_request_TUB_for_Kelheim-Actual_Data-VIA_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2022_1 <- read.csv2("VIA_data/zz__previous-data-samples/Via_data_2022-10-10/Data_request_TUB_for_Kelheim-Actual_Data-VIA_Feb_to_Oct_2022_edited_cleaned.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2022_2 <- read.csv2("VIA_data/zz__previous-data-samples/Via_data_2023-01-17/Data_request_TUB_for_Kelheim-Actual_Data-Oct-Dec_2022-Data_TUB_for_Kelheim-Actual_Data-Oct_to_Dec_22_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2023_1 <- read.csv2("VIA_data/zz__previous-data-samples/Via_data_2023-04-19/Data_request_TUB_for_Kelheim-Actual_Data-Jan-Mar_2023-Kelheim-Actual_Data-Jan-Mar_2023_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2023_2 <- read.csv2("VIA_data/zz__previous-data-samples/Via_data_2023-07-10/Data_request_TUB_for_Kelheim-Actual_Data-Apr-Jul_2023-Kelheim-Actual_Data-Apr-Jul_23_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")
VIAdata2023_3 <- read.csv2("VIA_data/zz__previous-data-samples/Via_data_2023-10-24/Data_request_TUB_for_Kelheim-Actual_Data-Jul-Oct_2023-Kelheim-Actual_Data-Jul-Oct_23_edited.csv", stringsAsFactors = FALSE, header = TRUE, encoding = "UTF-8", na.strings="")


VIAdataAll <- union(VIAdata2021, VIAdata2022_1)
Expand Down Expand Up @@ -76,17 +76,19 @@ for(dataset in datasets) {
p <- ggplot(data=reqProTag) +
geom_line(mapping=aes(x=date, y=n), col="#69b3a2") +
geom_area(mapping=aes(x=date, y=n), fill="#69b3a2", alpha=0.5) +
labs(x="Tag",y="Requests", title="Zeitverlauf der Anfragen pro Tag (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=4),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold")) +
labs(x="Tag",y="Requests", title="Zeitverlauf der Anfragen pro Tag") +
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18, angle=90),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold")) +
scale_x_date(breaks = "3 month")



plotFile = paste0("plots/",names[i],"/KEXI_requests_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p

############
Expand All @@ -99,14 +101,16 @@ for(dataset in datasets) {
p <- ggplot(data=reqProWochentag) +
geom_bar(mapping=aes(x=weekday, y=avg), stat="identity") +
labs(x="Wochentag",y="Durchschn. Anzahl Requests", title="Durchschn. Anzahl Requests pro Wochentag (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=4),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold"))
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold"))


plotFile = paste0("plots/",names[i],"/KEXI_requests_weekdays_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p


Expand All @@ -121,14 +125,16 @@ for(dataset in datasets) {
geom_line(mapping=aes(x=interval * 5/60, y=n), col="#69b3a2") +
geom_area(mapping=aes(x=interval * 5/60, y=n), fill="#69b3a2", alpha=0.5) +
labs(x="Stunde", y="Anzahl Requests pro Intervall", title="Requests pro 5 Minuten-Intervall (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=4),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold"))

theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold"))


plotFile = paste0("plots/",names[i],"/KEXI_requests_daily_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p


Expand All @@ -149,15 +155,17 @@ for(dataset in datasets) {
p <- ggplot(data=ridesProTag) +
geom_line(mapping=aes(x=date, y=n), col="#69b3a2") +
geom_area(mapping=aes(x=date, y=n), fill="#69b3a2", alpha=0.5) +
labs(x="Tag", y="Fahrten", title="Zeitverlauf der Fahrten pro Tag (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=2),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold")) +
labs(x="Tag", y="Fahrten", title="Zeitverlauf der KEXI-Fahrten (konv.) pro Tag") +
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18, angle = 90),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold"))+
scale_x_date(breaks = "3 month")

plotFile = paste0("plots/",names[i],"/KEXI_rides_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p


Expand Down Expand Up @@ -191,15 +199,16 @@ for(dataset in datasets) {
#plot avg nr of requests per weekday
p <- ggplot(data=ridesProWochentag) +
geom_bar(mapping=aes(x=weekday, y=avg), stat="identity") +
labs(x="Tag", y="Durchschn. Anzahl Fahrten", title="Durchschn. Anzahl Fahrten pro Wochentag (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=4),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold"))

labs(x="Tag", y="Durchschn. Anzahl Fahrten", title="Durchschn. Anzahl Fahrten pro Wochentag") +
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold"))

plotFile = paste0("plots/",names[i],"/KEXI_rides_weekdays_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p

################
Expand All @@ -213,16 +222,18 @@ for(dataset in datasets) {
p <- ggplot(data=saturdays) +
geom_line(mapping=aes(x=date, y=n), col="#69b3a2") +
geom_area(mapping=aes(x=date, y=n), fill="#69b3a2", alpha=0.5) +
labs(x="Tag",y="Fahrten", title="Zeitverlauf der Fahrten pro Samstag (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=2),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold")) +
labs(x="Tag",y="Fahrten", title="Zeitverlauf der Fahrten pro Samstag") +
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18, angle = 90),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold")) +
scale_x_date(breaks = "3 month")


plotFile = paste0("plots/",names[i],"/KEXI_rides_saturdays_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p

##############
Expand Down Expand Up @@ -254,15 +265,17 @@ for(dataset in datasets) {
p <- ggplot(data=ridesPerInterval) +
geom_line(mapping=aes(x=interval*5/60, y=n), col="#69b3a2") +
geom_area(mapping=aes(x=interval*5/60, y=n), fill="#69b3a2", alpha=0.5) +
labs(x="Stunde",y="Anzahl Fahrten", title="Fahrten pro 5-Minuten-Intervall (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=4),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold"))
labs(x="Stunde",y="Anzahl Fahrten", title="Fahrten pro 5-Minuten-Intervall") +
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold"))


plotFile = paste0("plots/",names[i],"/KEXI_rides_daily_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p


Expand All @@ -277,15 +290,16 @@ for(dataset in datasets) {
p <- ggplot(data=saturdays_day) +
geom_line(mapping=aes(x=interval*5/60, y=n), col="#69b3a2") +
geom_area(mapping=aes(x=interval*5/60, y=n), fill="#69b3a2", alpha=0.5) +
labs(x="Stunde",y="Anzahl Fahrten", title="SA: Fahrten pro 5-Minuten-Intervall (VIA)") +
theme(plot.title = element_text(hjust=0.5, size=3.5, face="bold"), axis.text.x = element_text(size=4),
axis.title.x = element_text(size=4, face="bold"), axis.text.y = element_text(size=4),
axis.title.y = element_text(size=4, face="bold"))

labs(x="Stunde",y="Anzahl Fahrten", title="SA: Fahrten pro 5-Minuten-Intervall") +
theme(plot.title = element_text(hjust=0.5, size=28, face="bold"),
axis.text.x = element_text(size=18),
axis.title.x = element_text(size=22, face="bold"),
axis.text.y = element_text(size=18),
axis.title.y = element_text(size=22, face="bold"))

plotFile = paste0("plots/",names[i],"/KEXI_rides_saturdays_daily_VIA.png")
paste0("printing plot to ", plotFile)
ggsave(plotFile, limitsize = FALSE)
ggsave(plotFile, limitsize = FALSE, dpi = 600, width = 32, height = 18, units = "cm")
p

#################################################################
Expand Down Expand Up @@ -314,8 +328,8 @@ for(dataset in datasets) {
labs(x="Stunde",y="Anzahl pro Intervall") +
scale_color_manual(values = c("darkgreen" , "darkred", "steelblue"))



p
requests_timeDiffs <- dataset %>%
select(Request.Creation.Time, Requested.Time) %>%
mutate(diff = seconds(Requested.Time - Request.Creation.Time)) %>%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.NumberFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
Expand Down Expand Up @@ -168,12 +169,16 @@ public Integer call() throws Exception {
// grid per hour means
calcGridMeans(gridPerHourStats, meanGridPerHour);

NumberFormat nf = NumberFormat.getInstance(Locale.US);
nf.setMaximumFractionDigits(4);
nf.setGroupingUsed(false);

// write total mean stats
try (CSVPrinter printer = new CSVPrinter(Files.newBufferedWriter(output.getPath("mean_emissions_total.csv")), CSVFormat.DEFAULT)) {
printer.printRecord(POLLUTANT, "kg");

for (Map.Entry<String, Double> e : meanTotal.entrySet()) {
printer.printRecord("mean-" + e.getKey(), e.getValue());
printer.printRecord("" + e.getKey() + " (mean)", nf.format(e.getValue()));
}
}

Expand Down Expand Up @@ -221,7 +226,8 @@ private void getGridData(Table gridTable, Map<Map.Entry<Double, Coord>, List<Dou
private void writeGridFile(String fileName, Map<Map.Entry<Double, Coord>, Double> values) throws IOException {
try (CSVPrinter printer = new CSVPrinter(Files.newBufferedWriter(output.getPath(fileName)), CSVFormat.DEFAULT)) {

printer.printRecord("# EPSG:25832");
//set the projection in the YAML instead, as this is put out with a quote atm...
//printer.printRecord("# EPSG:25832");
printer.printRecord("time", "x", "y", VALUE);

for (Map.Entry<Map.Entry<Double, Coord>, Double> e : values.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;

Expand Down Expand Up @@ -140,19 +142,21 @@ public Integer call() throws Exception {
XYTData damagesPerDayMean = calcAvroMeans(damagesPerDay, "damages_receiverPoint");
XYTData damagesPerHourMean = calcAvroMeans(damagesPerHour, "damages_receiverPoint");

DecimalFormat df = new DecimalFormat("#.###", DecimalFormatSymbols.getInstance(Locale.US));

// write emission mean stats
try (CSVPrinter printer = new CSVPrinter(Files.newBufferedWriter(output.getPath("mean_emission_per_day.csv")), CSVFormat.DEFAULT)) {
printer.printRecord(LINK_ID, VALUE);

for (Map.Entry<String, Double> e : meanEmissionsPerDay.entrySet()) {
printer.printRecord(e.getKey(), e.getValue());
printer.printRecord(e.getKey(), df.format(e.getValue()));
}
}

// write total mean stats
try (CSVPrinter printer = new CSVPrinter(Files.newBufferedWriter(output.getPath("mean_noise_stats.csv")), CSVFormat.DEFAULT)) {
for (Map.Entry<String, Double> e : meanTotalStatsPerDay.entrySet()) {
printer.printRecord(e.getKey(), e.getValue());
printer.printRecord(e.getKey(), df.format(e.getValue()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ public void configure(Header header, Layout layout) {
layout.row("second").el(GridMap.class, (viz, data) -> {
viz.title = "CO₂ Emissions";
viz.description = "per day. Be aware that CO2 values are provided in the simulation sample size!";
viz.projection = "EPSG:25832";
viz.height = 12.0;
viz.file = postProcess(data, "mean_emissions_grid_per_day.xyt.csv");
});
layout.row("third")
.el(GridMap.class, (viz, data) -> {
viz.title = "CO₂ Emissions";
viz.projection = "EPSG:25832";
viz.description = "per hour. Be aware that CO2 values are provided in the simulation sample size!";
viz.height = 12.;
viz.file = postProcess(data, "mean_emissions_grid_per_hour.csv");
Expand Down
Loading

0 comments on commit 3608c1b

Please sign in to comment.