WRF-Python

NCL

RIP4

ARWpost

 

WRF-to-GrADS

 

WG6 Home Page

 

 

 

WRF Model GRAPHIC TOOLS : NCL Scripts

Purpose

Ready-made NCL scripts are provided to create meta files for both real and ideal datasets. These scripts are relatively easy to read and change to generate different or more plots.

These notes describe the September 2005 beta release. This release requires high-level NCL scripts to run. This release can process ARW static/input and output files, as well as WRF-Var output data. Both single and double precision data can be processed.

Current Version of WRF_NCL

Version 2.0 (Released September 2005)
     We encourage users to use the latest version of the code, but this is still
     a beta version and would like to hear about any problems.

This version makes use of the latest NCL - which had some functions re-written. The WRF functions in this packages has also been re-written. Which means old ncl scripts will NOT work with the new procedures and functions.

What is NCL

The NCAR Command Language (NCL) is a free interpreted language designed specifically for scientific data processing and visualization. NCL has robust file input and output. It can read in netCDF, HDF4, HDF4-EOS, GRIB, binary and ASCII data. The graphics are world class and highly customizable.

It runs on many different operating systems including Solaris, AIX, IRIX, Linux, MacOSX, Dec Alpha, and Cygwin/X running on Windows. The NCL binaries are freely available at: http://www.ncl.ucar.edu/Download/

Necessary Software to run Scripts

- Obtain the WRF_NCL TAR file from the WRF Download page
- NCL libraries (This WRF_NCL beta release requires at least NCL version 4.2.0.a032)

Hardware

The code has been tested on the following machines (The code should run equally well on other machines, but has not been tested on all platforms):

- DEC Alpha
- IBM

Steps to Run Scripts

- Untar WRF_NCL TAR file - you will have the following files:

DOThluresfile

cp DOThluresfile ~/.hluresfile

Controls the color / background / fonts and basic size of the plot.

README_FIRST
README_NCL

 

gsn_code.ncl
SkewTFunc.ncl
WRFOptions.ncl
WRFPlot.ncl
WRFUserARW.ncl

NCL functions and procedures

wrf_user_fortran_util_0.f
make_ncl_fortran
make_ncl_fortran.alpha
make_ncl_fortran.ibm
make_ncl_fortran.ibm64
make_ncl_fortran.linux
make_ncl_fortran.sun

Used to build the external FORTRAN function

wrf_bwave.ncl
wrf_grav2d.ncl
wrf_hill2d.ncl
wrf_qss.ncl
wrf_squall_2d_x.ncl
wrf_squall_2d_y.ncl
wrf_real_input.ncl
wrf_real.ncl
wrf_cloud.ncl

NCL scripts to create graphics for real/ideal datasets.

 

- FIRST

Copy the file DOThluresfile to ~/.hluresfile

This file controls the color / background / fonts and basic size of your plot. This file MUST have the name .hluresfile, and MUST be located in your home directory.

For more information regarding this file, see:
http://www.ncl.ucar.edu/Document/Graphics/hlures.shtml

- Build the external function to link you into NCL:

- NCL links in fortran shareable object files for computing some diagnostic quantities and for performing interpolations
- Presently, only one fortran object needs to be built:
   wrf_user_fortran_util_0
-
To build the fortran object, try running one of the make_ncl_fortran csh scripts that will build the shared-object library:

make_ncl_fortran wrf_user_fortran_util_0

- If successful, you will see these files created in your directory:

so_locations
wrf_user_fortran_util_0.o
wrf_user_fortran_util_0.so
wrf_user_fortran_util_0_W.c

- "wrf_user_fortran_util_0.so", is the file that will be used later

- HINT: The most common error when building the external function, is not finding the “wrapit77” function on your system. “wrapit77” is part of the NCAR Graphics routines. If you run into this problem, make sure your path to this function is setup correctly. (If all else fails, locate the file on your system and copy it to your WRF_NCL directory.) For more information about wrapit77, see:
http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclExtend.shtml

