Average domain temperature

All around LEONARDO 4 (and previous 2014)
maherrerahu
Posts: 32
Joined: Thu Mar 22, 2018 9:35 pm

Average domain temperature

Post by maherrerahu »

Hello Envi Met team!

I wonder if the receptors are enough to know the temperature of every hour and in each height for the whole domain, or if I have to put a receptor in each cell to extract the information from the whole domain and finally average all the data (excluding buildings, of course)

Thank you very much

Maria

Tim
Posts: 1668
Joined: Mon May 15, 2017 3:46 pm

Re: Average domain temperature

Post by Tim »

Hi Maria,

the receptor only extracts the information for every hour and every height of the specified grid cell. If you want to average the whole domain, you will need to place more receptors or try to use the map script function of Leonardo.

Best regards
Tim

maherrerahu
Posts: 32
Joined: Thu Mar 22, 2018 9:35 pm

Re: Average domain temperature

Post by maherrerahu »

Tim wrote:Hi Maria,

the receptor only extracts the information for every hour and every height of the specified grid cell. If you want to average the whole domain, you will need to place more receptors or try to use the map script function of Leonardo.

Best regards
Tim
Hi Tim,

Thank you for answer.
Could you please tell me in what programming language should I run it or what are the variables needed to write the codes or where could I find the instructions to use the map script function?

Tim
Posts: 1668
Joined: Mon May 15, 2017 3:46 pm

Re: Average domain temperature

Post by Tim »

Hi Maria,

the MapScript function is located at the 'Data' tab. At the lower right corner of the Map Script Editor you can find the Help button, which gives some information about key variables.
In order to calculate an average for the whole domain (without including data from objects like buildings) you can use this script:

var
sum: Double;
i,j,counter: Integer;

Begin
{Edit your code here for the main routine}
sum := 0;
counter := 0;

for i := 0 to map_xgrids-1 do
for j := 0 to map_ygrids-1 do
if mapdata('Special2D',i,j) = 0 then
begin
sum := sum + mapdata('Data2D',i,j);
counter := counter + 1;
end;

Writeln(sum/counter);

Best regards
Tim

maherrerahu
Posts: 32
Joined: Thu Mar 22, 2018 9:35 pm

Re: Average domain temperature

Post by maherrerahu »

Tim wrote:Hi Maria,

the MapScript function is located at the 'Data' tab. At the lower right corner of the Map Script Editor you can find the Help button, which gives some information about key variables.
In order to calculate an average for the whole domain (without including data from objects like buildings) you can use this script:

var
sum: Double;
i,j,counter: Integer;

Begin
{Edit your code here for the main routine}
sum := 0;
counter := 0;

for i := 0 to map_xgrids-1 do
for j := 0 to map_ygrids-1 do
if mapdata('Special2D',i,j) = 0 then
begin
sum := sum + mapdata('Data2D',i,j);
counter := counter + 1;
end;

Writeln(sum/counter);

Best regards
Tim

Dear Tim,

Thank you very much for your help!

Actually, the real problem that I have, is the "Data2D" generation for Air Temperature and Relative Humidity at many position of view plane and for different hour, and it exportation. Because it is to hard to generate this data manually with Leonardo Plataform.

What I mean is that I need a script to export this large data and then calculate the average.

I hope that you can understand me.

Kind regards,

Maria

Tim
Posts: 1668
Joined: Mon May 15, 2017 3:46 pm

Re: Average domain temperature

Post by Tim »

Hi Maria,

I understand your wish to export all the data as average values. At the moment, I only see the 2 possibilities that I mentioned before:
1. Place receptors at every grid cell without buildings and merge the resulting receptor files. You will then get the data for all heights and hours but need to handle/merge several files (e.g. 10000 receptor files for a relatively small model area of 100x100 grids). I'd recommend writing a small script for that.
2. Extract the air temperature and subsequently the rel. humidity for every hour and every height that you need. Run the map script and save the resulting average values. This may take some time but can be done even when the simulation already finished (with no or only a few receptors in the model area) and needs no further programming skills (if you use my map script from above).

Best regards
Tim

maherrerahu
Posts: 32
Joined: Thu Mar 22, 2018 9:35 pm

Re: Average domain temperature

Post by maherrerahu »

Tim wrote:Hi Maria,

I understand your wish to export all the data as average values. At the moment, I only see the 2 possibilities that I mentioned before:
1. Place receptors at every grid cell without buildings and merge the resulting receptor files. You will then get the data for all heights and hours but need to handle/merge several files (e.g. 10000 receptor files for a relatively small model area of 100x100 grids). I'd recommend writing a small script for that.
2. Extract the air temperature and subsequently the rel. humidity for every hour and every height that you need. Run the map script and save the resulting average values. This may take some time but can be done even when the simulation already finished (with no or only a few receptors in the model area) and needs no further programming skills (if you use my map script from above).

Best regards
Tim

Hi Tim,

Thank you very much for your help and your patience.
The last question (I hope so) ... If I selected option 1, how computationally expensive could be to have too many receivers? This, because in option 2 my hand hurts.

In any case, I am very grateful for your collaboration.

Maria

maherrerahu
Posts: 32
Joined: Thu Mar 22, 2018 9:35 pm

Re: Average domain temperature

Post by maherrerahu »

maherrerahu wrote:
Tim wrote:Hi Maria,

