problems about regridding and functions of linint2_Wrap! HELP !

From: bianh_522 <bianh_522_at_nyahnyahspammersnyahnyah>
Date: Sat, 13 Sep 2008 08:53:01 +0800 (CST)

hello everyone:
 
  I used output from CAM3 ,which form is *.nc and the grid is 2x2.5 lat=91 lon=144,
and I need change it to 2.5x2.5 lat=73 lon=144.
  First I used f2fsh_Wrap to do ,but the value of varibles seems to be some wrong,sst with a min of -50
and then T changed to use linint2_Wrap to do ,bu I cann't use GRADS to open the *.nc ,It shows

Scanning self-describing file: e:\cam\out1\cam199107.nc
SDF file has no discernable X coordinate.

and I make my ddf of lon begin with -180.0. It doesn't work else.

It seems some wrong during the linint2_Wrap,I think .So I wonder that anybody has encounted

 this ?or has some exprience?

Here with my ncl script
-------

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

;**********************************************************
in =addfile("/scratch/student/bianh/cam1/work/out/cam.cam2.h0.1991-06-15-00000.nc","r")
;**********************************************************

;**********************************************************
; read needed variables

      hgt = in->Z3
       t = in->T
       u = in->U
       v = in->V
      rh = in->RELHUM
      psl = in->PSL
      ps = in->PS
      sst = in->SST
      t2 = in->T2
      rh2 = in->RH2
      u10 = in->U10
      v10 = in->V10
     phis = in->PHIS
      
;**********************************************************
; interpolate gaussian grid to fix grid (bilinear interpolation)
;**********************************************************
; TonPfix=f2fsh_Wrap(t,(/73,144/))
; UonPfix=f2fsh_Wrap(u,(/73,144/))
; VonPfix=f2fsh_Wrap(v,(/73,144/))
; RHonPfix=f2fsh_Wrap(rh,(/73,144/))
; psfix=f2fsh_Wrap(ps,(/73,144/))
; phisfix=f2fsh_Wrap(phis,(/73,144/))
; Z3onPfix=f2fsh_Wrap(hgt,(/73,144/))
; u10fix=f2fsh_Wrap(u10,(/73,144/))
; v10fix=f2fsh_Wrap(v10,(/73,144/))
; t2fix=f2fsh_Wrap(t2,(/73,144/))
; rh2fix=f2fsh_Wrap(rh2,(/73,144/))
; pslfix=f2fsh_Wrap(psl,(/73,144/))
; sstfix=f2fsh_Wrap(sst,(/73,144/))

       latG = new(91,float)
       latG = fspan(-90.0,90.0,91)
       lonG = new(144,float)
       lonG = fspan(0.0,360.0,144)
      latF = new(73,float)
       latF = fspan(-90.0,90.0,73)
       lonF = new(144,float)
       lonF = fspan(-180.0,180.0,144)

      TonPfix = linint2_Wrap(lonG,latG,t,False,lonF,latF,0)
      Z3onPfix = linint2_Wrap(lonG,latG,hgt,False,lonF,latF,0)
      UonPfix = linint2_Wrap(lonG,latG,u,False,lonF,latF,0)
      VonPfix = linint2_Wrap(lonG,latG,v,False,lonF,latF,0)
      RHonPfix = linint2_Wrap(lonG,latG,rh,False,lonF,latF,0)
      psfix = linint2_Wrap(lonG,latG,ps,False,lonF,latF,0)
      phisfix = linint2_Wrap(lonG,latG,phis,False,lonF,latF,0)
      u10fix = linint2_Wrap(lonG,latG,u10,False,lonF,latF,0)
      v10fix = linint2_Wrap(lonG,latG,v10,False,lonF,latF,0)
      t2fix = linint2_Wrap(lonG,latG,t2,False,lonF,latF,0)
      rh2fix = linint2_Wrap(lonG,latG,rh2,False,lonF,latF,0)
      pslfix = linint2_Wrap(lonG,latG,psl,False,lonF,latF,0)
      sstfix = linint2_Wrap(lonG,latG,sst,False,lonF,latF,0)

