Re: Column Integrated Total Cloud Mixing Ratio/colorbar

From: <yagnesh_at_nyahnyahspammersnyahnyah>
Date: Thu Feb 28 2013 - 23:06:04 MST

Hello Tracy,

On Mar 01 2013, Tracy Emerson <temerson@ucar.edu> wrote:

> Hi all,
>
> #1. I am trying to figure out if there is a function in NCL that calculates
> the column integrated total cloud mixing ratio (mm) , from cloud water/ice
> mixing ratios (g/kg). I didn't find anything in my searches so I expect not.
> I am trying to reproduce a figure that was made using RIP (which I've never
> used) which calculates this field (intcld).
>

I am no expert. but I have following function locally which may be useful for
you.

--8<---------------cut here---------------start------------->8---
;_____________________________________________________________________________
; wrf_user_getvar_weighted_sum:
; Calculate weighted sum of a WRF variable. uses hydrostatic equation.
;_____________________________________________________________________________
undef("wrf_user_getvar_weighted_sum")
function wrf_user_getvar_weighted_sum(file_handle,var_in:string,time_in:integer)
local var,varname, var, ph,phb,pres,gh,dim, wgt_var, noflevels, \
        lay_var,dgh,dp, lay_wgt, lay_wgt_var, wgt_var,time,g

begin
  g = 9.8 ; gravity

; check the file handle is okay
  if(typeof(file_handle).eq."file") then
    ISFILE = True
    nc_file = file_handle
  else
    print("wrf_user_getvar: error: the first argument must be a file or a list of files opened with addfile or addfiles")
    return
  end if

; get var we need to return
  varname=var_in(0)
  time = time_in(0)

  var = wrf_user_getvar(nc_file,varname,time)
  ph = wrf_user_getvar(nc_file,"PH",time)
  phb = wrf_user_getvar(nc_file,"PHB",time)
  pres = wrf_user_getvar(nc_file,"pressure",time)
  gh = ph + phb ;geo potential height

  dim = dimsizes(var)
  wgt_var = new((/ dim(1),dim(2) /),typeof(var))

  wgt_var = 0 ;intialize
  noflevels = 32
  do z = 0, noflevels, 1 ; z level

    lay_var = (var(z+1,:,:) + var(z,:,:)) / 2. ; mean var

    dgh = gh(z+1,:,:) - gh(z,:,:) ; 𝑑𝑧
    dp = pres(z+1,:,:) - pres(z,:,:) ; 𝑑𝑝
    lay_wgt = -1 * (dp/dgh) / g ; 𝜚 = - 𝑑𝑝/𝑑𝑧 / 𝑔
    lay_wgt_var = lay_var * lay_wgt
    wgt_var = wgt_var + lay_wgt_var
  end do
  return(wgt_var)
end
--8<---------------cut here---------------end--------------->8---

And in my script I use something like

   wgted_cloud = wrf_user_getvar_weighted_sum(a,"QCLOUD",time_step) ; just like wrf_user_getvar

and then I do some unit conversion stuff.

Thanks.,

-- 
ఎందరో మహానుభావులు అందరికి వందనములు.
YYR
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Feb 28 23:06:17 2013

This archive was generated by hypermail 2.1.8 : Fri Mar 01 2013 - 10:41:03 MST