Lambert Conformal Format


How to read in: GrADS | NCL | IDL | Ferret | MATLAB


The NARR model data is output onto a 349x277 Lambert Conformal Conic grid. This has a resolution that is approximately 32km. The coverage area is shown in the two maps below (both maps show the same data plotted).

In the netCDF file, the variables "lon" and "lat" contain those values for each of the coordinate pairs. Reading the data is simply a matter of reading the 349x277 array. Plotting may be harder as the grid is irregular. Below there are examples of how to plot the data in three commonly used packages. GrADS and NCL are free. You must buy a license for IDL.

narrplot and



To plot in GrADS, you will need to interpolate. GrADS can interpolate data using a ddf like the one below. It is also possible to use GrADS to plot in the native grid directly. See the "Use PDEF For Displaying Pre-Projected Data With GrADS". You can also use a script from the GrADS standard library

DTYPE netcdf
TITLE NARR 4D field Lambert Conformal Conic projection
UNDEF -9999.0 missing_value
UNPACK scale_factor add_offset
PDEF 349 277 lcc 1 -145.5 1 1 50 50 -107 32463.41 32463.41
XDEF 205 linear 150 1
YDEF 85 linear 2 1
ZDEF 29 levels 1000, 975, 950, 925, 900, 875, 850, 825, 800, 775, 750, 725, 700,
 650, 600, 550, 500, 450, 400, 350, 300, 275, 250, 225, 200, 175, 150, 125, 100
tdef 1 linear 00z1jan2004 3hr
vars 3
air 29 t,z,y,x  air_temp
lat=>glat 0 y,x Latitude
lon=>glon 0 y,x Longitude
The XDEF and YDEF determine the interpolation. To change, from the 1x1 degree output, to a 1/3x1/3 degrees
XDEF 615 linear 150 .333
YDEF 255 linear 2 .333
Note that the 1st number is the number of x,y points (here it is 3 times the 1 degree values). The 150 and 2 are the starting longitudes and latitudes respectively and the last number is the resolution.


The NCAR command language NCL will plot the data. See particularly here to transform and here to see Lambert Conformal Conic described..

Sample Code:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin
wks = gsn_open_wks("x11","narr_topo")
inf = addfile("/Datasets.private/narr/time_invariant/","r")
scale_factor = inf->hgt@scale_factor
add_offset = inf->hgt@add_offset
topo = scale_factor * (inf->hgt) + add_offset
lons = inf->lon
lats = inf->lat
dims = dimsizes(lons)
gsn_define_colormap (wks,"WhViBlGrYeOrReWh")
res = True
res@cnFillOn = True ; turn on color
res@cnLinesOn = False ; no contour lines
res@gsnSpreadColors = True ; use full color map
res@lbLabelAutoStride = True ; every other label
res@cnLevelSelectionMode = "ManualLevels" ; manual levels
res@cnMinLevelValF = 100.
res@cnMaxLevelValF = 3500.
res@cnLevelSpacingF = 100.
res@cnRasterModeOn = True
res@tiMainString = "NARR Topography"
res@gsnAddCyclic = False ; regional data
res@mpProjection = "LambertConformal" ; projection
res@mpLambertParallel1F = 50.0 ; two parallels
res@mpLambertParallel2F = 50.0
res@mpLambertMeridianF = -107.0 ; central meridian
res@mpLimitMode = "Corners" ; method to zoom
res@mpLeftCornerLatF = lats(0,0)
res@mpLeftCornerLonF = lons(0,0)
res@mpRightCornerLatF = lats(dims(0)-1,dims(1)-1)
res@mpRightCornerLonF = lons(dims(0)-1,dims(1)-1)
res@tfDoNDCOverlay = True ; do not transform data
res@pmTickMarkDisplayMode = "Always" ; get a box around the plot
res@tmXTOn = False ; turn off all ticks
res@tmXBOn = False
res@tmYROn = False
res@tmYLOn = False
plot = gsn_csm_contour_map (wks,topo(0,:,:),res)