;************************************************************************
    
       nvars = 5
       P0mb = 1000
       hyam = in->hyam
       hybm = in->hybm
       tbot = TonPfix(:,25,:,:)
;***********************************************************************
       
       npnew = 17
       pnew = new(npnew,float)
       pnew =(/1000.0,925.0,850.0,700.0,600.0,500.0,400.0,300.0,250.0,200.0,150.0,100.0,70.0,50.0,30.0,20.0,10.0/)
;***********************************************************************
; define other arguments required by vinth2p_ecmwf
; type of interpolation: 1 = linear,2 =log, 3 = loglog
        interp =2
;is extrapolation desired if data is outside the range of PS
        extrap = True

;calculate T,Z3,RELHUM,U,V on pressure levels

   TonP = vinth2p_ecmwf(TonPfix,hyam,hybm,pnew,psfix,interp,P0mb,1,extrap,1,tbot,phisfix)
   Z3onP = vinth2p_ecmwf(Z3onPfix,hyam,hybm,pnew,psfix,interp,P0mb,1,extrap,-1,tbot,phisfix)
   UonP = vinth2p_ecmwf(UonPfix,hyam,hybm,pnew,psfix,interp,P0mb,1,extrap,0,tbot,phisfix)
   VonP = vinth2p_ecmwf(VonPfix,hyam,hybm,pnew,psfix,interp,P0mb,1,extrap,0,tbot,phisfix)
   RHonP = vinth2p_ecmwf(RHonPfix,hyam,hybm,pnew,psfix,interp,P0mb,1,extrap,0,tbot,phisfix)
;**************************************************************************

; Tfix=g2fsh_Wrap(TonP,(/73,144/))
; Z3fix=g2fsh_Wrap(Z3onP,(/73,144/))
; Ufix=g2fsh_Wrap(UonP,(/73,144/))
; Vfix=g2fsh_Wrap(VonP,(/73,144/))
; RHfix=g2fsh_Wrap(RELHUMonP,(/73,144/))

;**************************************************************************
; output the result
;**************************************************************************
   ntime = dimsizes(in->time)
   nlev = 17
   nlat = dimsizes(latF)
   nlon = dimsizes(lonF)

  time = in->time
  lev = pnew
  lat = latF
  lon = lonF

;give the file name
  
  
  ncdf=addfile("/scratch/student/bianh/cam1/work/cam199107.nc","c")
;--------------------------------------------------------------------------
;Global attributes of the file

   fAtt = True
   fAtt_at_title = "CAM3 history files interpolated from sigma to pressure"
   fAtt_at_source_file = "cam3 output"
   fAtt_at_conventions = "none"
   fAtt_at_creation_date = systemfunc("date")
   fileattdef(ncdf,fAtt)
;--------------------------------------------------------------------------
   dimNames = (/"time","lev","lat","lon"/)
   dimSizes = (/ntime,nlev,nlat,nlon/)
   dimUnlim = (/False,False,False,False/)
   filedimdef(ncdf,dimNames,dimSizes,dimUnlim)
;--------------------------------------------------------------------------
   filevardef(ncdf,"time",typeof(time),"time")
   filevardef(ncdf,"lev","float","lev")
   filevardef(ncdf,"lat","double","lat")
   filevardef(ncdf,"lon","double","lon")
   filevardef(ncdf,"t",typeof(t),(/"time","lev","lat","lon"/))
   filevardef(ncdf,"hgt",typeof(hgt),(/"time","lev","lat","lon"/))
   filevardef(ncdf,"u",typeof(u),(/"time","lev","lat","lon"/))
   filevardef(ncdf,"v",typeof(v),(/"time","lev","lat","lon"/))
   filevardef(ncdf,"rh",typeof(rh),(/"time","lev","lat","lon"/))
