Skip to content

Commit

Permalink
* use MapPlot instead of Link panel
Browse files Browse the repository at this point in the history
* emissions -> airPollution
* delete default for base-run
  • Loading branch information
tschlenther committed Sep 26, 2024
1 parent 5f2c763 commit e7bfc20
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -53,10 +51,14 @@ public AverageKelheimEmissionsDashboard(List<String> 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) {
Expand All @@ -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){
Expand All @@ -88,21 +90,44 @@ 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";
viz.display.width.scaleFactor = 100;
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!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,26 @@ 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);
}
String finalLinkDescription = linkDescription;

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;
viz.showAllRows = true;
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]);
Expand Down

0 comments on commit e7bfc20

Please sign in to comment.