Other examples may be found on this web page.


IDL will plot the data. Here is some skeleton-code that will help you set up your own code.

C set var to your variable, obtain scale and offset
C get time index for starting and stopping: itimestart, itimeend
C For 4-D variables (variables with levels) you will also need
C to get the netCDF variable level and you will need
C to have count and start be 4D with level being the 3rd array item.

vararray = fltarr(nlons,nlats)
vararryinin = intarr(nlons,nlats)
rlons  = fltarr(nlons,nlats)
rlats  = fltarr(nlons,nlats)

infile = ''
nunit = ncdf_open(infile,/nowrite)
ivarid   = ncdf_varid(nunit,var)
ilatid   = ncdf_varid(nunit,'lat')
ilonid   = ncdf_varid(nunit,'lon')


for itime = itimestart,itimeend, 1 do begin
  offset   = [0,0,itime]
  count    = [nlons,nlats,1]

    count = count
  vararray = vararray + (varscale*FLOAT(vararrayin) + varoffset)

  count = [nlons,nlats]
  count = [nlons,nlats]

ncdf_close, nunit

; ------------------------------------------------------------------
; plot the data
; ------------------------------------------------------------------

  title='yourtitle', /continents,/usa


To plot in Ferret, use code similar to this. Note that the openDAP filename is used here.

yes? ! point to the OPeNDAP file name
yes? SET DATA "/cgi-bin/nph-nc/Datasets/NARR/monolevel/"

yes? ! Draw the color plot using the curvilinear coordinates in the file
yes? SHADE/MODULO/HLIMITS=145:360/VLIMITS=0:90/LEVELS=50 air[L=1],lon,lat

yes? ! Run the land.jnl script included with Ferret to draw land outlines
yes? GO land.jnl


In order to read NARR data into MATLAB we suggest that you use the mexnc and SNCTOOLS package at Because the packed NARR data is roughly 500 MB per file, loading and unpacking the data can cause MATLAB to run out of memory. You can load only part of the file at a time by using:

For example,
p = nc_varget('','prate',[0 0 0],[10 -1 -1])

If the OpenDAP option is enabled for SNCTOOLS then a URL can be used in place of the filename. Alternatively, you can solve the memory problem by using NCO ( ) to extract a subset of the data before loading it into MATLAB. Here is a sample plot generated by interpolating the NARR data to a regular lat-lon grid:

p = nc_varget('','prate',[0 0 0],[10 -1 -1]);       %get all the gridpoints for the first ten timesteps in the file    pmean = double(squeeze(mean(p,1)));                              % Take the mean of these data over time    
nlat=nc_varget('/Datasets/NARR/monolevel/','lat');  % get the latitude and longitude coordinates
nlon2 = nlon;nlon2(nlon<0) = nlon2(nlon<0)+360;                  % Make all longitudes have positive values   
x = 180:0.25:360;y=[10:0.25:80]';                                % Create a 1/4 degree lat-lon grid   
pint = griddata(double(nlon2),double(nlat),pmean,x,y,'linear');  % interpolate to this grid   
pcolor(x,y,pint);shading interp;colormap(1-jet.^2)               % make a pseudocolor plot    
load coast; 
hold on; 
hold off                 % load MATLAB's coastal outlines and overlay the

If you have the mapping toolbox there is a much simpler and faster solution (sample output):

p = nc_varget('','prate',[0 0 0],[10 -1 -1])     
pmean = double(squeeze(mean(p,1)));    
axesm('eqdcylin','maplatlimit',[0 80],'maplonlimit',[150 0]);     % Create a cylindrical equidistant map   
pcolorm(nlat,nlon,pmean)                                          % pseudocolor plot "stretched" to the grid    
load coast


The CMAPF routines are libraries of tools - functions and subroutines that allow meteorological model programs to be independent of the choice of map projection on which their model is based. See the ARL page You can use these routines to get the i,j coordinate corresponding to a lat/lon input. See this UNSUPPORTED FORTRAN code.