## climate visualization with Matlab

This tutorial goes through the process of visualizing TMY3 (Typical Meteorological Year) data using Matlab.

A common problem with weather visualization using tools like Ecotect or Climate Consultant is they only visualize 1 set of data at a time. But the ability to combine different datasets is critical to material decisions and spatial organization strategies. Thus, this tool is created for the sole purpose of enabling architects to actively use weather data to make better design decisions.

The 4 small Matlab scripts are meant for educational purpose only and you can download them here.

- Open ReadEPW.m
- Line 2 reads (‘Country_City_WeatherStation.epw‘);
- Change Country_City_WeatherStation.epw to a TMY3 data file you want to open, and click Run, the file will bring the weather into Matlab.
- Open EPW2Hourly.m and click Run, the file will sort through all the variables and give them proper names.
- Type in command:

plot(x,dbt,x,dpt);

to plot Dry Bulb Temperature and Dew Point Temperature on the same graph.

- Open EPW2Daily.m and click Run to arrange the data into daily values.
- Type in command:

pcolor(dbt);

to plot the Dry Bulb Temperature as a pseudo-color image.

- Type in command:

Colormap(jet);

to change the color mapping of the plot
- You may use the same commend to plot the following:

Direct Normal Radiation

Global Horizontal Radiation

Actual Vapour Content in Kg/Kg

Relative Humidity

Windspeed

- Type in command:

[fx,fy]=gradient(dbt);

to calculate the rate of change of Dry Bulb Temperature.
- Type in command:

quiver(x,y,fx,fy);

to plot the rate of change of Dry Bulb Temperature.

- Open EPW_DiurnalSwing.m and click Run to calculate the diurnal swing.
- Type in command:

x1 = 1:365;

To create a new variable x1.
- Type in command:

plot(x1,dbtMax,x1,dbtMin);

to plot Maximum Dry Bulb Temperature and Minimum Dry Bulb Temperature on the same graph to see the daily temperature changes.

- Type in command:

plot(x1,rhMax,x1,rhMin);

to plot Maximum Relative Humidity and Minimum Relative Humidity on the same graph to see the daily humidity changes.

- Type in command:

plot(x1,kgprkgMax,x1,kgprkgMax);

to plot the Maximum Water Vapor Content and Minimum Water Vapor Content on the same graph.

This entry was posted
on Sunday, August 22nd, 2010 at 12:38 pm and is filed under experiments and tagged with data visualization, matlab, weather data.
You can follow any responses to this entry through the RSS 2.0 feed.

I’m using a weather file for Graz in Austria however when running the ReadEPW.m all I end up getting is this warning –

??? The following error occurred converting from cell to double:

Error using ==> double

Conversion to double from cell is not possible.

any ideas?

Hi

These look awesome. Do you have the scripts for Scilab? Unfortunately cost restraints mean that I cannot use Matlab.

Many Thanks

Hi!

Firstly, an excellent site with amazing tutorials! I have a question regarding generation of the scale. For all the pseudo colour maps that you have generated, how can I get matlab to generate a scale as well?

I would also be posting a link to this tutorial on my website! Well done!

Cheers!

Found it! It’s the Colourbar command in the Insert menu!

Dan,

Scilab has comes with a Matlab translator. Much of the Matlab functions used are pretty common to all the Matlab “clones”. Unfortunately I don’t use Scilab, but I’m pretty interested in releasing the code in a format that’s opensource. Shoot me an email and let me know if you have any luck opening it in Scilab. Cheers!

try re-downloading the ReadEPW.m file from the Psychrometrics post.

Sorry i got the same problem that rhys above. any suggestions

??? The following error occurred converting from cell to double:

Error using ==> double

Conversion to double from cell is not possible

Error in ==> ReadEPW at 21

Thanks

[...] http://www.tedngai.net/experiments/climate-visualization-with-matlab.html [...]

Hi!

I have adapted your script into Excel and posted it on my blog. Have a look.

Cheers!

Excel is a good entry point to data processing. And the problem with Excel is it doesn’t handle matrix. Try calculating absolute humidity, enthalpy, heating degree days, or calculating the amount of solar irradiation on tilted surface, that’s when things get really tricky. You’ll end up doing a lot more coding. A good alternative to Matlab is all the opensource Matlab clones – try Octave or Scilab, they’re both very good alternative and require very little translation.

Dear ted,

thanks for your beautiful tool!

In the graph of “Maximum Dry Bulb Temperature and Minimum Dry Bulb Temperature” the area in between the two lines are hatched.

May I ask how do you do that in Matlab?

Plus, how do you make the X axis shown as months? The X axis of the chart created via your Matlab script is shown as days from 0 – 400

Thanks!

Hey!

You inspired me to learn Scilab, and I am now working on creating similar script for Scilab. I would be publishing them soon on my website.

Cheers!