Showing posts with label Reanalysis. Show all posts
Showing posts with label Reanalysis. Show all posts

Monday, May 13, 2013

Tutorial: Use the tcorr function to create a map of regression/correlation coefficients in GrADS

Making a correlation map in GrADS is actually quite simple.  A regression/correlation map, is basically a map of regression and correlation coefficients plotted against a time-series of some variable.  The classic example is the monthly average time-series of El-Nino vs. surface temperature on the globe.  The example used in this tutorial will be 500mb height correlated with the 500mb height over the northeast U.S.  For this tutorial we will use the NCEP reanalysis data.

GrADS makes correlation maps very simple.  All you need is a data set that varies in both space and time.  The first step is to define your time-series variable.  In the interest of time and simplicity, I will just take the 500mb height at one point rather than average over a small spatial area, as is often done when doing these maps.  So lets open the data file and set our time-series variable!

    'sdfopen http://monsoondata.org:9090/dods/rean3d'
    'set t 1 636'
    'set lev 500'
    'set lat 44'
    'set lon 282'
    'ts_var=z'


The variable "ts_var" is our time-series variable, and basically we saved the time-series of geopotential height at 500mb at the lat/lon point of 44/282.  Now, we are going to use two intrinsic GrADS functions to plot the regression coefficients (shaded) and the correlation coefficients (contoured above 0.5).

So, to plot our coefficients, we use the 'tregr()' and the 'tcorr()' functions.  Both of these functions do essentially the same thing; you feed them a time-series variable, and a spatial variable, as well as time-constraints, and the function plots your coefficients.

Example:  tregr(x, y, t=1, t=50)

This variable takes the regression coefficients of spatial variable y and time-series x through the first 50 time-steps.  In our example of 500mb height our code looks like:
  
    'set gxout shaded'
    'set t 1'
    'set lat 0 90'
    'set lon 180 360'
    'd tregr(ts_var,z,t=1,t=636)'

    'set gxout contour'
    'set cstyle 2'
    'set cthick 6'
    'set ccolor 1'
    'set clevs 0.5 0.6 0.7 0.8 0.9 1.0'
    'd tcorr(ts_var,z,t=1,t=636)'


Most of the above code is for display of the contour variable; style, thickness, levels, but you can see the tregr() and the tcorr() functions used correctly.  If you are following along at home, the resultant map is plotted.

Shaded:Regression Coefficients, Contoured: Correlation Coefficients

So, what you can gather from this map is that the 500mb geopotential height is generally well correlated above 20 degrees N (r>0.8).  Furthermore, you can pick out the Rossby wave pattern in the regression coefficients.  In anycase, this example show give you an idea of how to make regression/correlation maps in GrADS.

Download Example Script

Thursday, May 2, 2013

Script: NARR Plotter version 2.1

Update as of October 2019: Unfortunately, the NARR access through the GDS has been discontinued, and as a result, this script is no longer functional.  However, it's possible you could change some of the code around to work with NARR data you have saved locally.

A new version of this script has been developed and can be found here.

This script uses the GrADS widgets to create a GUI for generating quick data plots using data from the North American Regional Reanalysis (NARR).  This GUI is an excellent way to quickly and easily make images using the NARR dataset.  This is the 2nd major overhaul of this script, and it includes a help page and a settings page.  It should work just fine out of the box, but if you want to plot variables that are not listed on the drop down menus, you will need to edit the script itself (instructions on how to do this are on the help page).  In any case, enjoy, and please report any bugs.  Also, I'd love to hear your feedback.

In order for this script to run properly you must have these scripts in your scripts folder.
color.gs  
xcbar.gs 

Note: A newer version of this script is available here.


Example Images:

Opening Screen
Cross Section Screen
Plotting Screen


Download Here