<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Dear NCL Users<span class="Apple-tab-span" style="white-space:pre">
</span>
<div><br>
</div>
<div>I am currently trying to create box whisker plots of drying regions over land regions.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Essentially what I would like to do is:</div>
<div><br>
</div>
<div>1. Mask out the land regions (DONE)<br>
</div>
<div>2. Mask out the wetting regions (i.e. only have the drying regions) (DONE)<br>
</div>
<div>3. Area average the change in precipitation over a particular domain over the southern African continent (NOT SURE?? area average or dim_avg?)<br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Below is my code in NCL attempting to do 1-4<br>
<br>
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.
<br>
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.<br>
<br>
;*********************************************<br>
; boxplot.ncl<br>
;<br>
; ;*********************************************<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"<br>
;*********************************************<br>
begin<br>
;**********************************************<br>
; Add data in text format and sort in ascending order<br>
;**********************************************<br>
<br>
<br>
model = (/"bcc-csm1-1-m","BNU-ESM","CanESM2","CCSM4","CESM1-BGC","CESM1-CAM5","CSIRO-Mk3-6-0","FIO-ESM","GFDL-CM3","GFDL-ESM2G","GFDL-ESM2M","GISS-E2-H","HadGEM2-CC","HadGEM2-ES","IPSL-CM5A-LR","IPSL-CM5A-MR","MIROC5","MRI-CGCM3","NorESM1-M","NorESM1-ME"/)<br>
<br>
<br>
do gg = 0,dimsizes(model)-1<br>
;dP<br>
in1=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadprfutureOND/Delta_pr_"+model(gg)+".nc","r")
<br>
<br>
;dPShift<br>
in2=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPSpat_"+model(gg)+"_safrica_PSpat.nc","r")<br>
;dPT<br>
in3=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPT_"+model(gg)+"_safrica_PT.nc","r")<br>
;dPWeak<br>
in4=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPDiv_"+model(gg)+"_safrica_PDiv.nc","r")<br>
;dPTWRH<br>
in5=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPDiv+PT+PRH_"+model(gg)+".nc","r")<br>
;dPCross<br>
in6=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPNL_"+model(gg)+"_safrica_PNL.nc","r")<br>
;dPRH<br>
in7=addfile("/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPRH_"+model(gg)+"_safrica_PRH.nc","r")<br>
<br>
<br>
lat = in1->lat <br>
lon = in1->lon <br>
time = in1->time<br>
<br>
if ((gg.eq.0) .or. (gg.eq.9) .or. (gg.eq.10) .or. (gg.eq.11)) then<br>
dP = dble2flt(in1->pr(:,:,:))<br>
dPShift = in2->huss(:,:,:)<br>
dPtwrh = in5->huss(:,:,:)<br>
dPcross = in6->huss(:,:,:)<br>
dPT = in3->es2(:,:,:)<br>
dPweak = in4->huss(:,:,:)<br>
dPrh = in7->huss(:,:,:)<br>
<br>
else<br>
<br>
dP = in1->pr(:,0,:,:)<br>
dPShift = in2->huss(:,0,:,:)<br>
dPtwrh = in5->huss(:,0,:,:)<br>
dPcross = in6->huss(:,0,:,:)<br>
dPT = in3->es2(:,0,:,:)<br>
dPweak = in4->huss(:,0,:,:)<br>
dPrh = in7->huss(:,0,:,:)<br>
<br>
end if<br>
<br>
;Land mask<br>
<br>
b=addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")<br>
lsm_dP = landsea_mask(b->LSMASK,dP&lat,dP&lon) ; read in land sea mask<br>
dP = mask(dP,lsm_dP.eq.0,False) ;mask out all ocean points)<br>
<br>
;Drymask<br>
<br>
dP_dry = new ((/dimsizes(time),dimsizes(lat),dimsizes(lon)/), typeof(dP))<br>
dP_dry!0="time"<br>
dP_dry&time=time<br>
dP_dry!1="lat"<br>
dP_dry&lat=lat<br>
dP_dry!2="lon"<br>
dP_dry&lon=lon<br>
<br>
dP_dry = mask(dP,dP.gt.0, False) ; mask out all the wetting regions i.e. any values above 0 for dP<br>
<br>
<br>
printVarSummary(dP)<br>
printVarSummary(dP_dry)<br>
<br>
dP_fldmean = wgt_areaave(dP_dry((gg),{-30:0},{10:40}),1.0, 1.0, 0)<br>
;dP_fldmean = dim_avg(dP_dry(0,{-30:0},{10:40}))<br>
<br>
print(dP_dry)<br>
printVarSummary(dP_fldmean)<br>
print(dP_fldmean)<br>
<br>
end do <br>
<br>
end <br>
</div>
<div><br>
</div>
<div>Any advice regarding this code would very much be appreciated. </div>
<div><br>
Kindest Regards<br>
Melissa<br>
</div>
<div><br>
</div>
</div>
</div>
</body>
</html>