<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&nbsp; (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 &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;<br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;<br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;<br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;<br>
;*********************************************<br>
begin<br>
;**********************************************<br>
; Add data in text format and sort in ascending order<br>
;**********************************************<br>
<br>
&nbsp;<br>
&nbsp;model = (/&quot;bcc-csm1-1-m&quot;,&quot;BNU-ESM&quot;,&quot;CanESM2&quot;,&quot;CCSM4&quot;,&quot;CESM1-BGC&quot;,&quot;CESM1-CAM5&quot;,&quot;CSIRO-Mk3-6-0&quot;,&quot;FIO-ESM&quot;,&quot;GFDL-CM3&quot;,&quot;GFDL-ESM2G&quot;,&quot;GFDL-ESM2M&quot;,&quot;GISS-E2-H&quot;,&quot;HadGEM2-CC&quot;,&quot;HadGEM2-ES&quot;,&quot;IPSL-CM5A-LR&quot;,&quot;IPSL-CM5A-MR&quot;,&quot;MIROC5&quot;,&quot;MRI-CGCM3&quot;,&quot;NorESM1-M&quot;,&quot;NorESM1-ME&quot;/)<br>
<br>
<br>
do gg = 0,dimsizes(model)-1<br>
;dP<br>
&nbsp; in1=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadprfutureOND/Delta_pr_&quot;&#43;model(gg)&#43;&quot;.nc&quot;,&quot;r&quot;)&nbsp;
<br>
<br>
;dPShift<br>
in2=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPSpat_&quot;&#43;model(gg)&#43;&quot;_safrica_PSpat.nc&quot;,&quot;r&quot;)<br>
;dPT<br>
in3=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPT_&quot;&#43;model(gg)&#43;&quot;_safrica_PT.nc&quot;,&quot;r&quot;)<br>
;dPWeak<br>
in4=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPDiv_&quot;&#43;model(gg)&#43;&quot;_safrica_PDiv.nc&quot;,&quot;r&quot;)<br>
;dPTWRH<br>
in5=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPDiv&#43;PT&#43;PRH_&quot;&#43;model(gg)&#43;&quot;.nc&quot;,&quot;r&quot;)<br>
;dPCross<br>
in6=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPNL_&quot;&#43;model(gg)&#43;&quot;_safrica_PNL.nc&quot;,&quot;r&quot;)<br>
;dPRH<br>
in7=addfile(&quot;/research/geog/data2/DATA/mlazenby/Chadwick_Analysis/ChadDeltaPComponentsOND/DeltaPRH_&quot;&#43;model(gg)&#43;&quot;_safrica_PRH.nc&quot;,&quot;r&quot;)<br>
<br>
<br>
&nbsp; lat&nbsp;&nbsp;&nbsp; = in1-&gt;lat <br>
&nbsp; lon&nbsp;&nbsp;&nbsp; = in1-&gt;lon <br>
&nbsp; time&nbsp;&nbsp; = in1-&gt;time<br>
<br>
if ((gg.eq.0) .or. (gg.eq.9) .or. (gg.eq.10) .or. (gg.eq.11)) then<br>
dP = dble2flt(in1-&gt;pr(:,:,:))<br>
dPShift = in2-&gt;huss(:,:,:)<br>
dPtwrh = in5-&gt;huss(:,:,:)<br>
dPcross = in6-&gt;huss(:,:,:)<br>
dPT = in3-&gt;es2(:,:,:)<br>
dPweak = in4-&gt;huss(:,:,:)<br>
dPrh = in7-&gt;huss(:,:,:)<br>
<br>
else<br>
<br>
dP = in1-&gt;pr(:,0,:,:)<br>
dPShift = in2-&gt;huss(:,0,:,:)<br>
dPtwrh = in5-&gt;huss(:,0,:,:)<br>
dPcross = in6-&gt;huss(:,0,:,:)<br>
dPT = in3-&gt;es2(:,0,:,:)<br>
dPweak = in4-&gt;huss(:,0,:,:)<br>
dPrh = in7-&gt;huss(:,0,:,:)<br>
<br>
end if<br>
<br>
&nbsp;&nbsp;&nbsp; ;Land mask<br>
<br>
&nbsp;&nbsp;&nbsp; b=addfile(&quot;$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc&quot;,&quot;r&quot;)<br>
&nbsp;&nbsp;&nbsp; lsm_dP = landsea_mask(b-&gt;LSMASK,dP&amp;lat,dP&amp;lon)&nbsp;&nbsp;&nbsp; ; read in land sea mask<br>
&nbsp;&nbsp;&nbsp; dP = mask(dP,lsm_dP.eq.0,False)&nbsp;&nbsp;&nbsp; ;mask out all ocean points)<br>
<br>
&nbsp;&nbsp;&nbsp; ;Drymask<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dP_dry = new ((/dimsizes(time),dimsizes(lat),dimsizes(lon)/), typeof(dP))<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dP_dry!0=&quot;time&quot;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dP_dry&amp;time=time<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dP_dry!1=&quot;lat&quot;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dP_dry&amp;lat=lat<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dP_dry!2=&quot;lon&quot;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dP_dry&amp;lon=lon<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; dP_dry = mask(dP,dP.gt.0, False)&nbsp; ; mask out all the wetting regions i.e. any values above 0 for dP<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; <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>
&nbsp;;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>
&nbsp;<br>
end <br>
</div>
<div><br>
</div>
<div>Any advice regarding this code would very much be appreciated.&nbsp;</div>
<div><br>
Kindest Regards<br>
Melissa<br>
</div>
<div><br>
</div>
</div>
</div>
</body>
</html>