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, and can read in particular netcdf files. It can be used to display the Meso-NH output data, and it is an alternate to Diaprog. For more information on NCL, go to http://www.ncl.ucar.edu/overview.shtml. You can also find many examples here: http://www.ncl.ucar.edu/Applications/.

You can also find interesting information on the web pages created for the students of the NCL workshops held in Toulouse at CERFACS in October 2012: http://www.ncl.ucar.edu/Training/Workshops/CERFACS/.

On this page, you will find help on generating NCL scripts for Meso-NH.

Do I have NCL ?

type: which ncl

If it returns no ncl, either you don't have ncl on your machine, or the path variable is not set correctly. Make also sure that the variable NCARG_ROOT is set correctly.

If you get this error message while running ncl, it is because you are missing the file .hluresfile . This file must be saved in your home directory.

High resolution coastline dataset

Get and run the following script in the directory where you want to put the dataset: get_ncl_highres_files

Shapefile to plot department lines over France

Get the file depts_shape.tar and the script plot_departements.ncl . Put both files in the same directory and untar the depts_shape.tar file (it contains 4 files). Edit the file plot_departements.ncl and modify the path of the variable dirname to match the directory where you untar the file depts_shape.tar .

In your ncl script, add this line before the begin command :

load "plot_departements.ncl"

Make sure that the ressources gsnFrame and gsnDraw are set to False. Add these 2 lines after the plot :

lines = new(495,graphic)
lines = draw_depts(wks,plot,lines)

Don't forget to finalize the plot with :

draw(plot)
frame(wks)

Here is an example for the KTEST 16janvier : mnh_BasicMap2_Depts.ncl

NCL example scripts for nc4 output files

Here are some examples of scripts to be used with netcdf4 files generated by the MNH-V5-2 version of Meso-NH for the KTEST 004_Reunion:

EN COURS DE MODIFICATION

Basic map example :

Orography of la Reunion

mnh_BasicMap.ncl

Model level plot :

Potential temperature at model level 1

Water vapor mixinx ratio at model level 1

Wind speed and wind vector at model level 1

Potential temperature at model level 21

Water vapor mixinx ratio at model level 21

Wind speed and wind vector at model level 21

Potential temperature at model level 41

Water vapor mixinx ratio at model level 41

Wind speed and wind vector at model level 41

mnh_ModelLevels.ncl

Cross-section plot :

Position of the cross section on orography

Position of the cross section on orography

Position of the cross section on orography

Vertical cross-section of UT (filled contour) and THT

Vertical cross-section of UT (filled contour) and THT

Vertical cross-section of UT (filled contour) and THT

mnh_CrossSection.ncl

How to set projection parameters in NCL for Meso-NH ?

If RPK = 0 : use Mercator projection

For the Mercator projection you should specified these resources as follows:

res@mpProjection           = "Mercator"
res@mpLimitMode            = "Corners"
res@mpLeftCornerLatF       = lat(0,0)
res@mpLeftCornerLonF       = lon(0,0)
res@mpRightCornerLatF      = lat(imax-1,jmax-1)
res@mpRightCornerLonF      = lon(imax-1,jmax-1)
And you should associate latitude and longitude to the variable you want to plot, for example for ZS:
ZS@lat2d = lat
ZS@lon2d = lon

If RPK = 1 or -1 : use Stereographic projection

For the Stereographic projection you should specified these resources as follows:

res@mpProjection           = "Stereographic"
res@mpCenterLonF           = LON0
res@mpCenterRotF           = BETA
res@mpCenterLatF           = 90 ; if rpk=1
or
res@mpCenterLatF           = -90 ; if rpk=-1
res@mpLimitMode            = "Corners"
res@mpLeftCornerLatF       = lat(0,0)
res@mpLeftCornerLonF       = lon(0,0)
res@mpRightCornerLatF      = lat(imax-1,jmax-1)
res@mpRightCornerLonF      = lon(imax-1,jmax-1)
And you should associate latitude and longitude to the variable you want to plot, for example for ZS:
ZS@lat2d = lat
ZS@lon2d = lon
(with lat and lon read from the netcdf file or calculated with MESONHtools)

If -1<RPK<0 or 0<RKP<1: use Lambert projection

For the Lambert projection you should specified these resources as follows:

res@mpProjection          = "LambertConformal"
res@mpLambertParallel1F   = pole*asin(RPK)*(180./3.14) ; with pole=1 for north hemisphere and -1 for south hemisphere
res@mpLambertParallel2F   = res@mpLambertParallel1F
res@mpLambertMeridianF    = LON0
res@mpLimitMode           = "Corners"
res@mpLeftCornerLatF      = lat(0,0)
res@mpLeftCornerLonF      = lon(0,0)
res@mpRightCornerLatF     = lat(imax-1,jmax-1)
res@mpRightCornerLonF     = lon(imax-1,jmax-1)
And you should associate latitude and longitude to the variable you want to plot, for example for ZS:
ZS@lat2d = lat
ZS@lon2d = lon
(with lat and lon read from the netcdf file or calculated with MESONHtools)

Projection and wind : Be Carefull !!

The U and V winds in MesoNH are not zonal and meridian winds. If you want to plot the wind vector in a projection which is different from the projection of your data, you need first to convert wind into their zonal and meridian components. To do so for level k :

d2r = 3.14159/180.
ang = K*((lon0-lon(:,:))*d2r)+B
UZON(k,:,:) = UM(k,:,:)*cos(ang)-VM(k,:,:)*sin(ang)
VMED(k,:,:) = UM(k,:,:)*sin(ang)+VM(k,:,:)*cos(ang)

where : K = XRPK conicity parameter of the projection

B = XBETA is the angle of rotation

lon0 = XLON0 longitude of reference for the projection

lon = longitude

NCL functions to extract variables from lfi files

A useful set of functions (get_from_lfi.ncl) has been developped by Phillip Scheffknecht to extract variables (3D, 2D vertical and horizontal cross sections) from diachronic .lfi files generated by Meso/NH. The functions are :

get_from_lfi : to extract variable on model coordinates (3D or only 2D cross sections, part or entire grid)

get_from_lfi_2d : to extract 2D-variables (terrain, rain, lat, lon, etc...)

get_from_lfi_interp : to extract horizontal cross sections on pressure or z-coordinates

get_from_lfi_vx : to extract vertical cross sections on pseudo model coordinates between two given grid points (bilinear horizontal interpolation, horizontal resolution same as model resolution or slightly higher)

To use these functions, download the script get_from_lfi.ncl and follow the insctructions in the documentation: documentation_1.1.pdf.

You can also find examples of usage in these 2 scripts: example_3d.ncl and example_vx.ncl

Mesonh-53: UseNCL (last edited 2016-02-11 05:47:15 by SolineBielli)