Beruflich Dokumente
Kultur Dokumente
An Introduction to GrADS
This will copy a collection of files to your home directory and extract them.
Between tasks you can simply exit GrADS (quit) or reinitialize GrADS (reinit).
Note: commands written with “>” are UNIX commands, whilst “ga->” are GrADS
commands
All information will be available for download via my Earth Science’s personal page:
http://www.earthsci.unimelb.edu.au/~lgarde/grads/
Task 1 Command-Line
1. Execute GrADS
> grads
2. Open mslp.nc
ga-> sdfopen mslp.nc
3. Display mean sea level pressure (notice contours are in Pa)
ga-> d mslp
4. Clear display
ga-> c
5. Display mean sea level pressure again, but this time in hPa
ga-> d mslp/100
6. Set plot boundaries to be zoomed to the Australian region and display mean sea level
pressure (in hPa) again.
ga-> set lat -55 -5
ga-> set lon 110 170
ga-> d mslp/100
Notice plot draws onto of previous output
1
GrADS Tutorial April 2009
7. Clear display
8. Display mean sea level pressure again
d mslp
Mean sea level pressure will be drawn in Pa
This is because we have not defined (allocated to memory) the converted mslp
hPa field.
9. Define new mslp (hPa) field
ga-> mslp2 = mslp/100
This will memory allocate the new variable mslp2
Note: Variable names must not include special characters (@_#$% etc)
10. Clear and display new mslp2 variable
Task 2 Command-Line
1. Open mslp.nc
2. Define mslp in hPa
Define variable as mslp2
By quitting GrADS or using the reinit command, all previously defined variables
are cleared, hence mslp2 needs to be defined again
3. Average mslp (in hPa) covering January – December 1979 and display avemslp
ga-> avemslp = ave(mslp2,t=1,t=12)
ga-> d avemslp
4. Create a title for image
ga-> draw title Average MSLP Jan – Dec 1979
5. Create a hardcopy print using printim command
ga-> printim ave1979mslp.gif white
6. Create a hardcopy print using enable print command
ga-> enable print ave1979mslp2.gmf
ga-> print
ga-> disable print
7. Quit GrADS
8. On Unix command line convert outputted ave1979mslp2.gmf to ave1979mslp2.eps
> gxeps -acR -i ave1979mslp2.gmf -o ave1979mslp2.eps
> rm ave1979mslp2.gmf (optional, simply removes .gmf file)
9. Now display ave1979mslp.gif (image created using printim command)
> display ave1979mslp.gif
10. Now display ave1979mslp2.eps (image created using gxeps)
> display ave1979mslp2.eps
You might notice a difference in image quality between the two images.
An eps image is a Postscript image. This vector image can be zoomed to high
levels with no pixel distortion
2
GrADS Tutorial April 2009
1. Execute GrADS
ga-> sdfopen u10m.nc
ga-> sdfopen v10m.nc
2. Open both u10m.nc and v10m.nc
3. Query opened files
ga-> q files
This will print to screen each opened file
4. Set plot boundaries to be zoomed to the Australian region
Lat = -55 -5 N, Lon = 110 170 E
5. Display uwnd contours from 1 st file
ga-> d uwnd
6. Clear
7. Display vwnd contours from 2 nd file
ga-> d vwnd.2
8. Clear display and draw wind vectors and colour magnitudes
ga-> set gxout vector
ga-> d uwnd;vwnd.2;mag(uwnd,vwnd.2)
9. Clear and draw wind barbs
ga-> set gxout barb
ga-> d uwnd;vwnd.2
10. Clear and draw wind streamlines
ga-> set gxout stream
ga-> d uwnd;vwnd.2;mag(uwnd,vwnd.2)
3
GrADS Tutorial April 2009
In this task we are going to construct a colour map instruction script. This script will define
the colours and levels that GrADS will use to create your plots
4
GrADS Tutorial April 2009
Hint: If using the cbarn.gs colour bar the number of arguments in set clevs must be one less
than the number for set ccols. This will insure that the top triangle will have an assigned
colour and not default grey.
5
GrADS Tutorial April 2009
1. Open GrADS
2. Open gl2008011800.nc
3. Set latitude limits for averaging
ga-> set lat -40 -20 (set lat -90 90 would be globally)
4. Set fixed longitude
ga-> set lon 90 (for display purposes this needs to be fixed)
5. Set level from 1000 – 70 hPa
ga-> set lev 1000 70
6. Define azonal as the global average of zonal wind between -40 -20
ga-> azonal = ave(zonal_wnd,lon=0,lon=360) or
ga-> azonal = ave(zonal_wnd,lon=0,lon=360,-b)
7. Display new azonal variable. This will show a cross section view of the average
global zonal wind
8. clear and repeat 3 - 6 a couple of times, experimenting with latitude and longitude
boundaries and also the -b flagging option
9. Clear and now set plot boundaries are follows:
Level = 1000
Latitude = -55 -5 N
Longitude = 110 170 E
10. Now calculate and area average of mslp between about lat and lon boundaries
define aamslp = aave(mslp,lon=110,lon=170,lat=-55,lat=-5)
11. Display aamslp
Notice numerical output to GrADS terminal (“Result value = 1008.58”)
12. Repeat 9 - 11 a couple of times, experimenting with latitude and longitude boundaries
DSET gl%y4%m2%d2%h2.nc
DTYPE netcdf
OPTIONS template yrev
TITLE netCDF file
UNDEF -9.e36
XDEF ___ LINEAR ___ 1.5
YDEF ___ LINEAR ___ ___
ZDEF 31 LEVELS ___ 995 ___ 985 ___ ___ ___ ___
TDEF 2 LINEAR 00:00z17JAN2008 1dy
VARS ___
sfc_pres=>ps 1 t,y,x Surface pressure
sfc_temp=>pt 1 t,y,x Surface temperature
mslp 1 t,y,x a
geop_ht=>h 31 t,z,y,x a
air_temp=>t 31 t,z,y,x a
mix_rto=>qv 31 t,z,y,x a
zonal_wnd=>u 31 t,z,y,x a
merid_wnd=>v 31 t,z,y,x a
ENDVARS
6
GrADS Tutorial April 2009
You may recognise this event as the Sydney to Hobart 1998 Cyclone
'reinit'
'sdfopen syd_hobart.nc'
'set t 1'
say ' '
prompt 'Enter number of time steps (max 14): '
pull tstep
say ' '
say 'Time steps set to: 'tstep
'set dbuff on'
i=1
while (i <= tstep)
'set t 'i
say 'time set to: 'i
'set mpdset hires'
'set map 1 1 3'
'set ccolor 1'
'd msl/100'
'set gxout stream'
'd p10u;p10v;mag(p10u,p10v)'
'draw title MSLP & 10m Wind ['i' of 'tstep']'
'swap'
* Pause screen output (in sec)
7
GrADS Tutorial April 2009
'!sleep 1'
i=i+1
endwhile
say 'DONE: Loop completed!'
say 'Type: run anim_ex.gs to run again'
1. Run clim.gs
'reinit'
'sdfopen mslp.nc'
'set grads off'
'enable print mslp_map.gmf'
'set lon 0 360'
'set lat -55 60'
'set lev 1000'
'set t 1 12'
'define spclim = ave(mslp,t+0,t=348,12)'
'modify spclim seasonal'
'set t 1'
'set gxout shaded'
'd spclim(t=1)/100'
'run cbarn.gs'
'draw title Mean Jan MSLP'
'print'
'disable print'
2. Display mslp_map.gif
3. Open Firefox Web Browser
4. Go to www.cdc.noaa.gov/cgi-bin/Composites/printpage.pl
5. Select Sea Level Pressure
6. Select January for both starting and ending months
7. Enter range of years: 1979 – 2007
8. Select shading with contours
9. Change plot size to 150%
10. Select custom for map projection
11. Set latitude: -55 60 N
12. Set longitude: 0 360 E
13. Change projection to Cylindrical Equidistant
14. Create Plot
15. Compare Webpage output to GrADS output mslp_map.gif
16. You could then download this data by clicking “Get a copy of the netcdf data file used
for the plot” and plot this data again using your own colour maps and in eps format.
8
GrADS Tutorial April 2009