Walter & Leith climate diagrams illustrate precipitation and temperature changes throughout the year in one standardized chart. They are especially useful to determine water stress or other significant climatic factors on plants. This step-by-step guide teaches how to generate your own Walter & Leith climate diagram using the software called R. Here are some samples that I made for several places in the Andean highlands following this process:
R is a command-line based open source software that is hugely flexible for computations and quantitative visuals. This post assumes basic knowledge of R. If you don't know anything about R, see this post for an introduction and links to more information. You will also need basic working knowledge of excel or similar spreadsheet software. I find that OpenOffice's spreadsheet software works even better than Excel and it's open source to boot.
For any more advanced R users reading this post, there are definitely more efficient ways to do this task. I put together this tutorial for a 2-hour introductory workshop with people who had never used the software before, so I chose to make it as simple as possible. Please feel free to do this your way, and to post comments with any recommendations.
In this tutorial we will use the climatol package. Its description and guide can be found here:
http://cran.r-project.org/web/packages/climatol/index.html
Precip = average precipitation in mm per month
Max temp = maximum average temperature per month in ºC
Min temp = minimum average temperature per month in ºC
Abs min t = daily minimum temperature per month in ºC.
If you do not have the abs min t data, simply copy the minimum temperature data from the column above, but do not leave the cells blank.
2. Delete the first column in excel so that only the data remains. Be sure to delete any extra text and formatting anywhere in the file.
3. Save the file as a .csv
2. Attach the installed package to your session using this command:
>require(climatol)
3. Set the working directory to the folder where you keep your files using the Misc drop down menu. Verify it with this command, which should return the file path to the directory you selected in the drop down command.
> getwd()
4. Load and assign a name to your data:
> name=read.csv("folder/subfolder/datafile.csv")
5. View your data and check for anything unexpected. Reload as needed.
>name
COMMON ERROR: If you see anything strange here, then go back to step 2 and delete rows and columns that are adjacent to your data (even if they are blank). Be sure to put your cursor in cell A1, which should be the upper left-hand corner of your table, before saving. You can also try a "paste special" of "values" only into a new spreadsheet and resaving. If it still isn't normal-looking, then try opening your spreadsheet in Openoffice (it's free) and converting into .csv from there, with no extra formatting.
6. Create the plot (this returns in a new window):
> diagwl(name, est="Location",alt=elevation, per="dates", mlab="en")
COMMON ERROR: If you do not see a window with the graph open up, select the button that looks like a bar graph at the top of the R window, and try the command again, using the up arrow.
7. Adjust the colors if you like, using the color chart pdf:
> diagwl(name,est="Location",alt=elevation,per="dates",mlab="en",pcol="#color1",sfcol="#color2")
These are the color parameter names, with their default colors:
pcol Color pen for precipitation ("#005ac8").
Tcol Color pen for temperature ("#e81800").
Pfcol Fill color for probable frosts ("#79e6e8").
Sfcol Fill color for sure frosts ("#09a0d1").
8. Assign a name to the plot:
> plotname=diagwl(name,est="Location",alt=elevation,per="dates",mlab="en",
pcol="#color1",sfcol="#color2")
9. Generate a plot file of the plot in your working directory as .eps:
For an .eps file, use this string of commands:
> postscript("plotname.eps", horizontal = FALSE, onefile = FALSE, paper = "special", height = 10, width = 10)
> setEPS()
> postscript("plotname.eps")
> diagwl(name,est="Location",alt=elevation,per="dates",mlab="en",
pcol="#color1",sfcol="#color2")
> dev.off()
10. Repeat from step 4 to create any additional diagrams while in the same session.
I originally developed this tutorial as part of a workshop for graduate students in Environmental Science and Policy at Central European University in Budapest, Hungary.
R is a command-line based open source software that is hugely flexible for computations and quantitative visuals. This post assumes basic knowledge of R. If you don't know anything about R, see this post for an introduction and links to more information. You will also need basic working knowledge of excel or similar spreadsheet software. I find that OpenOffice's spreadsheet software works even better than Excel and it's open source to boot.
For any more advanced R users reading this post, there are definitely more efficient ways to do this task. I put together this tutorial for a 2-hour introductory workshop with people who had never used the software before, so I chose to make it as simple as possible. Please feel free to do this your way, and to post comments with any recommendations.
Downloads you will need:
In this tutorial we will use the climatol package. Its description and guide can be found here:
http://cran.r-project.org/web/packages/climatol/index.html
You will need to download this package, using R, prior to starting this process.
Part 1: Gathering Data
Before starting, have this data on hand for your location of interest:
- Name of the location.
- Elevation of the location in meters above sea level.
- The range of years that the climate data was collected.
- The monthly climate data as per the table below (Abs min t is optional).
Part 2: Preparing the data in a spreadsheet
1. Create a spreadsheet with the following information in the upper left-hand corner of the file (replace the numbers to match your data - this is just an example).
Precip = average precipitation in mm per month
Max temp = maximum average temperature per month in ºC
Min temp = minimum average temperature per month in ºC
Abs min t = daily minimum temperature per month in ºC.
If you do not have the abs min t data, simply copy the minimum temperature data from the column above, but do not leave the cells blank.
2. Delete the first column in excel so that only the data remains. Be sure to delete any extra text and formatting anywhere in the file.
3. Save the file as a .csv
Part 3: Working in R
1. In R, use the Package drop down menu to install the climatol package. You will need an intenet connection to do this.
2. Attach the installed package to your session using this command:
>require(climatol)
3. Set the working directory to the folder where you keep your files using the Misc drop down menu. Verify it with this command, which should return the file path to the directory you selected in the drop down command.
> getwd()
4. Load and assign a name to your data:
> name=read.csv("folder/subfolder/datafile.csv")
5. View your data and check for anything unexpected. Reload as needed.
>name
COMMON ERROR: If you see anything strange here, then go back to step 2 and delete rows and columns that are adjacent to your data (even if they are blank). Be sure to put your cursor in cell A1, which should be the upper left-hand corner of your table, before saving. You can also try a "paste special" of "values" only into a new spreadsheet and resaving. If it still isn't normal-looking, then try opening your spreadsheet in Openoffice (it's free) and converting into .csv from there, with no extra formatting.
6. Create the plot (this returns in a new window):
> diagwl(name, est="Location",alt=elevation, per="dates", mlab="en")
COMMON ERROR: If you do not see a window with the graph open up, select the button that looks like a bar graph at the top of the R window, and try the command again, using the up arrow.
7. Adjust the colors if you like, using the color chart pdf:
> diagwl(name,est="Location",alt=elevation,per="dates",mlab="en",pcol="#color1",sfcol="#color2")
These are the color parameter names, with their default colors:
pcol Color pen for precipitation ("#005ac8").
Tcol Color pen for temperature ("#e81800").
Pfcol Fill color for probable frosts ("#79e6e8").
Sfcol Fill color for sure frosts ("#09a0d1").
8. Assign a name to the plot:
> plotname=diagwl(name,est="Location",alt=elevation,per="dates",mlab="en",
pcol="#color1",sfcol="#color2")
9. Generate a plot file of the plot in your working directory as .eps:
For an .eps file, use this string of commands:
> postscript("plotname.eps", horizontal = FALSE, onefile = FALSE, paper = "special", height = 10, width = 10)
> setEPS()
> postscript("plotname.eps")
> diagwl(name,est="Location",alt=elevation,per="dates",mlab="en",
pcol="#color1",sfcol="#color2")
> dev.off()
10. Repeat from step 4 to create any additional diagrams while in the same session.
I originally developed this tutorial as part of a workshop for graduate students in Environmental Science and Policy at Central European University in Budapest, Hungary.