NOAA-GSL / pygraf

ADB's Python graphics package
MIT License
10 stars 11 forks source link

develop Supercooled Liquid Water graphic #32

Closed cshartsough closed 3 years ago

cshartsough commented 4 years ago

using this NCL method:

; first, get Pmain levels from the p (midpoint, given in grib) levels and surface p
;
pvar = grb_file->$PRESNATNAME$(:,:,:)
Pmain = pvar * 0. ; initialize a new array for main P levels
psfcvar = grb_file->$PSFCNAME$(:,:)
;print("psfcvar = "+psfcvar(0,0))
nnat = grb_file->$NUMNATLEVS$(:)
nn = dimsizes(nnat) - 1
;
;do ip = 0,nn
; print("pvar "+ip+" = "+pvar(ip,0,0))
;end do
do ip = 0,nn
 if (ip .eq. 0) then
  Pmain(0,:,:) = (2.0 * pvar(0,:,:)) - psfcvar(:,:)
 else
  Pmain(ip,:,:) = (2.0 * pvar(ip,:,:)) - Pmain(ip - 1,:,:)
 end if
; print("Pmain "+ip+" = "+Pmain(ip,0,0))
end do
;
; now use the Pmain levels to get dp at each level
;
dp = pvar * 0.
do ip = 0,nn - 1
 if (ip .eq. 0) then
  dp(0,:,:) = psfcvar(:,:) - Pmain(0,:,:)
 else
  dp(ip,:,:) = Pmain(ip,:,:) - Pmain(ip + 1,:,:)
 end if
; print("dp "+ip+" = "+dp(ip,0,0))
end do
;
tempvar = grb_file->$TMPNATNAME$(:,:,:) - 273.15 ; convert to deg C
clwmrvar = grb_file->$CLWMRNATNAME$(:,:,:)
rwmrvar = grb_file->$RWMRNATNAME$(:,:,:)
one_ov_g = 1. / 9.81
;
slwvar = tempvar * 0. ; initialize slw
slwcolvar = lat * 0. ; initialize slwcol
slwvar = where(tempvar .le. 0,clwmrvar + rwmrvar,slwvar)
;do i = 0,nx - 1
; do j = 0,ny - 1
;  do k = 0,nn - 1
;   if (tempvar(k,j,i) .le. 0.) then
;    slwvar(k,j,i) = clwmrvar(k,j,i) + rwmrvar(k,j,i)
;    slwcolvar(j,i) = slwcolvar(j,i) + dp(k,j,i) * one_ov_g * slwvar(k,j,i)
;   end if     
;  end do
; end do
;end do
;
do k = 0,nn - 1 
 slwcolvar = slwcolvar + dp(k,:,:) * one_ov_g * slwvar(k,:,:)
end do
;
tvar = slwcolvar

should point out that CLWMRNATNAME is cloud water mixing ratio, and RWMRNATNAME is rain water mixing ratio.

cshartsough commented 3 years ago

this task was completed in PR 65 (February 2021)