Don't hesitate to comment below if you have any questions or additional phrases
NCAR Command Language -
NCL Juli Rew
CISL SOARS, June 4, 2008
,Overview of NCL Strategies for
Survival Work with
Example Programs What We Will
Study
,NCAR Command Language is a complete programming language for processing data and producing high-quality
2D graphics NCL commands can be run at the command line, or they can be placed in batch scripts
What is NCL?
,NCL is built on top of
NCAR Graphics, which was originally written in Fortran NCAR Graphics was re-written in object-oriented form, and NCL works with graphical “objects”
Thanks to Mary Haley of the CISL
Visualization and
Technology Section for much of the training information given here NCL
History
,Freely available
Easier to use than conventional programming Competes well with expensive products such as
IDL Versatile - it can accept and output data in a variety of formats Produces publication-quality graphics Why Use NCL?
,NCL has so many features that it can take a lot of time to master NCL has around 800 functions Before writing any new NCL code, look at the downloadable examples to see if one fits GSUN tutorialhttp://www.ncl.ucar.edu/
Document/Manuals/Getting_Started/ GSUN line-by-line exampleswww.ncl.ucar.edu/Document/Manuals/Getting_Started/examples
.shtml Strategies for Survival
,Use the gsn and csm libraries Documentation is available online at:
http://www.ncl.ucar.edu/
Help from fellow users by joiningncl-talk@ucar.edu Subscribe athttp://mailman.ucar.edu/mailman/listinfo/ncl-talk
Support: Mary Haley (haley@ucar.edu, ML 35) Strategies for Survival, cont.
,begin/end - to start/end scripts (optional) ; -
Comment @ -
Attribute, e.g.,temperature@units = “Degrees C” Operators like Fortran - + - *, .le
., .lt., etc. All parameters are passed by reference (as in Fortran) NCL
Syntax
,Indexes start at 0 (similar to C) 1D, integer: a = (/
1,2,3/) 2D, float: b = (/ (/
1.1,
.01/), /(.001,.0001/) /) Whole-array syntax is like Fortrana=ba*b (more efficient than looping to copy array) Arrays
,
Dimensions can be named:temperature!0 = “frtime”temperature!1 = “lat”temperature!2 = “lon”
Strings - enclosed in double quotes Syntax, cont.
,
Coordinate variables- 1D arrays with same name and size as the dimensions they are assigned to-
Represent data coordinates for each index of a named dimension- Must be monotonically increasing/decreasingtemperature&frtime = forecast timestemperature&lat = lat_pointstemperature&lon = lon_points Coordinate subscriptstemperature (
0,{20:60},{-95:-120}) Syntax, cont.
,We will emphasize graphics features here Some examples of input and output to/from
ASCII text and netCDF data files Graphics
,
Load necessary libraries
Open “workstation” to send graphics to
Change the color map (optional) Set plot resources (optional)
Draw the graphics
Minimum Steps Needed to
Create a
Plot
,load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl”
First library contains “generic” interfaces and supplemental routines
Second library contains gsn_csm interfaces that use
CSM conventions. Load order is important. CSM conventions are accepted ways to label data, e.g., units 1. Load the
Necessary Libraries
,automatic subtitles contour line labels tickmarks out & lat/lon labels informational label automatic labelbar “basic”
interface “metadata aware” interface
,Can be PostScript (PS or
EPS),
PDF,
X11 window, or NCAR
CGM (NCGM) Has a default color map associated with it, but you will probably want to change this (more later) Can have up to 15 multiple workstations open 2.
Open graphics “workstation” wks = gsn_open_wks(“x11”,”test”) ; x11 window wks = gsn_open_wks(“ps”,”test”) ; “test.ps” wks = gsn_open_wks(“eps”,”wrf”) ; “wrf
.eps” wks = gsn_open_wks(“pdf”,”slp”) ; “slp
.pdf”
,Do this before drawing anything to the frame. If you use the same color map a lot, can put i
- published: 31 May 2016
- views: 27