<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">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;">Hi<br>
<br>
I have managed to sub-sample 39 models using the generate_sample_indices function.<br>
<br>
I just have a question about how I can do 50 iterations of this to obtain different models for each time I sub-sample.<br>
<br>
I think I need to use a do loop but I am not sure as to what the syntax should be in my code as I have a loop already to loop through the different number of models I sub-sample.<br>
<br>
Below is my code currently that is working for just 1 iteration.<br>
<br>
I have commented out the attempt at adding the addition iterations loop.<br>
<br>
Many thanks!<br>
<br>
Kind Regards<br>
Melissa<br>
<br>
; ==============================================================<br>
; sub-sampling_1.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>
load "./generate_sample_indices.ncl"<br>
<br>
begin<br>
<br>
model = (/"ACCESS1-0", "ACCESS1-3", "bcc-csm1-1", "CanESM2", "CCSM4", "CESM1-BGC", "CESM1-CAM5", "CMCC-CM", "CMCC-CMS", "CNRM-CM5", "CSIRO-Mk3-6-0", "EC-EARTH", "FGOALS-g2", "FIO-ESM","GFDL-CM3", "GFDL-ESM2G", "GFDL-ESM2M", "GISS-E2-H_p1", "GISS-E2-H_p2", "GISS-E2-H_p3",
"GISS-E2-R_p1", "GISS-E2-R_p2", "GISS-E2-R_p3", "HadGEM2-AO", "HadGEM2-CC", "HadGEM2-ES", "inmcm4", "IPSL-CM5A-LR", "IPSL-CM5A-MR", "IPSL-CM5B-LR","MIROC5", "MPI-ESM-LR", "MPI-ESM-MR", "MRI-CGCM3", "NorESM1-ME", "NorESM1-M"/)<br>
<br>
nmodels = (/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39/)<br>
<br>
samplesize = (/5,10,15,20,25,30,35/)<br>
ntimes = 50<br>
<br>
<br>
printVarSummary(samplesize)<br>
<br>
Smean = new(7,"float")<br>
Stdand = new(7,"float")<br>
Srange = new(7,"float")<br>
S25 = new(7,"float")<br>
S75 = new(7,"float")<br>
Smedian = new(7,"float")<br>
;stat = new(7,"float")<br>
<br>
dPDJF = asciiread("pr_ens_percent_change_boxplot_DJF.txt",39,"float")<br>
<br>
printVarSummary(dPDJF) <br>
print(dPDJF) ; Print the values<br>
<br>
;do it=0, ntimes-1<br>
do ni=0,6<br>
<br>
sdPDJF = dPDJF(generate_sample_indices(samplesize(ni),0))<br>
<br>
dimt = dimsizes(sdPDJF) ; should be 5,10,15,20,25,30,35<br>
x25 = round(.25*dimt,3)-1 ; -1 to account for NCL indexing starting<br>
x75 = round(.75*dimt,3)-1 ; at 0 <br>
<br>
printVarSummary(sdPDJF)<br>
<br>
;opt = True<br>
;opt@PrintStat = True<br>
<br>
;stat(ni) = stat_dispersion(sdPDJF,opt)<br>
<br>
Smean(ni) = avg(sdPDJF)<br>
Stdand(ni) = stddev(sdPDJF)<br>
Srange(ni) = max(sdPDJF)-min(sdPDJF) <br>
S25(ni) = sdPDJF(x25) <br>
S75(ni) = sdPDJF(x75)<br>
Smedian(ni) = dim_median(sdPDJF) <br>
<br>
<br>
print(Smean)<br>
print(Stdand)<br>
print(Srange)<br>
print(S25)<br>
print(S75)<br>
print(Smedian)<br>
<br>
delete(sdPDJF)<br>
<br>
end do<br>
;end do<br>
end<br>
</div>
</body>
</html>