I understand your wish to export all the data as average values. At the moment, I only see the 2 possibilities that I mentioned before:
1. Place receptors at every grid cell without buildings and merge the resulting receptor files. You will then get the data for all heights and hours but need to handle/merge several files (e.g. 10000 receptor files for a relatively small model area of 100x100 grids). I'd recommend writing a small script for that.
2. Extract the air temperature and subsequently the rel. humidity for every hour and every height that you need. Run the map script and save the resulting average values. This may take some time but can be done even when the simulation already finished (with no or only a few receptors in the model area) and needs no further programming skills (if you use my map script from above).

Best regards
Tim

Hi Tim,

Thank you very much for your help and your patience.
The last question (I hope so) ... If I selected option 1, how computationally expensive could be to have too many receivers? This, because in option 2 my hand hurts :oops: :cry:

In any case, I am very grateful for your collaboration.

Maria

Tim
Posts: 1668
Joined: Mon May 15, 2017 3:46 pm

Re: Average domain temperature

Post by Tim »

Hey Maria,

I never tried to place that many receptors. They are usually not time consumpting but in such high amount they will definitely cause a delay. You have to try out how fast the simulation runs.

Best regards
Tim

maherrerahu
Posts: 32
Joined: Thu Mar 22, 2018 9:35 pm

Re: Average domain temperature

Post by maherrerahu »

Dear Tim,

I really appreciate your help. I'll try to see how long it takes.

Have a nice day

Maria

sara5759
Posts: 20
Joined: Mon Nov 25, 2019 2:01 am

Re: Average domain temperature

Post by sara5759 »

Dear ENVI-met team
I have read all topics about average temperature in a given area. I need to calculate the mean temperature for just outdoor area excluding buildings. Thus I need to calculate them for more than 30 senarios, I need to find a very easy way to do that. I used the script you provided for two maps; air temperature at 1.5 height and surface temperature. Both maps have been attached. These are the results:

Air temperature map
Mean temperature include buildings: 31.4088818381933 °C
Mean temperature exclude buildings: 31.4095282395625 °C

Surface temperature
Mean temperature include buildings: 32.7341864669422 °C
Mean temperature exclude building: 32.7305928530969 °C

As you can see there is no much difference between them when building involved, which seems weird especially for surface temperature. From the legend in surface temperature maps, it is guessable that the outdoor mean temperature would be around approximately 36°C. Then, I decided to solve this problem. With the help of one of my friends, I wrote a script and tried it. It shows the same result as your script for air temperature but the surface temperature was quite different. However, I am not sure about it. Since the results will go to my doctoral thesis could you please take a look at that.
This is the script written for surface temperature:
var
sum: Double;
i,j,counter: Integer;

Begin
{Edit your code here for the main routine}
{AnalyseMap;
AnalyseMask(FALSE); }
sum := 0;
counter := 0;

for i := 0 to map_xgrids-1 do
for j := 0 to map_ygrids-1 do
{Writeln(mapdata('Data2D',i,j)) }
if mapdata('Data2D',i,j) > 22 then
begin
sum := sum + mapdata('Data2D',i,j);
counter := counter + 1;
end;

Writeln(sum/counter);
end;

These are the results.
Air temperature map
Mean temperature exclude buildings: 31.4095282395625 °C
Surface temperature
Mean temperature exclude building: 36.7921607648367°C

Many thanks for your help and supports.

Best regards
Sara
Attachments
Mapscript for air temperature.jpg
TS.jpg
TA.jpg

Tim
Posts: 1668
Joined: Mon May 15, 2017 3:46 pm

Re: Average domain temperature

Post by Tim »

Hi Sara,

In Surface outputs is no SpecialLayer information included. The If condition asking for any free cells (Special2d = 0) thus gives you all cells as result and calculates the average also for cells within buildings. You new if condition is thus much better for the surface outputs since you ask if the temperature is above a certain level. 22 °C though might be too high since there could be some places with have around 20 °C in your model area. Buildings all show the default value of 19.85 °C. If you ask for Data2D > 19.86, it will also average all free cells but also includes cells which may have values lower than 22 °C.

Best regards,
Tim

sara5759
Posts: 20
Joined: Mon Nov 25, 2019 2:01 am

Re: Average domain temperature

Post by sara5759 »

Hi Tim,

That is very helpful :) . I really appreciate it.

Regards
Sara

fsophia
Posts: 2
Joined: Tue Apr 14, 2020 2:53 pm

Re: Average domain temperature

Post by fsophia »

Hi team,

I want to gather the averages of potential air temperature, wind speed and mean radiant temperature of mask of my study area (roughly 2x20 cells, all at the same height). I'd like to have that for every hour in my simulation (which are 120 hours). What would be the best way to gather that, apart from distracting the excel files for the 40 cells and calculating the average there? I've tried to use to map script function but I'm not sure if it can produce the above mentioned goal.

Thanks in advance!

Tim
Posts: 1668
Joined: Mon May 15, 2017 3:46 pm

Re: Average domain temperature

Post by Tim »

Hi,

You could write a short program which reads our binary files and extracts the data for all timesteps of your area of interest. However, I would simply enable write netcdf outputs and extract the data by various netcdf analysis programs or tools. It should e.g. quickly be possible to extract the data from netcdf with R.

Best regards,
Tim

Post Reply