Re: Unknown and unreasonable values when making plots with NARR (.nc) data

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Mon, 29 Jun 2009 20:22:06 -0600

Yan,

The problem is in the data files, not your script. Some of the NARR
files from NOAA/PSD contain a _FillValue attribute that differs from
the missing_value attribute. This leads to the problem shown in
your plot. This problem has been reported to the data management
group here.

There is an easy workaround. Replace these lines:

                                            ; convert short=>float
   x = short2flt( f->air(10,:,:,:) ) ; (time=10,lev,lat,lon)

with the following:

   in = f->air(10,:,:,:) ; read data subset as packed

   if (isatt(in,"_FillValue") .and. isatt(in,"missing_value")) then
     if (in@_FillValue .ne. in_at_missing_value) then
       in@_FillValue = in_at_missing_value ; use alt. missing value
     end if ; only if needed
   end if

   x = short2flt(in) ; convert short=>float

and you should then get the expected results.

Dave Allured
CU/CIRES Climate Diagnostics Center (CDC)
http://cires.colorado.edu/science/centers/cdc/
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
http://www.cdc.noaa.gov/psd1/

Yan Bao wrote:
> Hi, Every one,
> I tried to make plots with the script in ncl webpage using the
> similar NARR .nc data (air.199001.nc < >), to see
> what I have got (see attachment). I have tried soil temperature, soil
> moisture, surface heat flux, geopotential height , and so on, the
> similar things happen to NARR. There must be something wrong with the
> script (acturally I didn't do any modification compared with the one in
> the NCL webpage except for the file) or some reason I haven't
> considered about when processing NARR data. Any suggestions?
> You're very appreciated for any help.
>
> Yan
>
> The script I use:
>
> 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"
>
> begin
> ;*******************************************
> ; open file and read in data
> ;*******************************************
> diri = "./" ; input directory
> f = addfile (diri+"air.199001.nc <http://air.199001.nc>", "r")
> ; convert short=>float
> x = short2flt( f->air(10,:,:,:) ) ; (time=10,lev,lat,lon)
>
> lat2d = f->lat ; coordinates
> lon2d = f->lon
> dimlc = dimsizes(lat2d) ; dimension sizes
> nlat = dimlc(0)
> mlon = dimlc(1)
> ;*************create plots*******************
> wks = gsn_open_wks ("ps", "narr") ; open workstation
> gsn_define_colormap (wks,"gui_default") ; choose color map
>
> res = True ; plot mods desired for original grid
> res_at_cnFillOn = True ; color fill
> res_at_cnLinesOn = False ; no contour lines
> res_at_gsnSpreadColors = True ; use total colormap
> res_at_gsnSpreadColorStart = 4
> res_at_gsnSpreadColorEnd = -1
> res_at_mpGridAndLimbOn = True
> res_at_pmTickMarkDisplayMode = "Always" ; turn on tickmarks
> res_at_tmXTOn = False
> res_at_gsnAddCyclic = False ; regional data
>
> res_at_mpLimitMode = "Corners" ; choose range of map
> res_at_mpLeftCornerLatF = lat2d(0,0)
> res_at_mpLeftCornerLonF = lon2d(0,0)
> res_at_mpRightCornerLatF = lat2d(nlat-1,mlon-1)
> res_at_mpRightCornerLonF = lon2d(nlat-1,mlon-1)
> res_at_tfDoNDCOverlay = True ; direct plot
> res_at_mpProjection = "LambertConformal"
> res_at_mpLambertParallel1F = f->Lambert_Conformal_at_standard_parallel(0) ; lat2d_at_mpLambertParallel1F
> res_at_mpLambertParallel2F = f->Lambert_Conformal_at_standard_parallel(1)
> res_at_mpLambertMeridianF = f->Lambert_Conformal_at_longitude_of_central_meridian
>
> res_at_gsnCenterString = "T@"+x&level(3) + "hPa" ; draw center subtitle
> res_at_gsnLeftString = "Original grid" ; draw left subtitle
> plot = gsn_csm_contour_map(wks,x(3,:,:),res) ; Draw original grid on map
> 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 29 2009 - 20:22:06 MDT

This archive was generated by hypermail 2.2.0 : Wed Jul 01 2009 - 06:11:45 MDT