Re: regrid problem

From: cheryl Ma <xiaoyancloud_at_nyahnyahspammersnyahnyah>
Date: Fri May 10 2013 - 09:43:51 MDT

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
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Fri May 10 09:44:11 2013

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