Dynamics of the Atmosphere GEMPAK Lab 3 Goals of this lab: 1) Learn about Linux scripts. 2) Learn how to combine levels in GEMPAK functions. 3) In-class exercise about geostrophic balance in the real atmosphere. Please log into synoptic and open Xming, changing the tunneling settings if necessary. Making Linux scripts You may have noticed that it is a bit tedious to make a GEMPAK plot with multiple layers (e.g., relative vorticity and geopotential height). You have to set all the parameters and save them separately for each layer of the plot. If you make any mistake in the sequence of commands to make the desired plot, you may have to start everything from scratch. Furthermore, if you want to change something minor after you finish the plot, it's tedious to go back and make the changes. Writing a Linux script allows you to make GEMPAK plots more easily, and in particular, makes editing and changing the plot effortless. A Linux script is simply a text file that lists Linux and GEMPAK commands. The commands are executed in order when the script is run. You can therefore list the commands that are necessary to make a particular GEMPAK plot in a script, and then run the script to make the plot. If you want to change something about the plot, you can simply edit the script, save it, and rerun it. Making plots with Linux scripts is much more convenient than typing all of the commands manually into the command window, and you can even put the "cleanup" command at the end of a script so that any GEMPAK processes are automatically ended when it s finished. Linux scripts will always have the file extension ".sh" and can be viewed, created, and edited in the program gedit. I've made several example scripts that we'll look at now. Please copy these scripts from my directory into yours. This can be done with one simple Linux command: [deangelis@sun2 ~]$ cp /users/deangelis/*.sh. The files will be copied to whatever directory you run the above command from. Only the files in my directory that have read permission by everyone will be copied, so just ignore any permission errors you get. You should have all of the following files in your directory now: 500hghtvor.sh, 800tmpfwnd.sh, 800tmpfwndbad.sh, 800tmpfadv.sh, sfc6hrprec.sh, geo300vec.sh, geo300rat.sh, geo1000vec.sh 1
Let's take a look at the anatomy of a Linux script, by looking at the 500hghtvor.sh script: [deangelis@sun2 ~]$ gedit 500hghtvor.sh & Now let s run the script. This is very important: To run a script, the permissions on the script file must be set so that you (the user) can read, write, and (most importantly) execute it. The following command in the Linux prompt will do this: [deangelis@sun2 ~]$ chmod 700 filename.sh So, for example, to make the 500 mb script executable, type the following: [deangelis@sun2 ~]$ chmod 700 500hghtvor.sh Or, you can make all of your scripts executable at once with the following command: [deangelis@sun2 ~]$ chmod 700 *.sh Note, the script files that you copied from my directory already had the permissions set so that the user could read, write, and execute them, so it was unnecessary to change the permissions with the commands above. BUT, for new script files that you create in gedit, the permissions will not be set for execute by default, so you MUST change the permissions using the chmod command above. To run a script, use the following command in the Linux prompt: [deangelis@sun2 ~]$./filename.sh So, to run the script which makes the 500 mb map, type the following: [deangelis@sun2 ~]$./500hghtvor.sh After typing the above, all of the commands which are listed in the script file (500hghtvor.sh), with the exception of the comments (all lines starting with #), will be entered into the Linux and GEMPAK prompts, as if you were typing them in one by one. On your SSH client window will print all of the messages that would show up from Linux or GEMPAK associated with those commands. So, you can scroll up and see if any error messages appear. This particular script also opens up the created.gif file in ImageMagick at the end, as well as runs cleanup. Let's take a look at the example scripts for other plots we have made this semester and run them. 2
Combining atmospheric levels in GEMPAK functions The @ symbol in GFUNC or GVECT Putting the @ symbol and an atmospheric level after a variable in the GFUNC or GVECT parameters (e.g., tmpf@800) sets the atmospheric level for just that variable. The atmospheric level that is set after the @ symbol will overwrite the level that is set in GLEVEL for just that variable. The @ symbol is most often used to combine variables from different atmospheric levels in one function. For example, let's say I wanted to plot the difference in temperature between 1000 mb and 500 mb (as a crude measure of instability). I would set the parameter GFUNC to the following: gfunc=sub(tmpf@1000,tmpf@500) If the above were the only thing being plotted (i.e., no vector in gdplot), it wouldn't matter which level GLEVEL is set to, and in fact, you could even leave it blank. GLEVEL is only used for variables in which a level is NOT specified with the "@". Of course, GVCORD must be set to "pres" if the level you specify with "@" is a pressure level. 3
In-class exercise: geostrophic balance We learned about geostrophic balance in class. It applies to horizontal motion and states that the pressure gradient force is exactly balanced by the Coriolis force, resulting in no net acceleration on a parcel of air. In order for this balance to be satisfied, the wind must have a constant magnitude and blow parallel to contours of equal pressure (or equal geopotential height in pressure coordinates) with low pressure (or geopotential height) to the left in the northern hemisphere. This wind is known as the geostrophic wind and its magnitude is proportional to the magnitude of the pressure gradient (or geopotential height gradient in pressure coordinates). How close are the real winds to being in geostrophic balance? Where in the atmosphere are the winds most geostrophic? We ll answer these questions by making a few GEMPAK maps. To assess the geostrophic balance, we ll make maps on constant pressure surfaces with four vectors: the horizontal pressure gradient force (with pressure as the vertical coordinate), the scaled horizontal Coriolis force, the actual wind, and the geostrophic wind (which obeys geostrophic balance by definition). In GEMPAK, the variables WND and GEO are the actual wind and geostrophic wind, respectively, and are thus easy to plot. However, plotting the pressure gradient and Coriolis force vectors is not so obvious. Let s work on this now. (Derive GEMPAK expressions for the horizontal pressure gradient and Coriolis force vectors (per unit mass) on the board.) The script geo300vec.sh that I ve prepared contains all of the commands necessary to plot the four vectors at 300 mb. Please open the script in gedit. Let s talk about the commands in this script. Notice that I can use gdwind to make this map, since I am only interested in plotting vectors. Like gdcntr, gdwind gives information about the minimum and maximum magnitudes of the vectors when running the program, potentially making it easier to set the scaling/sizes of vectors (although in this case it was still difficult). Also, pay particular attention to the SCALE, WIND, and TITLE parameters in this script. Note that I use both the SCALE parameter and the size component of the WIND parameter to control the vector sizes. I plot the real and geostrophic winds with the exact same scale and size for easy comparison, and likewise for the pressure gradient and Coriolis force vectors. Finally, note that the TITLE will be displayed on two different lines when set this way. Let s run the script: [deangelis@sun2 ~]$./geo300vec.sh Does the atmosphere appear to be in geostrophic balance at 300 mb? Take note of both the difference between the actual and geostrophic wind vectors, as well as the orientation of the pressure gradient and Coriolis force vectors. What do you notice about the difference in magnitudes of the geostrophic and real wind at difference places on the map, and how does this relate to the flow? Open and run the supplemental script geo300rat.sh: 4
[deangelis@sun2 ~]$./geo300rat.sh Take note of the functions I use in the script, as well as how I contour the values. Do the ratios of the real to geostrophic wind make sense in this plot? Why do you think there are blobs of ratios that are so different from one in areas where there is hardly any geopotential height gradient? Do you think the real wind will follow geostrophic balance better or worse at 1000 mb? Let s find out. Open and run my script geo1000vec.sh: [deangelis@sun2 ~]$./geo1000vec.sh Note that to make the 1000 mb plot, I kept the SCALE parameter for all vectors the same, but manipulated the size of the vectors with the WIND parameter. Changing the size of vectors with the WIND parameter allows you to scale them by any factor, while changing the SCALE parameter only allows you to scale them by a power of 10. Thus, the WIND parameter allows for more control over the vector sizes. What is different about the flow at 1000 mb? More importantly, is the geostrophic balance a better or worse approximation for the real wind at 1000 mb? Why might this be the case? 5
GEMPAK Assignment # 3 - Due Wed. May 4 (end of day) Please prepare this assignment in a Word document and email it to: deangelis@envsci.rutgers.edu Directions: Copy and paste all scripts that you write as well as any.gif files that you generate for this assignment into your final document. Use the numerous example scripts given in this lab to help you write the scripts for the following questions. Failure to have "cleanup" at the end of your scripts will result in a loss of points. See the bonus question on the next page! 1) April Fools Nor easter of 2011 (20 pts.) a. For the 6 hour forecast from the NAM211 run that was initialized April 1, 2011 at 12Z (file is in /users/deangelis/data directory), make a plot of the 6 hour precipitation accumulation forecast (much like the precipitation plot from lab 1). For GAREA, use 28;-110;48;-48 instead of the values we ve been using. Write a script to make this plot and create a.gif image of the plot. b. For the same gdfile, gdattim, and garea as part (a), make another map showing the average of the divergence of the wind at the 1000 mb and 850 mb pressure levels. Plot this with color fills. Use a SCALE value of 5 and FINT of "-7;-5;-4;-3;-2;2;3;4;5;7", but choose appropriate colors. For everything else, follow the tips for making "nice" plots from lab 2. Write a script to make this plot and create a.gif image of the plot. Hint: Look up the functions AVG and DIV and use @ when setting gfunc (http://www.unidata.ucar.edu/cgi-bin/gempak/manual/apxb_index ) c. Compare both of your plots and comment on what you observe to the east of Maine. Explain what you observe in the context of the kinematic method. If you were to plot omega ( ) at 700 mb, would you expect it to be positive, negative, or near zero to the east of Maine? 2) Multi-level Winds (20 pts.) a. For the initialization of the NAM211 on April 1, 2011 at 12Z, plot vectors for the wind at 850 mb, wind at 500 mb, and the 500 mb minus 850 mb wind shear (hint, look up the function VSUB). Plot the three vectors as arrows, with a distinctly different color for each vector. Specify the colors for each vector in the title, and make the title two lines if necessary. Set the SKIP parameter to /4, SCALE to 0 and the size component of WIND to.45 for all vectors. For GAREA, use 30;-95;45;-48. For everything else, follow the tips for making nice plots from lab 2. Write a script to make this plot and create a.gif image of the plot. Hint: You can use gdwind for this plot and the script will have a similar structure to geo300vec.sh b. What type of temperature advection would you expect there to be in the 500-850 mb layer over the Atlantic immediately to the east of the Carolinas? What about over the Atlantic immediately south and southeast of Nova Scotia? Explain your answer. Is the magnitude of the horizontal temperature gradient in the 500-850 mb layer likely to be larger along the Atlantic coast, or over the Indiana/Ohio area? Explain your answer. What underlying assumption must be made about the flow at 500 and 850 mb in order for you to answer the above questions? 6
3) Bonus Question! (maximum 5 extra pts.) We can plot the Coriolis force vector (per unit mass) in GEMPAK by setting GVECT to: smul(-1,smul(corl,kcrs(wnd))) Create a different GVECT expression that would give the exact same result, but does not use the GEMPAK function kcrs. 7