Requirements

This script needs matplotlib and numpy installed. For an instruction how to install python-libraries click here.

Description

The “Compare Scenario Script” analyses an user defined area of interest and compares the values inside this area between two given simulation outputs. The idea of the script is, that the impact of two different planning scenarios on an area of interest is directly compareable. Hence, the script output shows two figures. The upper figure directly compares the values inside the area of interest from scenario 1 with the values inside the area of interest from scenario 2 for each timestep. The lower figure shows the absolute difference between scenario 1 and scenario 2 for each timestep.

General advice

  • Only change one input parameter at once (e.g. for scenario 2: only change the meteorological conditions and keep the model area the same or do it the other way around). Thus, the results are still compareable.
  • The area of interest should exist in both scenarios.
  • The script output should be shown together with screenshots of both model areas (scenario 1 and scenario 2)

Example

Settings

In this example, we would like to compare the Potential Air Temperature [°C] between both scenarios in the defined area.

File path

The Potential Air Temperture is saved in the atmosphere output folder. Hence, we need to set the Datafile 1 and Datafile 2 to the atmosphere folder of each scenario. Datafile 1 represents scenario A and Datafile 2 represents scenario B. For each, select a random .EDX-file in the corresponding atmosphere folder.

In addition you can also define a diagram-title which will be used in the output figure. Anyway, if you leave the Diagram Title field empty the script generates a appropriate title automatically.

Now click on the script and click “Copy to Python Console” to adjust the remaining settings.

Model Area

The area we would like to compare in both scenarios is displayed in red in the following images. Every grid cell inside this red cuboid will be taken into account. To set this area in the script, change the following lines accordingly:

# define the location you would like to compare (as bounding box)
x_from = 50
x_to = 60
y_from = 30
y_to = 50
z_from = 1
z_to = 4

(lines 16 - 22 in current script version)

x and y defines the horizontal position of the area of interst in your model area and z defines the vertical extend of your area of interest. You can use Spaces or Leonardo to look up the x, y and z values of your area of interest.

Scenario 1

Scenario 1 shows a greened model area with city parks and urban trees.

Scenario 2

In Scenario 2 the greened areas are replaced by paved ground.

Data index

The data indexes are printed on the console for the given output folder if you run the script. For the atmosphere output, the indexes are as follows:

Potential Air Temperature is at index 8, so we need to set:

data_index = 8

(line 26 in current script version)

Timespan

At last we need to set the timespan for which the area of interest is compared between both scenarios. The time variables are also index based. The first output-EDX-file in a folder has index 0. The second one has index 1. The following image illustrates the indexes:

If both scenarios were simulated for the same time period, the indexes between both output folders should match (e.g. the 0 index in both folders(scenario 1 atmosphere folder, scenario 2 atmosphere folder) is dated to 23.06.2018 08:00h). In this case it is enough to edit the following lines:

time_from = 0
time_to = 92

(lines 32 - 33 in current script version)

With index 0 we start at 23.06.2018 08:00h and with index 92 we end at 27.06.2018 04:00h.

Anyway, if the simulation periods between both scenarios do not match, we need to define the indexes separately for each folder (scenario). Example: Your first scenario simulation started at 23.06.2018 at 07:00h, so your first output (with index 0) is 23.06.2018 08:00h. Your second scenario simulation started at 23.06.2018 at 05:00h, so your first output (with index 0) is 23.06.2018 6:00h Then you need to define the indexes separately as follows:

time_from = 0
time_to = 92
 
time_from_scen2 = 2
time_to_scen2 = 94

(lines 40 - 41 in current script version)

Now the timespteps match again. Otherwise you would compare different timesteps.

Advanced Settings

There is the option to compare maximum or minimum values instead of the mean values. To do so, change lines 133 - 139 (in current script version) as follows:

Mean vallues (default)
#vals1 = (np.nanmin(data1, axis=1), "Min.")
#vals1 = (np.nanmax(data1, axis=1), "Max.")
vals1 = (np.nanmean(data1, axis=1), "Mean")
 
#vals2 = (np.nanmin(data2, axis=1), "Min.")
#vals2 = (np.nanmax(data2, axis=1), "Max.")
vals2 = (np.nanmean(data2, axis=1), "Mean")
Maximum values
#vals1 = (np.nanmin(data1, axis=1), "Min.")
vals1 = (np.nanmax(data1, axis=1), "Max.")
#vals1 = (np.nanmean(data1, axis=1), "Mean")
 
#vals2 = (np.nanmin(data2, axis=1), "Min.")
vals2 = (np.nanmax(data2, axis=1), "Max.")
#vals2 = (np.nanmean(data2, axis=1), "Mean")
Minimum values
vals1 = (np.nanmin(data1, axis=1), "Min.")
#vals1 = (np.nanmax(data1, axis=1), "Max.")
#vals1 = (np.nanmean(data1, axis=1), "Mean")
 
vals2 = (np.nanmin(data2, axis=1), "Min.")
#vals2 = (np.nanmax(data2, axis=1), "Max.")
#vals2 = (np.nanmean(data2, axis=1), "Mean")

Output

If all settings are done, the script is ready to get executed. The output should look like this:

If you would like to analyse pollutant-data instead, an output for e.g. NO2-concentration could look like this:

Technical Note

Note that the execution-time of the script may be unexpected high, especially when you compare longer time periods or large areas. This is caused by limited implementation options caused by the Delphi-Python-interface. During execution, the GUI might not be reactive.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies