Why not debug at one grid point?
http://www.ncl.ucar.edu/Document/Functions/Built-in/dpres_hybrid_ccm.shtml
Example 3 ... modified here
---
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
....
dp = dpres_hybrid_ccm (ps,p0,hyai,hybi) ; Pa
xdp = x*dp ; (temporary variable)
copy_VarCoords(x, xdp)
vint = dim_sum_n( xdp, 1)
dpsum= dim_sum_n( dp, 1)
vavg = vint/dpsum ; weight average
copy_VarCoords(ps, vavg) ; add variable meta data
vavg@long_name = "Weighted Vertical Average: "+x@long_name
vavg@units = x@units
printVarSummary(vavg)
print("vavg: min="+min(vavg)+" max="+max(vavg))
LAT = 52.5 ; arbitrary grid point
LON = 13.0
nt = 0
print("---")
copy_VarCoords(x, dp)
print("x="+x(nt,:,{LAT},{LON}) +" dp="+ dp(nt,:,{LAT},{LON}) +"
xdp="+xdp(nt,:,{LAT},{LON}))
print("---")
print("LAT="+LAT+" LON="+LON+" vavg="+vavg(nt,{LAT},{LON}))
print("---")
delete( [/dp, xdp, ps, vint, dpsum/] ) ; delete temporary variables
On 12/26/12 8:12 PM, Thejna Tharammal wrote:
>
> Hi all,
>
> I want to calculate the total column mean of a variable from the CCSM model
> results. I tried to use dim_sum_n for the purpose as,
>
> ;**************************************
>
>
> dp = dpres_hybrid_ccm (ps,p0,hyai,hybi)
>
> xdp=x(0,:,:,:)*dp
>
> vint=x(0,0,:,:)
>
> vint = dim_sum_n(xdp,0)
>
> ; for average, 1/(b-a) * integral ( from a to b ) of f(x)
>
> vintAvg=vint
>
> vintAvg =vint/dim_sum_n(dp, 0)
>
> ;**************************************
>
> I find that the results obtained are very different from the ones calculated
> using nco vertical integration functions ("ncwa -a lev") as a test. So I
> wonder if the
> method I used is correct?
>
> Thanks,
>
> Thejna
>
>
>
>
>
> _______________________________________________
> 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 Wed Dec 26 21:55:09 2012
This archive was generated by hypermail 2.1.8 : Fri Jan 04 2013 - 15:32:29 MST