Re: regrid problem

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun May 12 2013 - 13:45:15 MDT

Your "plot_regrid_data.ncl" script should have been giving you an error when you ran it:

(0) gsn_add_cyclic: Warning: The range of your longitude coordinate array is at least 360.
(0) You may want to set gsnAddCyclic to False to avoid a warning
(0) message from the spline function.

Once I set

res@gsnAddCyclic = False

the script ran fine with the correct image.

--Mary

On May 10, 2013, at 9:43 AM, cheryl Ma wrote:

> Thanks, Mary.
>
> Yes, I set up the coordinate arrays for var. I am attaching the data file and plotting codes. could you please take a look?
> Thanks,
>
>
> On Fri, May 10, 2013 at 11:29 AM, Mary Haley <haley@ucar.edu> wrote:
> The problem is likely with your plotting. Did you set up
> the coordinate arrays for "var" like you did with "var0"?
>
> Since you didn't include your data or your plotting code,
> I took the code snippet you had below, created some
> dummy data, added coordinates for "var" and added
> some plotting code. You will see that the two plots
> look correct.
>
> --Mary
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> begin
> nlat = 45
> nlon = 72
> var0 = generate_2d_array(10, 10, -19, 19, 0, (/nlat,nlon/))
> lat=fspan(-90.0,90.0,nlat)
> lon=fspan(-180.0,180.0,nlon)
> lat@units = "degrees_north"
> lon@units = "degrees_east"
>
> ;create a sequence for the new values of lat
> newlat=fspan(-90.0,90.0,180)
> ;create a sequence for the new values of lon
> newlon=fspan(-180.0,180.0,360)
> newlat@units = "degrees_north"
> newlon@units = "degrees_east"
> var=linint2(lon,lat,var0,True,newlon,newlat,0)
> var!0 = "LAT"
> var!1 = "LON"
> var&LAT = newlat
> var&LON = newlon
> var0!0 = "LAT"
> var0!1 = "LON"
> var0&LAT = lat
> var0&LON = lon
> printVarSummary(var)
>
> wks = gsn_open_wks("x11","contour_map")
>
> res = True
>
> res@gsnMaximize = True
> res@gsnDraw = False
> res@gsnFrame = False
> res@cnFillOn = True
> res@cnLinesOn = False
> res@cnLineLabelsOn = False
> res@gsnAddCyclic = False
>
> res@tiMainString = "regridded var"
> plot1 = gsn_csm_contour_map(wks,var0,res)
>
> res@tiMainString = "original var"
> plot2 = gsn_csm_contour_map(wks,var,res)
>
> gsn_panel(wks,(/plot1,plot2/),(/2,1/),True)
> end
>
>
>
> On May 10, 2013, at 8:58 AM, cheryl Ma wrote:
>
> > begin
> > nlat = 45
> > nlon = 72
> > setfileoption("bin","ReadByteOrder","BigEndian")
> > var0 = new( (/nlat,nlon/), float)
> > var0 = fbindirread( "1.dat",0, (/nlat,nlon/), "float")
> > printVarSummary(var0)
> > ;
> > lat=fspan(-90.0,90.0,nlat)
> > lon=fspan(-180.0,180.0,nlon)
> > print(lat)
> > print(lon)
> > ;
> > ;create a sequence for the new values of lat
> > newlat=fspan(-90.0,90.0,180)
> > ;create a sequence for the new values of lon
> > newlon=fspan(-180.0,180.0,360)
> > newlat@units = "degrees_north"
> > newlon@units = "degrees_east"
> > var=linint2(lon,lat,var0,True,newlon,newlat,0)
> > var!0 = "LAT"
> > var!1 = "LON"
> > var&LAT = newlat
> > var&LON = newlon
> > printVarSummary(var)
> > fout=addfile("regrid_data.nc","c")
> > fout->var=var
> > ;
> > end
>
>
> <plot_original_data.ncl><plot_regrid_data.ncl><1.dat>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun May 12 13:45:26 2013

This archive was generated by hypermail 2.1.8 : Wed May 15 2013 - 10:19:28 MDT