How do I plot one variable at a given time step and a level?

The NCL graphics package.

How do I plot one variable at a given time step and a level?

Postby wrf_usr » Mon Mar 11, 2019 7:21 am

Hello,
All the script samples I use for WRF output plot several fields in a loop. I would like to plot just one variable at any given time step and a given level.
With my script below, my T is T(T,L,L,L), i.e. T(Time,Level, Lat,Lon)=T(17,31,60,69).
When I run the code below I get a plot, but alos the error:
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) check_for_y_lat_coord: Warning: Data either does not contain
(0) a valid latitude coordinate array or doesn't contain one at all.
(0) A valid latitude coordinate array should have a 'units'
(0) attribute equal to one of the following values:
(0) 'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0) check_for_lon_coord: Warning: Data either does not contain
(0) a valid longitude coordinate array or doesn't contain one at all.
(0) A valid longitude coordinate array should have a 'units'
(0) attribute equal to one of the following values:
(0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'

I have seen a number of posts on ncl-talk on this error, but I do not understand the solutions given.
When I put the following code after addfile

Code: Select all
;  lat =  f->XLAT   ; get lat from the file
 lon =  f->XLONG  ; get lon from the file

 t!0 = "time" ; dimension 0 for t is time
 dimension 1 for t is level
  t!2 = "lat"  ; dimension 2 for t is lat
  t!3 = "lon"  ; dimension 3 for t is lon

  t2@units = "degrees_north"
  t2@units = "degrees_east"

I get the error:
fatal:Variable (t) has (2) dimensions can not write to dimension (2)
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 16 in file contplot1.ncl

My main code is below.
In addition I get titles which I do not know where they come from ("perturbation potential temperature ()" above the figure, and "contour from -6 to 24 by 2" below)

I hope someone can assist me.
Zilore Mumba
Code: Select all
 begin
  f= addfile("/home/zmumba/Rwanda_Radar_Proj/Training_Materials/Data/wrfout_d01_2017-04-18_00:00:00.nc", "r")

  t = f->T(0,0,:,:)

  wks = gsn_open_wks("png","firstcontplot")
  res              =  True
  res@tiMainString = "NCL plot in 5 steps"
  res@mpFillOn                     = False        ; turn off gray fill
  res@mpOutlineBoundarySets        = "National"   ; turn on country boundaries
;  res@mpGeophysicalLineColor      = "Navy"       ; color of cont. outlines
;  res@mpGeophysicalLineThicknessF = 1.5          ; thickness of outlines
;  res@mpNationalLineColor         = "Black"
  res@mpNationalLineThicknessF     = 2.5          ; turn on country boundaries

  res@mpDataBaseVersion            = "MediumRes"  ; choose higher resolution
  res@mpDataSetName                = "Earth..4"   ; choose most recent boundaries

  res@mpMaxLatF                    = -8           ; choose a subregion
  res@mpMinLatF                    = -18
  res@mpMaxLonF                    =  34
  res@mpMinLonF                    =  21

  plot = gsn_csm_contour_map(wks, t, res)

 end

wrf_usr
 
Posts: 6
Joined: Thu Feb 10, 2011 10:49 am

Return to NCL

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest