From c44f494c3734a735a63b14bea6f73eb8345a5e7f Mon Sep 17 00:00:00 2001 From: schlenther Date: Wed, 25 Sep 2024 12:04:28 +0200 Subject: [PATCH 1/6] package structure + debug dashboard color ramps --- .../EmissionsPostProcessingAverageAnalysis.java | 2 +- ...flineAirPollutionAnalysisByEngineInformation.java | 2 +- .../dashboard/AverageKelheimEmissionsDashboard.java | 6 +++++- .../dashboard/AverageKelheimNoiseDashboard.java | 12 ++++++------ .../matsim/dashboard/KelheimDashboardProvider.java | 1 - .../KelheimEmissionsDashboard.java | 9 ++++++++- .../matsim/dashboard/KelheimSimWrapperRunner.java | 1 - 7 files changed, 21 insertions(+), 12 deletions(-) rename src/main/java/org/matsim/analysis/postAnalysis/{ => emissions}/EmissionsPostProcessingAverageAnalysis.java (99%) rename src/main/java/org/matsim/analysis/{ => postAnalysis}/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java (99%) rename src/main/java/org/matsim/{analysis/emissions => dashboard}/KelheimEmissionsDashboard.java (90%) diff --git a/src/main/java/org/matsim/analysis/postAnalysis/EmissionsPostProcessingAverageAnalysis.java b/src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java similarity index 99% rename from src/main/java/org/matsim/analysis/postAnalysis/EmissionsPostProcessingAverageAnalysis.java rename to src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java index 2ed4a58..e1e0463 100644 --- a/src/main/java/org/matsim/analysis/postAnalysis/EmissionsPostProcessingAverageAnalysis.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java @@ -1,4 +1,4 @@ -package org.matsim.analysis.postAnalysis; +package org.matsim.analysis.postAnalysis.emissions; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; diff --git a/src/main/java/org/matsim/analysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java b/src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java similarity index 99% rename from src/main/java/org/matsim/analysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java rename to src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java index 1d0c91c..e746f74 100644 --- a/src/main/java/org/matsim/analysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java @@ -18,7 +18,7 @@ * * * *********************************************************************** */ -package org.matsim.analysis.emissions; +package org.matsim.analysis.postAnalysis.emissions; import it.unimi.dsi.fastutil.objects.Object2DoubleLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; diff --git a/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java b/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java index 5cef300..ddf3036 100644 --- a/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java +++ b/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java @@ -20,7 +20,7 @@ package org.matsim.dashboard; -import org.matsim.analysis.postAnalysis.EmissionsPostProcessingAverageAnalysis; +import org.matsim.analysis.postAnalysis.emissions.EmissionsPostProcessingAverageAnalysis; import org.matsim.simwrapper.Dashboard; import org.matsim.simwrapper.Data; import org.matsim.simwrapper.Header; @@ -33,6 +33,8 @@ import java.util.ArrayList; import java.util.List; +import static org.matsim.dashboard.AverageKelheimNoiseDashboard.*; + /** * Average emissions dashboard for several runs with the same config but a different random seed. */ @@ -105,6 +107,7 @@ public void configure(Header header, Layout layout) { 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.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED}); viz.height = 12.0; viz.file = postProcess(data, "mean_emissions_grid_per_day.xyt.csv"); }); @@ -112,6 +115,7 @@ public void configure(Header header, Layout layout) { .el(GridMap.class, (viz, data) -> { viz.title = "CO₂ Emissions"; viz.projection = "EPSG:25832"; + viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED}); 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"); diff --git a/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java b/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java index 3a24899..92d89e2 100644 --- a/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java +++ b/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java @@ -23,12 +23,12 @@ public class AverageKelheimNoiseDashboard implements Dashboard { private final List dirs; private final Integer noRuns; private static final String NOISE = "noise"; - private static final String DARK_BLUE = "#1175b3"; - private static final String LIGHT_BLUE = "#95c7df"; - private static final String ORANGE = "#f4a986"; - private static final String RED = "#cc0c27"; - private static final String SAND = "#dfb095"; - private static final String YELLOW = "#dfdb95"; + static final String DARK_BLUE = "#1175b3"; + static final String LIGHT_BLUE = "#95c7df"; + static final String ORANGE = "#f4a986"; + static final String RED = "#cc0c27"; + static final String SAND = "#dfb095"; + static final String YELLOW = "#dfdb95"; public AverageKelheimNoiseDashboard(List dirs, Integer noRuns) { this.dirs = dirs; diff --git a/src/main/java/org/matsim/dashboard/KelheimDashboardProvider.java b/src/main/java/org/matsim/dashboard/KelheimDashboardProvider.java index 17a1a6c..16c9b85 100644 --- a/src/main/java/org/matsim/dashboard/KelheimDashboardProvider.java +++ b/src/main/java/org/matsim/dashboard/KelheimDashboardProvider.java @@ -1,6 +1,5 @@ package org.matsim.dashboard; -import org.matsim.analysis.emissions.KelheimEmissionsDashboard; import org.matsim.core.config.Config; import org.matsim.core.utils.io.IOUtils; import org.matsim.simwrapper.Dashboard; diff --git a/src/main/java/org/matsim/analysis/emissions/KelheimEmissionsDashboard.java b/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java similarity index 90% rename from src/main/java/org/matsim/analysis/emissions/KelheimEmissionsDashboard.java rename to src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java index cb7a9a9..c12f382 100644 --- a/src/main/java/org/matsim/analysis/emissions/KelheimEmissionsDashboard.java +++ b/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java @@ -18,8 +18,9 @@ * * * *********************************************************************** */ -package org.matsim.analysis.emissions; +package org.matsim.dashboard; +import org.matsim.analysis.postAnalysis.emissions.KelheimOfflineAirPollutionAnalysisByEngineInformation; import org.matsim.application.prepare.network.CreateGeoJsonNetwork; import org.matsim.simwrapper.Dashboard; import org.matsim.simwrapper.Header; @@ -28,6 +29,9 @@ import org.matsim.simwrapper.viz.Links; import org.matsim.simwrapper.viz.Table; +import static org.matsim.dashboard.AverageKelheimNoiseDashboard.*; +import static org.matsim.dashboard.AverageKelheimNoiseDashboard.RED; + /** * this is basically equivalent to the standard emissions dashboard * but calls the matsim-kelheim-specific emissions analysis class @@ -93,6 +97,8 @@ public void configure(Header header, Layout layout) { viz.description = "per day. Be aware that CO2 values are provided in the simulation sample size!"; viz.height = 12.0; viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_day.xyt.csv", new String[0]); + viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED}); + }); layout.row("third") .el(GridMap.class, (viz, data) -> { @@ -100,6 +106,7 @@ public void configure(Header header, Layout layout) { viz.description = "per hour. Be aware that CO2 values are provided in the simulation sample size!"; viz.height = 12.; viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_hour.csv"); + viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED}); }); } } diff --git a/src/main/java/org/matsim/dashboard/KelheimSimWrapperRunner.java b/src/main/java/org/matsim/dashboard/KelheimSimWrapperRunner.java index b454bc6..01b3c3a 100644 --- a/src/main/java/org/matsim/dashboard/KelheimSimWrapperRunner.java +++ b/src/main/java/org/matsim/dashboard/KelheimSimWrapperRunner.java @@ -22,7 +22,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.analysis.emissions.KelheimEmissionsDashboard; import org.matsim.application.ApplicationUtils; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.ShpOptions; From 08939ef8f8d05ad26e0275e96a693ebe174c4764 Mon Sep 17 00:00:00 2001 From: sime94 Date: Wed, 25 Sep 2024 17:08:10 +0200 Subject: [PATCH 2/6] fix typo --- .../matsim/analysis/postAnalysis/NoiseAverageAnalysis.java | 4 ++-- src/test/java/org/matsim/run/MeanNoiseDashboardTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java b/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java index 14da560..71fc532 100644 --- a/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java @@ -137,8 +137,8 @@ public Integer call() throws Exception { calcCsvMeans(totalStats, meanTotalStatsPerDay); // calc avro means - XYTData imissionsPerDayMean = calcAvroMeans(imissionsPerDay, "imissions"); - XYTData imissionsPerHourMean = calcAvroMeans(imissionsPerHour, "imissions"); + XYTData imissionsPerDayMean = calcAvroMeans(imissionsPerDay, "immission"); + XYTData imissionsPerHourMean = calcAvroMeans(imissionsPerHour, "immission"); XYTData damagesPerDayMean = calcAvroMeans(damagesPerDay, "damages_receiverPoint"); XYTData damagesPerHourMean = calcAvroMeans(damagesPerHour, "damages_receiverPoint"); diff --git a/src/test/java/org/matsim/run/MeanNoiseDashboardTest.java b/src/test/java/org/matsim/run/MeanNoiseDashboardTest.java index e3e0c50..c5c8fca 100644 --- a/src/test/java/org/matsim/run/MeanNoiseDashboardTest.java +++ b/src/test/java/org/matsim/run/MeanNoiseDashboardTest.java @@ -67,7 +67,7 @@ void runMeanNoiseDashboardTest() throws IOException { timeStamps.add(28800); - immissionData.put("imissions", List.of((float) i)); + immissionData.put("immission", List.of((float) i)); damageData.put("damages_receiverPoint", List.of((float) i)); String seedDir = path + i + "seed/"; From 5f2c7639bbc245cc2189b485b5f1ef6b96f1dc4a Mon Sep 17 00:00:00 2001 From: schlenther Date: Thu, 26 Sep 2024 11:21:36 +0200 Subject: [PATCH 3/6] fix typo consistently --- .../postAnalysis/NoiseAverageAnalysis.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java b/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java index 71fc532..2749a67 100644 --- a/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java @@ -57,8 +57,8 @@ public class NoiseAverageAnalysis implements MATSimAppCommand { private static final String ANALYSIS_DIR = "/analysis/noise"; private static final String LINK_ID = "Link Id"; private static final String VALUE = "value"; - private List imissionsPerDay = new ArrayList<>(); - private List imissionsPerHour = new ArrayList<>(); + private List immissionsPerDay = new ArrayList<>(); + private List immissionsPerHour = new ArrayList<>(); private Map> emissionsPerDay = new HashMap<>(); private Map meanEmissionsPerDay = new HashMap<>(); private Map> totalStats = new HashMap<>(); @@ -86,8 +86,8 @@ public Integer call() throws Exception { for (String folder : foldersSeeded) { final Path analysisDir = Path.of(folder + ANALYSIS_DIR); String emissionsCsv = globFile(analysisDir, "*emission_per_day.csv*").toString(); - String imissionsPerDayAvro = globFile(analysisDir, "*immission_per_day.avro*").toString(); - String imissionsPerHourAvro = globFile(analysisDir, "*immission_per_hour.avro*").toString(); + String immissionsPerDayAvro = globFile(analysisDir, "*immission_per_day.avro*").toString(); + String immissionsPerHourAvro = globFile(analysisDir, "*immission_per_hour.avro*").toString(); String totalStatsCsv = globFile(analysisDir, "*noise_stats.csv*").toString(); String damagesPerDayAvro = globFile(analysisDir, "*damages_receiverPoint_per_day.avro*").toString(); String damagesPerHourAvro = globFile(analysisDir, "*damages_receiverPoint_per_hour.avro*").toString(); @@ -105,8 +105,8 @@ public Integer call() throws Exception { .separator(CsvOptions.detectDelimiter(totalStatsCsv)).build()); // read avro files - readAvroFile(imissionsPerDayAvro, imissionsPerDay); - readAvroFile(imissionsPerHourAvro, imissionsPerHour); + readAvroFile(immissionsPerDayAvro, immissionsPerDay); + readAvroFile(immissionsPerHourAvro, immissionsPerHour); readAvroFile(damagesPerDayAvro, damagesPerDay); readAvroFile(damagesPerHourAvro, damagesPerHour); @@ -137,8 +137,8 @@ public Integer call() throws Exception { calcCsvMeans(totalStats, meanTotalStatsPerDay); // calc avro means - XYTData imissionsPerDayMean = calcAvroMeans(imissionsPerDay, "immission"); - XYTData imissionsPerHourMean = calcAvroMeans(imissionsPerHour, "immission"); + XYTData immissionsPerDayMean = calcAvroMeans(immissionsPerDay, "immission"); + XYTData immissionsPerHourMean = calcAvroMeans(immissionsPerHour, "immission"); XYTData damagesPerDayMean = calcAvroMeans(damagesPerDay, "damages_receiverPoint"); XYTData damagesPerHourMean = calcAvroMeans(damagesPerHour, "damages_receiverPoint"); @@ -161,8 +161,8 @@ public Integer call() throws Exception { } // write avro mean files - writeAvro(imissionsPerDayMean, new File(output.getPath("mean_immission_per_day.avro").toString())); - writeAvro(imissionsPerHourMean, new File(output.getPath("mean_immission_per_hour.avro").toString())); + writeAvro(immissionsPerDayMean, new File(output.getPath("mean_immission_per_day.avro").toString())); + writeAvro(immissionsPerHourMean, new File(output.getPath("mean_immission_per_hour.avro").toString())); writeAvro(damagesPerDayMean, new File(output.getPath("mean_damages_receiverPoint_per_day.avro").toString())); writeAvro(damagesPerHourMean, new File(output.getPath("mean_damages_receiverPoint_per_hour.avro").toString())); From e7bfc20345475ea1f89fbfc3fd24e4472295926e Mon Sep 17 00:00:00 2001 From: schlenther Date: Thu, 26 Sep 2024 12:39:49 +0200 Subject: [PATCH 4/6] * use MapPlot instead of Link panel * emissions -> airPollution * delete default for base-run --- .../AverageKelheimEmissionsDashboard.java | 49 ++++++++++++++----- .../AverageKelheimNoiseDashboard.java | 2 +- .../dashboard/CreateAverageDashboards.java | 8 +-- .../dashboard/KelheimEmissionsDashboard.java | 10 ++-- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java b/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java index ddf3036..da115ca 100644 --- a/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java +++ b/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java @@ -25,9 +25,7 @@ import org.matsim.simwrapper.Data; import org.matsim.simwrapper.Header; import org.matsim.simwrapper.Layout; -import org.matsim.simwrapper.viz.GridMap; -import org.matsim.simwrapper.viz.Links; -import org.matsim.simwrapper.viz.Table; +import org.matsim.simwrapper.viz.*; import java.nio.file.Path; import java.util.ArrayList; @@ -53,10 +51,14 @@ public AverageKelheimEmissionsDashboard(List dirs, Integer noRuns, Strin this.dirs = dirs; this.noRuns = noRuns; - if (!pathToBaseRun.endsWith("/")) { - pathToBaseRun += "/"; + if(pathToBaseRun == null || pathToBaseRun.equals("null")){ + this.pathToCsvBase = null; + } else { + if (!pathToBaseRun.endsWith("/")) { + pathToBaseRun += "/"; + } + this.pathToCsvBase = pathToBaseRun + "analysis/emissions/emissions_per_link_per_m.csv"; } - this.pathToCsvBase = pathToBaseRun + "analysis/emissions/emissions_per_link_per_m.csv"; } private String postProcess(Data data, String outputFile) { @@ -70,8 +72,8 @@ private String postProcess(Data data, String outputFile) { * Produces the dashboard. */ public void configure(Header header, Layout layout) { - header.title = "Average Emissions"; - header.description = "Shows the average emissions footprint and spatial distribution for several simulation runs."; + header.title = "Average Air Pollution"; + header.description = "Shows the average air pollution and spatial distribution for several simulation runs."; String linkDescription = "Displays the emissions for each link per meter. Be aware that emission values are provided in the simulation sample size!"; if (pathToCsvBase != null){ @@ -88,12 +90,16 @@ public void configure(Header header, Layout layout) { viz.showAllRows = true; viz.width = 1.0; }) - .el(Links.class, (viz, data) -> { - viz.title = "Emissions per Link per Meter"; + /** + * Commented out link panel, because the MapPlot can show a legend and seems to be the development head. + * However, it doesn't seem to have the pointer to the base case + */ + /*.el(Links.class, (viz, data) -> { + viz.title = "Emitted Pollutant in Gram per Meter"; viz.description = finalLinkDescription; viz.height = 12.0; viz.datasets.csvFile = postProcess(data, "mean_emissions_per_link_per_m.csv"); - viz.datasets.csvBase = Path.of(this.dirs.get(0)).getParent().relativize(Path.of(pathToCsvBase)).toString(); + viz.datasets.csvBase = pathToCsvBase == null ? "" : Path.of(this.dirs.get(0)).getParent().relativize(Path.of(pathToCsvBase)).toString(); viz.network = new CreateAverageDashboards().copyVizNetwork(dirs, ".avro"); viz.display.color.columnName = "CO2_TOTAL [g/m]"; viz.display.color.dataset = "csvFile"; @@ -101,8 +107,27 @@ public void configure(Header header, Layout layout) { viz.display.width.columnName = "CO2_TOTAL [g/m]"; viz.display.width.dataset = "csvFile"; viz.center = data.context().getCenter(); + viz.width = 1.0; + })*/ + .el(MapPlot.class, (viz, data) -> { + viz.title = "Emitted Pollutant in Gram per Meter"; + viz.description = finalLinkDescription; + viz.height = 12.0; + viz.center = data.context().getCenter(); + viz.zoom = data.context().mapZoomLevel; + viz.setShape(new CreateAverageDashboards().copyVizNetwork(dirs, ".avro"), "id"); + viz.addDataset("emissions_per_m", postProcess(data, "mean_emissions_per_link_per_m.csv")); + viz.display.lineColor.dataset = "emissions_per_m"; + viz.display.lineColor.columnName = "CO2_TOTAL [g/m]"; + viz.display.lineColor.join = "linkId"; + viz.display.lineColor.setColorRamp(ColorScheme.Oranges, 8, false, "35, 45, 55, 65, 75, 85, 95"); + viz.display.lineWidth.dataset = "emissions_per_m"; + viz.display.lineWidth.columnName = "CO2_TOTAL [g/m]"; + viz.display.lineWidth.scaleFactor = 100d; + viz.display.lineWidth.join = "linkId"; viz.width = 3.0; - }); + }); + 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!"; diff --git a/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java b/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java index 92d89e2..40f34fa 100644 --- a/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java +++ b/src/main/java/org/matsim/dashboard/AverageKelheimNoiseDashboard.java @@ -14,7 +14,7 @@ import java.util.List; /** - * Shows emission in the scenario. + * Averages and displays the noise outcome of single runs. */ public class AverageKelheimNoiseDashboard implements Dashboard { diff --git a/src/main/java/org/matsim/dashboard/CreateAverageDashboards.java b/src/main/java/org/matsim/dashboard/CreateAverageDashboards.java index b6dffb3..0b923b4 100644 --- a/src/main/java/org/matsim/dashboard/CreateAverageDashboards.java +++ b/src/main/java/org/matsim/dashboard/CreateAverageDashboards.java @@ -24,18 +24,14 @@ final class CreateAverageDashboards implements MATSimAppCommand { private String inputPath; @CommandLine.Option(names = "--no-runs", defaultValue = "5", description = "Number of simulation runs to be averaged.") private Integer noRuns; - @CommandLine.Option(names = "--base-run", description = "Path to directory base run.", defaultValue = "/net/ils/matsim-kelheim/v3.0-release/output-base/25pct") + @CommandLine.Option(names = "--base-run", description = "Path to directory base run.") private String pathToBaseRun; public static void main(String[] args) { new CreateAverageDashboards().execute(args); } - CreateAverageDashboards() { - - } - - + CreateAverageDashboards() {} @Override public Integer call() throws Exception { diff --git a/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java b/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java index c12f382..1eade5e 100644 --- a/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java +++ b/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java @@ -57,10 +57,10 @@ public KelheimEmissionsDashboard(String pathToBaseRun) { */ public void configure(Header header, Layout layout) { - header.title = "Emissions"; - header.description = "Shows the emissions footprint and spatial distribution."; + header.title = "Air Pollution"; + header.description = "Shows the air pollution and spatial distribution."; - String linkDescription = "Displays the emissions for each link per meter. Be aware that emission values are provided in the simulation sample size!"; + String linkDescription = "Displays the emitted pair pollutants for each link per meter. Be aware that pollutant values are provided in the simulation sample size!"; if (pathToCsvBase != null){ linkDescription += String.format("%n Base is %s", pathToCsvBase); } @@ -68,7 +68,7 @@ public void configure(Header header, Layout layout) { layout.row("links") .el(Table.class, (viz, data) -> { - viz.title = "Emissions"; + viz.title = "Air Pollution"; viz.description = "by pollutant. Total values are scaled from the simulation sample size to 100%."; viz.dataset = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_total.csv", new String[0]); viz.enableFilter = false; @@ -76,7 +76,7 @@ public void configure(Header header, Layout layout) { viz.width = 1.0; }) .el(Links.class, (viz, data) -> { - viz.title = "Emissions per Link per Meter"; + viz.title = "Emitted Pollutant in Gram per Meter"; viz.description = finalLinkDescription; viz.height = 12.0; viz.datasets.csvFile = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_per_link_per_m.csv", new String[0]); From 24ae7d441521f310496d80840a754a0ea9073cb3 Mon Sep 17 00:00:00 2001 From: schlenther Date: Thu, 26 Sep 2024 12:47:21 +0200 Subject: [PATCH 5/6] checkstyle --- .../matsim/dashboard/AverageKelheimEmissionsDashboard.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java b/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java index da115ca..9ac111d 100644 --- a/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java +++ b/src/main/java/org/matsim/dashboard/AverageKelheimEmissionsDashboard.java @@ -27,7 +27,6 @@ import org.matsim.simwrapper.Layout; import org.matsim.simwrapper.viz.*; -import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -51,7 +50,7 @@ public AverageKelheimEmissionsDashboard(List dirs, Integer noRuns, Strin this.dirs = dirs; this.noRuns = noRuns; - if(pathToBaseRun == null || pathToBaseRun.equals("null")){ + if (pathToBaseRun == null || pathToBaseRun.equals("null")){ this.pathToCsvBase = null; } else { if (!pathToBaseRun.endsWith("/")) { @@ -90,7 +89,7 @@ public void configure(Header header, Layout layout) { viz.showAllRows = true; viz.width = 1.0; }) - /** + /* * Commented out link panel, because the MapPlot can show a legend and seems to be the development head. * However, it doesn't seem to have the pointer to the base case */ From bbb5aea55e754fae9224a5bbaf6ffc0ce57eb2c6 Mon Sep 17 00:00:00 2001 From: schlenther Date: Thu, 26 Sep 2024 14:18:51 +0200 Subject: [PATCH 6/6] * only dump 4 decimal digits * always set projection per yaml for GridMaps --- ...missionsPostProcessingAverageAnalysis.java | 8 ++++---- ...rPollutionAnalysisByEngineInformation.java | 20 ++++++++++++------- .../dashboard/KelheimEmissionsDashboard.java | 2 ++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java b/src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java index e1e0463..f07cbd6 100644 --- a/src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/emissions/EmissionsPostProcessingAverageAnalysis.java @@ -198,8 +198,8 @@ public Integer call() throws Exception { } // write grid mean stats - writeGridFile("mean_emissions_grid_per_day.xyt.csv", meanGridPerDay); - writeGridFile("mean_emissions_grid_per_hour.csv", meanGridPerHour); + writeGridFile("mean_emissions_grid_per_day.xyt.csv", meanGridPerDay, nf); + writeGridFile("mean_emissions_grid_per_hour.csv", meanGridPerHour, nf); return 0; } @@ -223,7 +223,7 @@ private void getGridData(Table gridTable, Map, List, Double> values) throws IOException { + private void writeGridFile(String fileName, Map, Double> values, NumberFormat numberFormat) throws IOException { try (CSVPrinter printer = new CSVPrinter(Files.newBufferedWriter(output.getPath(fileName)), CSVFormat.DEFAULT)) { //set the projection in the YAML instead, as this is put out with a quote atm... @@ -231,7 +231,7 @@ private void writeGridFile(String fileName, Map, Double printer.printRecord("time", "x", "y", VALUE); for (Map.Entry, Double> e : values.entrySet()) { - printer.printRecord(e.getKey().getKey(), e.getKey().getValue().getX(), e.getKey().getValue().getY(), e.getValue()); + printer.printRecord(e.getKey().getKey(), e.getKey().getValue().getX(), e.getKey().getValue().getY(), numberFormat.format(e.getValue())); } } } diff --git a/src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java b/src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java index e746f74..2c5ab6c 100644 --- a/src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/emissions/KelheimOfflineAirPollutionAnalysisByEngineInformation.java @@ -428,8 +428,6 @@ private void writeTotal(Network network, EmissionsOnLinkEventHandler emissionsEv //so we need to do some stupid filtering afterwards, which means that we produce and calculate more data than we dump out.... private void writeRaster(Network fullNetwork, Network filteredNetwork, Config config, EmissionsOnLinkEventHandler emissionsEventHandler) { - - Map rasterMap = FastEmissionGridAnalyzer.processHandlerEmissions(emissionsEventHandler.getLink2pollutants(), fullNetwork, gridSize, 20); Raster raster = rasterMap.values().stream().findFirst().orElseThrow(); @@ -437,6 +435,10 @@ private void writeRaster(Network fullNetwork, Network filteredNetwork, Config co try (CSVPrinter printer = new CSVPrinter(Files.newBufferedWriter(output.getPath("emissions_grid_per_day.xyt.csv")), CSVFormat.DEFAULT.builder().setCommentMarker('#').build())) { + NumberFormat nf = NumberFormat.getInstance(Locale.US); + nf.setMaximumFractionDigits(4); + nf.setGroupingUsed(false); + String crs = ProjectionUtils.getCRS(fullNetwork); if (crs == null) crs = config.network().getInputCRS(); @@ -444,7 +446,7 @@ private void writeRaster(Network fullNetwork, Network filteredNetwork, Config co crs = config.global().getCoordinateSystem(); // print coordinate system - printer.printComment(crs); +// printer.printComment(crs); // print header printer.print("time"); @@ -478,7 +480,7 @@ private void writeRaster(Network fullNetwork, Network filteredNetwork, Config co printer.print(coord.getY()); double value = rasterMap.get(Pollutant.CO2_TOTAL).getValueByIndex(xi, yi); - printer.print(value); + printer.print(nf.format(value)); printer.println(); } @@ -515,14 +517,18 @@ private void writeTimeDependentRaster(Network fullNetwork, Network filteredNetwo try (CSVPrinter printer = new CSVPrinter(IOUtils.getBufferedWriter(output.getPath("emissions_grid_per_hour.csv").toString()), CSVFormat.DEFAULT.builder().setCommentMarker('#').build())) { + NumberFormat nf = NumberFormat.getInstance(Locale.US); + nf.setMaximumFractionDigits(4); + nf.setGroupingUsed(false); + String crs = ProjectionUtils.getCRS(fullNetwork); if (crs == null) crs = config.network().getInputCRS(); if (crs == null) crs = config.global().getCoordinateSystem(); - // print coordinate system - printer.printComment(crs); +// print coordinate system +// printer.printComment(crs); // print header printer.print("time"); @@ -560,7 +566,7 @@ private void writeTimeDependentRaster(Network fullNetwork, Network filteredNetwo printer.print(coord.getX()); printer.print(coord.getY()); - printer.print(value); + printer.print(nf.format(value)); printer.println(); } diff --git a/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java b/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java index 1eade5e..952fd5c 100644 --- a/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java +++ b/src/main/java/org/matsim/dashboard/KelheimEmissionsDashboard.java @@ -96,6 +96,7 @@ public void configure(Header header, Layout layout) { viz.title = "CO₂ Emissions"; viz.description = "per day. Be aware that CO2 values are provided in the simulation sample size!"; viz.height = 12.0; + viz.projection = "EPSG:25832"; viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_day.xyt.csv", new String[0]); viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED}); @@ -105,6 +106,7 @@ public void configure(Header header, Layout layout) { viz.title = "CO₂ Emissions"; viz.description = "per hour. Be aware that CO2 values are provided in the simulation sample size!"; viz.height = 12.; + viz.projection = "EPSG:25832"; viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_hour.csv"); viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED}); });