# get_cloudfrac

#### ukmetmodeller

##### New member
I've just been looking at the WRF-python code for calculating cloud cover. The python script uses the DCLOUDFRAC2 from wrf_cloud_fracf.f90 which all makes sense. I understand all elements of the process but I believe that the low / mid / high grouping is wrong when using pressure.

low_thresh = 97000
mid_thresh = 80000
high_thresh = 45000

I believe the requirements should be:
Low: full_p(k) <= low_thresh & > mid_thresh
Mid: full_p(k) <= mid_thresh & > high_thres
High: full_p(k) <= high_thresh

See below table for pressure levels at a single location (i,j)
 k 1​ 2​ 3​ 4​ 5​ 6​ 7​ 8​ 9​ 10​ 11​ 12​ 13​ 14​ 15​ 16​ 17​ 18​ 19​ 20​ 21​ full_p 96580.59​ 96057.03​ 95317.11​ 94014.46​ 92151.03​ 89689.49​ 86636.23​ 82997.47​ 78777.13​ 73980.17​ 68599.44​ 62624.09​ 56031.54​ 48747.43​ 40990.8​ 33650.34​ 27540.33​ 22820.15​ 18995.81​ 15398.71​ 11799.98​ <= low_thresh & >mid_thresh 9.17E-01​ 0.951522​ 1​ 1​ 1​ 1​ 1.00E+00​ 7.47E-01​ <= mid_thresh & >high_thresh 0.172427​ 0​ 0​ 0​ 0​ 0​ <= high_thresh 0.145057​ 0​ 0​ 0​ 0​ 0​ 0​

This would put level k=8 into the low group (82997.47 Pa is greater than 80000 Pa and less than 97000).
However, DCLOUDFRAC2 puts it into the mid group based on the following fortan code:

kchi = -1
kcmi = -1
kclo = -1

DO k = 1,nz
IF (vert(i,j,k) .GT. low_thresh) kclo=k
IF (vert(i,j,k) .GT. mid_thresh) kcmi=k
IF (vert(i,j,k) .GT. high_thresh) kchi=k
END DO

Here kclo=-1, kcmi=8, kchi=14

Then base on the loop below pressure level k=8 (82997.47 Pa) is greater than or equal to kcmi and less than kchi so fits into the mid cloud group.
DO k = 1,nz
IF (k .GE. kclo .AND. k .LT. kcmi) THEN
lowc(i,j) = MAX(rh(i,j,k), lowc(i,j))
ELSE IF (k .GE. kcmi .AND. k .LT. kchi) THEN ! mid cloud
midc(i,j) = MAX(rh(i,j,k), midc(i,j))
ELSE if (k .GE. kchi) THEN ! high cloud
highc(i,j) = MAX(rh(i,j,k), highc(i,j))
END IF
END DO

This doesn't match the criteria of Mid: full_p(k) <= mid_thresh & > high_thres (mid <= 80000 and > 45000)

Does anyone know if this is a mistake or intentional?