# [ncl-talk] Masking, area averaging and box whisker plots

Melissa Lazenby M.Lazenby at sussex.ac.uk
Tue Mar 21 06:41:16 MDT 2017

```Dear NCL Users

I am currently trying to create box whisker plots of drying regions over land regions.

I have tried creating the masks and field averages in CDO however there seems to be a bug in the CDO code I am running so I am trying to do all the masking and area averaging in an NCL script.

Essentially what I would like to do is:

1. Mask out the land regions  (DONE)
2. Mask out the wetting regions (i.e. only have the drying regions) (DONE)
3. Area average the change in precipitation over a particular domain over the southern African continent (NOT SURE?? area average or dim_avg?)
4. Create a box whisker plot of the change in precipitation over that region for 20 different CMIP5 models to determine the robustness and spread.

Below is my code in NCL attempting to do 1-4

I have managed to do steps 1 and 2 without problems, however I am struggling to complete step 3 i.e. create an field mean using the area average function.
Essentially I would like 20 output values from my 20 models of the area averages and currently I am only obtaining 1 value not 20.

;*********************************************
; boxplot.ncl
;
; ;*********************************************
;*********************************************
begin
;**********************************************
; Add data in text format and sort in ascending order
;**********************************************

do gg = 0,dimsizes(model)-1
;dP

;dPShift
;dPT
;dPWeak
;dPTWRH
;dPCross
;dPRH

lat    = in1->lat
lon    = in1->lon
time   = in1->time

if ((gg.eq.0) .or. (gg.eq.9) .or. (gg.eq.10) .or. (gg.eq.11)) then
dP = dble2flt(in1->pr(:,:,:))
dPShift = in2->huss(:,:,:)
dPtwrh = in5->huss(:,:,:)
dPcross = in6->huss(:,:,:)
dPT = in3->es2(:,:,:)
dPweak = in4->huss(:,:,:)
dPrh = in7->huss(:,:,:)

else

dP = in1->pr(:,0,:,:)
dPShift = in2->huss(:,0,:,:)
dPtwrh = in5->huss(:,0,:,:)
dPcross = in6->huss(:,0,:,:)
dPT = in3->es2(:,0,:,:)
dPweak = in4->huss(:,0,:,:)
dPrh = in7->huss(:,0,:,:)

end if

dP_dry = new ((/dimsizes(time),dimsizes(lat),dimsizes(lon)/), typeof(dP))
dP_dry!0="time"
dP_dry&time=time
dP_dry!1="lat"
dP_dry&lat=lat
dP_dry!2="lon"
dP_dry&lon=lon

dP_dry = mask(dP,dP.gt.0, False)  ; mask out all the wetting regions i.e. any values above 0 for dP

printVarSummary(dP)
printVarSummary(dP_dry)

dP_fldmean = wgt_areaave(dP_dry((gg),{-30:0},{10:40}),1.0, 1.0, 0)
;dP_fldmean = dim_avg(dP_dry(0,{-30:0},{10:40}))

print(dP_dry)
printVarSummary(dP_fldmean)
print(dP_fldmean)

end do

end

Any advice regarding this code would very much be appreciated.

Kindest Regards
Melissa

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170321/45555359/attachment.html
```