;----------------------------------------------------------------------------
; dimNames = (/"time","lat","lon"/)
; dimSizes = (/ntime,nlat,nlon/)
; dimUnlim = (/False,False,False,False/)
; filedimdef(ncdf,dimNames,dimSizes,dimUnlim)

   
; filevardef(ncdf,"pmsl",typeof(psl),(/"time","lat","lon"/))
; filevardef(ncdf,"ps",typeof(ps),(/"time","lat","lon"/))
; filevardef(ncdf,"skintemp",typeof(sst),(/"time","lat","lon"/))
; filevardef(ncdf,"t2",typeof(t2),(/"time","lat","lon"/))
; filevardef(ncdf,"u10",typeof(u10),(/"time","lat","lon"/))
; filevardef(ncdf,"v10",typeof(v10),(/"time","lat","lon"/))
; filevardef(ncdf,"rh2",typeof(rh2),(/"time","lat","lon"/))

;----------------------------------------------------------------------------
; add some attributes
;----------------------------------------------------------------------------
  TonP_at_long_name="Temperature"
  TonP_at_units="Celsuis"
  Z3onP_at_long_name="Geoptential Height"
  Z3onP_at_units="M"
  RHonP_at_long_name="Relative humidity"
  UonP_at_long_name=u_at_long_name
  UonP_at_units=u_at_units
  VonP_at_long_name=v_at_long_name
  VonP_at_units=v_at_units
; pslfix_at_long_name=psl_at_long_name
; pslfix_at_units=psl_at_units
; psfix_at_long_name=ps_at_units
; psfix_at_units=ps_at_units
; sstfix_at_long_name=sst_at_long_name
; sstfix_at_units=sst_at_units
; t2fix_at_long_name=t2_at_long_name
; t2fix_at_units=t2_at_units
; rh2fix_at_long_name=rh2_at_long_name
; rh2fix_at_units=rh2_at_units
; u10fix_at_longname=u10_at_long_name
; u10fix_at_units=u10_at_units
; v10fix_at_long_name=v10_at_long_name
; v10fix_at_units=v10_at_units

 filevarattdef(ncdf,"t",TonP)
 filevarattdef(ncdf,"hgt",Z3onP)
 filevarattdef(ncdf,"u",UonP)
 filevarattdef(ncdf,"v",VonP)
 filevarattdef(ncdf,"rh",RHonP)
; filevarattdef(ncdf,"ps",psfix)
; filevarattdef(ncdf,"psl",pslfix)
; filevarattdef(ncdf,"skintemp",sstfix)
; filevarattdef(ncdf,"t2",t2fix)
; filevarattdef(ncdf,"rh2",rh2fix)
; filevarattdef(ncdf,"u10",u10fix)
; filevarattdef(ncdf,"v10",v10fix)

 filevarattdef(ncdf,"time",time)
 filevarattdef(ncdf,"lev",lev)
 filevarattdef(ncdf,"lat",lat)
 filevarattdef(ncdf,"lon",lon)
 
 ncdf->lev_at_long_name="pressure"
 ncdf->lev_at_units="mb"
 ncdf->time_at_long_name="time"
; ncdf->lat_at_long_name="latitude"
; ncdf->lon_at_long_name="longtitude"

;------------------------------------------------------------
; output only the data values since the dimensionality and such have been predefined
;--------------------------------------------------------------

  ncdf->time=(/time/)
  ncdf->lev=pnew
  ncdf->lat=(/lat/)
  ncdf->lon=(/lon/)
 
  ncdf->t=(/TonP/)
  ncdf->hgt=(/Z3onP/)
  ncdf->u=(/UonP/)
  ncdf->v=(/VonP/)
  ncdf->rh=(/RHonP/)
  ncdf->pmsl=pslfix
  ncdf->ps=psfix
  ncdf->skintemp=sstfix
  ncdf->t2=t2fix
  ncdf->rh2=rh2fix
  ncdf->u10=u10fix
  ncdf->v10=v10fix

end

---------------------------------------

 

[广告] KFC骨肉相连优惠券

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Sep 12 2008 - 18:53:01 MDT

This archive was generated by hypermail 2.2.0 : Fri Sep 12 2008 - 21:42:04 MDT