Tuesday, June 18, 2013

Outline Nested Grid Boundaries in GrADS

If you have ever attended a talk or a presentation, or read a paper for that matter, focused on modeling, you have likely encountered an image showing you the model domain with nested grid boundaries marked inside of it (see below).  This tutorial will show you how to use the 'q w2xy' command to draw these boundaries.  For this tutorial, we will show the NAM domain nested inside of the GFS.

NAM Domain outlined inside the GFS domain.

Lets first start by opening the files, and gathering our relevant information!

    'sdfopen http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20130618/gfs_hd_00z'
    'set mpdset hires'
    set display color white'
    'set clevs 100000'
    'd capesfc'

    'sdfopen http://nomads.ncep.noaa.gov:9090/dods/nam/nam20130618/nam_00z'
    'set dfile 2'
    'q file'

This code first opens the GFS (parent file) and then displays a dummy variable so that we have a map and a scaled environment. It then opens the NAM (nested file) and gathers the number of x and y grid-points in the domain.  This is important, as we can make use of this data to help set our boundaries.

The simplest way to draw the domain of a nested grid is to take the lower left and the upper right corners of your domain, and draw a rectangle around them.  We will set the nested model to encompass its entire domain and then, by using the 'q dims' and the 'q w2xy' commands, we will convert the lat/lon coordinates to page coordinates and draw our box.

    'set x 1 'xmax
    'set y 1 'ymax  
    'q dims'





     *Bottom Left Corner
    'q w2xy 'lonmin' 'latmin

   *Top Right Corner
    'q w2xy 'lonmax' 'latmax

What we did here, was just get the minimum lat/lon coordinate, and the maximum lat/lon coordinate and convert them to page coordinates using the 'q w2xy' command.  Note: the longitude values had to be added to 360 to account for the differences between the two domains.  Then we saved each value.  Now, the last thing we need to do is draw the rectangle.  This is done by simply inputting the bottom left and top right corners into the 'draw rec' command.

    'set line 1'
    'set cthick 6'
    'draw rec 'x1' 'y1' 'x2' 'y2

I added a couple of commands to make the line thicker and black, but now you have your nested domain boundaries plotted in your parent grid (see image above).

Download Example Script Here

1 comment:

  1. Hi,
    I have a time of series, is possible the q w2xy?.
    Un example, please