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}); });