Thursday, February 19, 2015

Tutorial: Use basemap.gs to make a beautiful map of "SST", Sea Ice and Snow in GrADS

This tutorial will draw upon many of the skills discussed in several other tutorials on this site, e.g., how to handle multiple files at once, or how to use basemap.gs.  There isn't too much "new" information in this tutorial on how to use these different features and functions of GrADS, rather this tutorial will show you how to specifically make a very pretty map of sea-surface temperature, sea ice, and snow.  The final outcome is shown below.

For this tutorial you will need:

 Snow Cover and Sea Ice on the Robinson Map Projection

So before we start, I want to give a full disclaimer: The plot is not actually showing any observed SST.  In this tutorial I'm going to use the 0.25 degree GFS surface temperature.  In practice the surface temperature should be roughly equal to the SST over the Oceans.

The first thing we need to do is open both the GFS data and the sea ice data.  This data will come from NOMADS and will be opened using the 'sdfopen' command.  Note, the files below are for February 2015, so keep in mind, that you will need to change the date on files if you wish to copy paste the example code below.

'reinit'

'sdfopen 'gfsfile
'sdfopen 'icefile

Now that the files are open we will simply set up the map.  Since we are using the Robinson Projection, we need to set the longitude to range from -180 to 180 and the latitude -90 to 90.

'set mpdset hires'
'set lon -180 180'
'set lat -90 90'
'set mproj robinson'
'colormaps -l 272 307 0.5 -map jet' ;*Note the use of colormaps.gs

Then we display the variable:

'd tmpsfc'
'xcbar -fs 4'

After a moment, the surface temperature will be displayed following the "jet" color map.
Now, we are going to mask out the land using the land basemap from basemap.gs.

Note, in my version of basemap.gs, I did not want to include the frame around the map projection.  So I opened up basemap.gs and commented out the lines at the bottom that draw the rectangle:

* Draw a new square frame around the plot
* If you have 'set frame off' or 'set frame circle' before running basemap,
* you may want to comment out the next 2 lines
*'set line 1 1 6'
*'draw rec 'x1' 'y1' 'x2' 'y2

We are going to use the "medium (M)" resolution option for the coastlines, and we are going to define a custom dark gray color for the land.

'set rgb 73 80 80 80'
'basemap L 73 0 M'         ;*L = Land, 73 = Fill Color, 0 = outline Color, M=Medium resolution

 SST only!
This will fill in the land areas with a gray map and you will have an image like this:

Now that we are done with the "SST" and the land mask, we are going to open up the sea-ice file and plot the sea ice.  It is important that you use the maskout function when plotting the sea-ice, otherwise you will overwrite all of the SST data with zeros.

'set dfile 2'                   ;*Sets Default file to file 2 (Sea ice)
'set z 1'                        ;*Set z to 1
'set t 1'                        ;*Set t to 1
'set map 0 1 6'
'color 0 0.6 0.1 -kind dimgray->seashell->white'           ;*Note use of color.gs

After a few moments, the sea ice will plot and you will have an image like this:

 Sea Ice and SST only!
Now this is all well and good, but our knowledge is limited to the ice over the oceans, we don't really get any sense of how ice and snow covers the land masses.  So the final touch that we'll add to the map is to plot the GFS snow water equivalent (SWE) using a similar color scale as ice cover.  To do that, we need to reset the file to our first file and then reset our time our vertical level.  Lastly, we plot SWE (again using maskout to avoid plotting over everything).

'set dfile 1'
'color 10 100 5 -kind dimgray->seashell->white'
'set z 1'
'set t 1'
'set map 0 1 6'

And after a few moments, you have a map like the one shown at the beginning of the tutorial.
You can play around with your minimum values for ice and snow, I used 0.1 for sea-ice and 10 mm for SWE.  That seemed to produce a good looking map.  Experiment as you like!  This plot is really basic, no special formatting outside of the actual plot (titles, etc).  Hopefully you enjoyed this tutorial, I know it was oddly specific, and didn't really present anything new, hopefully you learned something anyway!

1. Hye there, there is a problem with the basemap scripts. I try to do your tutorial but for the basemap it's said error reading 1poly_mres.asc

2. I am wondering how to use ESRI shape files in order to maskout the area of interest in GrADS.

1. Hi, it sounds like this should be a fairly straightforward problem, should just be able to draw a shapefile with the fill option after plotting.

I don't know if you've seen some of the other tutorials on this site, but there are a few that deal with using shapefiles: