Re: Stage IV precip data: conversion error

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 14 2010 - 17:43:18 MDT

Hi James,
When I tried to run this script, I did get errors as follows:

(0) check_for_y_lat_coord: Warning: Data either does not contain a
valid latitude coordinate array or doesn't contain one at all.
(0) A valid latitude coordinate array should have a 'units' 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 a valid
longitude coordinate array or doesn't contain one at all.
(0) A valid longitude coordinate array should have a 'units' 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'

This indicates you do not have valid coordinates set.

You have commented out the statements
  ;suma&lat2d = lat2d
  ;suma&lon2d = lon2d

Since your coordinates are 2d you cannot set these arrays as the
coordinate variables of your data variable, which is what the '&'
syntax is trying to do.
Actually "lat2d" and "lon2d" are special *attributes* recognized by
the gsn routines. I was able to get a plot by changing those 2 lines
to these:

suma&lat2d = lat2d
suma&lon2d = lon2d

  -dave

On Jun 14, 2010, at 5:17 PM, Correia, James wrote:

> Hi Everybody-
> I am using NCEP Stage 4 data. I used ncl's .Grb to .nc converter.
>
> I can view the data just fine using ncview, and it appears that I
> can print
> the array values correctly in NCL, BUT I cannot plot the data. There
> is no
> error message so I am struggling to understand what is wrong in
> order to fix
> it.
>
> Perhaps an NCL developer can take a look at the data and assist? I
> uploaded
> the file via ftp: ST2ml2002092008.Grb
>
> Any help is greatly appreciated.
>
> Below is the code.
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> begin
> ;************************************************
> ; open file and read in data
> ;************************************************
>
> mon = (/"04","05","06","07","08","09"/)
> hr =
> (/"00
> ","01
> ","02","03","04","05","06","07","08","09","10","11","12","13","14"
> ,"15","16","17","18","19","20","21","22","23"/)
> day =
> (/"01
> ","02
> ","03","04","05","06","07","08","09","10","11","12","13","14","15"
> ,"16
> ","17
> ","18","19","20","21","22","23","24","25","26","27","28","29","30",
> "31"/)
>
> suma = new((/881,1121/),"float")
> suma = 0.
> suma@_FillValue = 1e20
> sumh = new((/24,881,1121/),"float")
> sumh = 0.
> sumh@_FillValue = 1e20
>
> wks = gsn_open_wks("ps" ,"test") ; ps,pdf,x11,ncgm,eps
>
> y1 = 2002
> m1 = 5
> if(m1 .eq. 5)then
> nt = 30*24
> end if
>
> do yr=y1,y1
> do month=m1,m1
> if(month .eq. 0)then
> nd = 29
> end if
> if(month .eq. 1)then
> nd = 30
> end if
> if(month .eq. 2)then
> nd = 29
> end if
> if(month .eq. 3)then
> nd = 30
> end if
> if(month .eq. 4)then
> nd = 30
> end if
> if(month .eq. 5)then
> nd = 29
> end if
> nt = -1
> do d=19,19
> do h=8,8
> nt = nt + 1
>
> files = "ST2ml"+yr+mon(month)+day(d)+hr(h)+".nc"
> g = addfile(files, "r")
> print(files+" ")
> if(nt .eq. 0)then
> xlat = g->gridlat_240
> xlon = g->gridlon_240
> end if
>
> ;need to do qc?
>
>
> var = g->A_PCP_240_SFC_acc1h
> ;print(var)
> ;print(files+" "+max(var)+" "+min(var))
> ;printVarSummary(var)
> suma = suma + var(:,:)
> ;print(suma)
>
> sumh(h,:,:) = sumh(h,:,:) + var(:,:)
>
> end do
> end do
> end do
> end do
>
> print("max: "+max(suma))
> print("min: "+min(suma))
>
> do h=0,23
> print(h+" "+"max: "+max(sumh(h,:,:)))
> print(h+" "+"min: "+min(sumh(h,:,:)))
> end do
>
>
> ;************************************************
> ; create plots
> ;************************************************
> gsn_define_colormap(wks ,"BlAqGrYeOrReVi200"); choose colormap
>
> res = True ; plot mods desired
> res@gsnMaximize = True ; uncomment to
> maximize size
> res@gsnSpreadColors = True ; use full range of
> colormap
> res@cnFillOn = True ; color plot desired
> res@cnLinesOn = False ; turn off contour lines
> res@cnLineLabelsOn = False ; turn off contour
> labels
> res@lbLabelAutoStride = True ; let NCL figure lb
> stride
> res@cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn
> levels
> res@mpOutlineBoundarySets = "GeophysicalAndUSStates"
> res@cnLevels = (/0,.254,1,8,16,32,48,64,80,96,128/)
>
> ; WRF_map_c(gg,res,0) ; set map resources
> ;************************************************
> ; set True for native mapping (faster plotting)
> ; set to False othewise
> ;************************************************
> res@tfDoNDCOverlay = False
>
> ;************************************************
> ; associate the 2-dimensional coordinates to variables for plotting
> ; only if res@tfDoNDCOverlay=False
> ;************************************************
> if (.not.res@tfDoNDCOverlay) then
> lat2d = xlat
> lon2d = xlon
> end if
> lat2d@units = "degrees_north"
> lon2d@units = "degrees_east"
>
> ; lata = gg->XLAT(0,:,:)
> ; lona = gg->XLONG(0,:,:)
> ;x2 = 143
> ;y2 = 118
> ;x1 = 10
> ;y1 = 10
> ;print("wrf")
> ; res@mpRightCornerLonF = lona(y2,x2)
> ; res@mpRightCornerLatF = lata(y2,x2)
> ; res@mpLeftCornerLonF = lona(y1,x1)
> ; res@mpLeftCornerLatF = lata(y1,x1)
>
> ;lets try the stereographic suggestion from the archives
> res@mpProjection = "Stereographic"
> res@mpLimitMode = "Corners"
> res@mpCenterLonF = 255.
> res@mpCenterLatF = 90.
> res@cnInfoLabelOn = False
> res@mpLeftCornerLatF = lat2d(0,0)
> res@mpLeftCornerLonF = lon2d(0,0)
> res@mpRightCornerLatF = lat2d(880,1120)
> res@mpRightCornerLonF = lon2d(880,1120)
> res@gsnAddCyclic = False
> ;res@mpGridSpacingF = 300.
> ;res@mpGridLatSpacingF = 3.0
> ;res@mpGridLonSpacingF = 3.0
>
> suma!0 = "lat"
> suma!1 = "lon"
> ;suma&lat2d = lat2d
> ;suma&lon2d = lon2d
> ;sumh&lat2d = lat2d
> ;sumh&lon2d = lon2d
>
> ;map it to the wrfgrid perhaps? Wow that takes entirely too long.
> ;nlat = fspan(20.,55.,360)
> ;nlon = fspan(-120.,-60.,611)
> ;print("here")
> ;suma2 = rcm2rgrid(xlat,xlon,suma,nlat,nlon,1)
> ;print("here2")
> ;suma1 = rgrid2rcm(nlat,nlon,suma2,lata,lona,1)
>
> plot = gsn_csm_contour_map(wks,suma,res)
>
> ;delete(suma2)
> ;delete(suma1)
> ;suma2 = rcm2rgrid(lat2d,lon2d,sumh,nlat,nlon,1)
> ;suma1 = rgrid2rcm(nlat,nlon,suma2,lata,lona,1)
>
> ;do h=0,23
> ;plot = gsn_csm_contour_map(wks,sumh(h,:,:),res)
> ;end do
>
> end
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 14 17:43:32 2010

This archive was generated by hypermail 2.1.8 : Wed Jun 16 2010 - 15:28:33 MDT