As mentioned in the previous blog post, I used the freely available GFS raw data from NCAR, stored in GRIB2 format, for plotting. NCAR also provides a own plotting language called NCL, which stands for NCAR Command Language. It’s a very useful tool to create both simple and very complex plots of meteorological data. It supports different data formats as e.g. GRIB2 and NetCDF to just mention the most common.
An alternative plotting tool that is commonly used to plot meteorogical data fields is GraDS.
In this post I want to share a simple plotting sample script for plotting a GFS T2m temperature field.
A wide variety of examples can be found at the official NCL page. But unfortunately there are no examples for GFS. So I hope this example can give you a good starting point.
Example for plotting 2m temperature from GFS GRIB2-data
The following example should work under linux distributions and Mac OS X.
- Make sure to have NCL installed and running
- Download the forecast data from NCEP-servers: e.g. from ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/
- Create script file plot_t2m.ncl
;***************************************************** load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ;*************************************** begin ;;;; ;;; read data from grib file ;;;; outfile="/gfs/t2m_06z_120" grib_file="/data/2012-02-02/gfs.t06z.pgrb2f120.grib2" fin = addfile(grib_file,"r") ;;; get variables: temperature, longitude, latitude t2m = fin->TMP_P0_L103_GLL0(:,:) lon = fin->lon_0 lat = fin->lat_0 ;;;; ;;; prepare ;;;; t2m = t2m-273.15 ; degrees ;;;; ;;; create plot (pdf) ;;;; wks = gsn_open_wks("pdf",outfile) ; open wk station gsn_define_colormap(wks,"BkBlAqGrYeOrReViWh200") ; load color table ;;; Font Style res1 = True ; plots modification on res1@txFont = "Helvetica" res1@txFontQuality = "High" ;;; Title res1@tiMainString = "www.meteo-blog.net" ; add title res1@gsnLeftString = "T2m, SLP" res1@gsnRightString = "" ;;; Map res1@mpDataBaseVersion = "Ncarg4_1" ; choose more recent database res1@mpDataSetName = "Earth..4" ; high resolution res1@mpOutlineBoundarySets = "National" ; National borders res1@mpNationalLineColor = "Black" ; National borders color ;;; T2m res1@cnFillOn = True ; turn on color fill res1@cnLinesOn = False ; turn of contour lines ;;; color fill tresholds and colors res1@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels res1@cnLevels = (/ -26.,-24.,-22.,-20.,-18.,-16.,-14.,/ -12.,-10.,-8.,-6.,-4.,-2.,0.,/ 2.,4.,6.,8.,10.,12.,14.,16.,18.,/ 20.,22.,24.,26.,28.,30.,32.,34.,/ 36.,38.,40./) ; set levels res1@cnFillColors = (/ 10,12,14,15,17,19,22,25,31,35,39,43,48,53,/ 61,64,67,71,89,95,99,104,108,111,115,123,/ 130,135,143,148,150,155,159,163,165) ; set the colors to be used ;;; label bars style ;;; if not set standard values are used. ;;; so you normally can delete these lines without any problems res1@cnInfoLabelOn = False ; turn off contour info label res1@lbAutoManage = False ; control label bar res1@pmLabelBarDisplayMode = "Always" ; turns on label bar res1@lbOrientation = "Vertical" res1@pmLabelBarSide = "Right" res1@lbLabelAutoStride = True res1@pmLabelBarWidthF = 0.1 res1@pmLabelBarHeightF = 0.5 res1@lbLabelFontHeightF = .010 res1@lbPerimOn = False res1@lbLabelFont = "Helvetica" ; label font res1@lbTitleOn = True ; turn on title res1@lbTitleString = "[~S~o~N~C]" ; title string res1@lbTitlePosition = "Top" ; title position res1@lbTitleFontHeightF= .010 ; make title smaller res1@lbTitleDirection = "Across" ; title direction ;;; Map Projection (min and max Lon and Lat) res1@gsnAddCyclic = True ; data already has cyclic point ; this must also be set for any zoom res1@mpProjection = "LambertConformal" res1@mpMinLatF = 30 res1@mpMaxLatF = 65 res1@mpMinLonF = -20 res1@mpMaxLonF = 30 res1@mpLimitMode="LatLon" plot = gsn_csm_contour_map(wks,t2m,res1) ; create plot END
- Change the path of the input (“grib_file”) and output file (“outfile”)
- run script file with the following command from terminal ncl plot_t2m.ncl
You should get a pdf-file that looks similar to the following:
Last modified: February 2, 2012