Re: is_valid_latlon2d_attr: Warning:

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 03 2014 - 08:55:26 MDT

Dear Li,

This is a case of where it's important to look at your data. Right after you read in "crain", do a printVarSummary on it:

printVarSummary(crain)

It looks like this:

Variable: crain
Type: float
Total Size: 1232000 bytes
            308000 values
Number of Dimensions: 2
Dimensions and sizes: [lat | 440] x [lon | 700]
Coordinates:
            lat: [15.05..58.95]
            lon: [70.05..139.95]
Number Of Attributes: 5
  missing_value : -999
  long_name : CH01 combined analysis (mm/Hour)
  time : 22
  lev : 1
  _FillValue : -999

Note that "crain" has coordinate arrays called "lat" and "lon":

Coordinates:
            lat: [15.05..58.95]
            lon: [70.05..139.95]

When you have coordinate arrays already attached to your data variable, you do not need to read in lat / lon separately and attach them.

To get your script to work, remove these five lines:

> lat = fi->lat
> lon = fi->lon

> crain@_FillValue = -999
> crain@lat2d = lat
> crain@lon2d = lon

I'm removing the setting of "_FillValue", because it is already attached (see printVarSummary output above).

--Mary

On Jun 2, 2014, at 8:29 PM, Li Qi <liqi123sh@qq.com> wrote:

>
> Dear Mary,
>
> I've tried your suggestion, but the data are still overlaid on the map incorrectly.
>
> Here is my code and attached please find the data "crain24h.nc"
>
>
> 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
> fi = addfile("./crain24h.nc", "r")
>
> wks = gsn_open_wks("eps", "crain1h")
> gsn_define_colormap(wks, "precip")
>
> lat = fi->lat
> lon = fi->lon
> time = fi->time
>
> ntimes = dimsizes(time) ; number of times in the file
>
> ;;;;;;;;;;;;
>
> do it = 0, ntimes-1 ; time loop
>
>
> crain = fi->crain(it,0,:,:)
> crain@_FillValue = -999
> crain@lat2d = lat
> crain@lon2d = lon
> res = True
> res@gsnAddCyclic = False
>
> ;;;;;;;;;;;;;;set for the map
> res@mpDataBaseVersion = "HighRes"
> res@mpDataSetName = "Earth..4"
> res@mpGridAndLimbOn = False ; Turn off lat/lon lines
> res@mpOutlineOn = True ; Turn on map outlines
> res@mpGeophysicalLineColor = "Black" ; Change the outline line color
> res@mpGeophysicalLineThicknessF= 2. ; double the thickness of geophysical boundaries
> res@mpOutlineSpecifiers = (/"China","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)
> ;;;;;;;;;;;;;;;ZOOM
> res@mpMinLatF = 27.7
> res@mpMaxLatF = 32
> res@mpMinLonF = 113
> res@mpMaxLonF = 122
> res@pmTickMarkDisplayMode = "Always"
>
>
> res@cnFillOn = True
> res@cnLinesOn = False ; Turn off contour lines
> res@cnLevelSelectionMode = "ExplicitLevels"
> res@cnLevels = (/1, 2, 6, 10, 15, 20, 30, 40, 50, 70, 90, 110, 130, 150, 200/)
>
> res@lbBoxLinesOn = False
> plot = gsn_csm_contour_map(wks, crain, res)
>
>
> ;;;;;;;;;;;;;;;;;;;;;
> end do
> end
>
> -------------------------
> ncl_filedump crain24h.nc
>
> Variable: f
> Type: file
> filename: crain24h
> path: crain24h.nc
> file global attributes:
> CDI : Climate Data Interface version 1.6.2 (http://code.zmaw.de/projects/cdi)
> Conventions : CF-1.4
> history : Mon Jun 02 15:42:14 2014: cdo -f nc import_binary crain24h.ctl crain24h.nc
> CDO : Climate Data Operators version 1.6.2 (http://code.zmaw.de/projects/cdo)
> dimensions:
> lon = 700
> lat = 440
> lev = 1
> time = 24 // unlimited
> variables:
> double lon ( lon )
> standard_name : longitude
> long_name : longitude
> units : degrees_east
> axis : X
>
> double lat ( lat )
> standard_name : latitude
> long_name : latitude
> units : degrees_north
> axis : Y
>
> double lev ( lev )
> long_name : generic
> units : level
> axis : Z
>
> double time ( time )
> standard_name : time
> units : hours since 2011-06-14 01:00:00
> calendar : standard
>
> float crain ( time, lev, lat, lon )
> long_name : CH01 combined analysis (mm/Hour)
> _FillValue : -999
> missing_value : -999
>
> float gsamp ( time, lev, lat, lon )
> long_name : CH02 gauge numbers
> _FillValue : -999
> missing_value : -999
>
>
> ------------------ Original ------------------
> From: "Mary Haley";<haley@ucar.edu>;
> Date: Tue, Jun 3, 2014 01:30 AM
> To: "Li Qi"<liqi123sh@qq.com>;
> Cc: "ncl-talk"<ncl-talk@ucar.edu>;
> Subject: Re: [ncl-talk] is_valid_latlon2d_attr: Warning:
>
> Li,
>
> This is not quite enough information. Are you getting any other errors?
>
> You might try setting the gsnAddCyclic resource to False:
>
> res@gsnAddCyclic = False
>
> --Mary
>
> On Jun 2, 2014, at 1:39 AM, Li Qi <liqi123sh@qq.com> wrote:
>
> > hello,
> >
> > I got a warning:
> >
> > (0) is_valid_latlon2d_attr: Warning: The 'lat2d' attribute must either be the same dimension sizes as the data, or one element larger in both directions. Your data will most likely not be overlaid on the map correctly.
> >
> > How to solve it?
> >
> > Thanks in advance for any advice!
> >
> > Li Qi
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> .
> 从QQ邮箱发来的超大附件
>
> crain24h.nc (56.4M, 2014年07月03日 10:22 到期)
> 进入下载页面
> _______________________________________________
> 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 Tue Jun 3 08:55:40 2014

This archive was generated by hypermail 2.1.8 : Tue Jun 03 2014 - 11:40:09 MDT