- Edit the script you want to run:

- Change the location and name of the file:
   a = addfile("../../WRFV2/run/wrfout_d01_2000-01-24_00:00:00.nc","r")
   Do not remove the ".nc" after the file name - the script needs it to
   determine which type of input file (netCDF) it is dealing with.
   (Note the .nc is NOT part of the actual file name.)

- Specify the type of plot you want to generate:
       type = ……
   Options are x11, pdf, ps, ncgm

- Specify the output file name:
       wks = gsn_open_wks(type,”MyOutput”)

- Give your output a title:
       res@MainTitle =“REAL-TIME ARW”

- Control plotting options with WRFOptions.ncl:

MainTitlePos

Options are top Left, Center, Right

InitTime

Add Initial Time to plot

ValidTime

Add Valid Time to Plot
Switch off for files which do not have a valid time

TimePos

Placement of Time Information. Options are top Left or Right. If MainTitlePos and TimePos are on same side, Time Information will be plotted under the Main Title

Footer

Add some model information as a Footer to the plots

mpOutlineBoundarySets

Default is GeophysicalandUSStates
Alternatively set to AllBoundaries

 

- Basic flow of an NCL script:

load "WRFOptions.ncl"      ; set basic plot options here
load "gsn_code.ncl"        ; high-level NCL scripts
load "WRFPlot.ncl"         ; WRF functions / procedures
load "WRFUserARW.ncl"      ; Diagnostics

begin
  ; Open file
   a = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r")
   type = "pdf"    ; Will create pdf output files
  ; open workstation and create output file name
   wks = gsn_open_wks(type,"wrfout")

   res@MainTitle    = "ARW Real Data" ; Set plot title

   times = wrf_user_list_times(a)   ; get times in file
   ntimes = dimsizes(times)          ; number of times

   do it = 0,ntimes-1        ; loop through all times

     res@TimeLabel = times(it)      ; Set Valid time info

     map = wrf_map(wks,a,res)       ; Create a map
     ter = wrf_user_getvar(a,"HGT",time)   ; get terrain
     t2  = wrf_user_getvar(a,"T2",time)    ; get T2

   ; Set options and create terrain plot
     opts_ter = res
     opts_ter@cnFillOn      = True
     contour_ter = wrf_contour(a,wks,ter,opts_ter)

   ; Set options and create t2 plot
     opts_t2 = res
     contour_t2 = wrf_contour(a,wks,t2,opts_t2) 

   ; Overplay terrain and t2 plots and place on map
     wrf_map_overlay(wks,map,(/contour_ter, contour_t2/),False)
   end do

end

 

- Run script:

ncl < wrf_real.ncl    (or “ncl   NCL_script” for higher versions of NCL)

- This will create an output file    MyOutput.(pdf/ps/ncgm)
   If type of output was set to “x11”, no hardcopy will be produced.

- The name of this file is controlled by the line:
      wks = gsn_open_wks(type,”MyOutput”)    inside the NCL script

- To view a meta file (type= ncgm), type:

      idt  MyOuput.ncgm

- Examples of idealized plots:

wrf_bwave.ncl
wrf_grav2d.ncl
wrf_hill2d.ncl
wrf_qss.ncl
wrf_squall_2d_x.ncl
wrf_squall_2d_y.ncl

- Examples of real plots:

wrf_real.ncl
wrf_cloud.ncl
wrf_real_input.ncl

- Miscellaneous:

For print quality images, create pdf or ps images directly via the ncl scripts (type = pdf / ps).

To convert NCGM files to GIF images, a very handy tool is the ncgm2gif script

               ncgm2gif -res 500x500 -nomerge test.cgm

Will convert all images in test.cgm to testxxx.gif



 
 
Home -- Model System -- User Support -- Doc / Pub -- Links -- Download -- WRF Real-time Forecast