[ncl-talk] generate_sample_indices without replacement
Sri nandini
bax8609 at uni-hamburg.de
Thu Feb 17 06:27:59 MST 2022
Hello dear ncl-users,
I would like to know how to properly code for selecting 40 random
ensemble from a 100 ensembles of my data.
I wonder if someone could help me with this code? My original data is
[time | 240] x [ens | 100] x [lat | 180] x [lon | 360]
f = addfile ("temperature_data.nc", "r")
T2m = f->temp
printVarSummary(T2m)
dimx = dimsizes(T2m)
ntim = dimx(0) ; 240- time dimension
nens = dimx(1) ; 100- ensemble dimension
nlat = dimx(2) ; 180- lat
mlon = dimx(3) ; 360- lon
T2m at _FillValue = -9.96921e+36
; randomly select 40 members from 100 members without replacement
; define a new variable dimensions
n=40
rcp_40=new((/ntim,n,nlat,mlon/),typeof(rcp45_anom))
copy_VarCoords(rcp45_anom(:,0,:,:),rcp_40(:,0,:,:)) ; Copy metadata
printVarSummary(rcp_40) ==>Dimensions and sizes: [time | 240] x
[40] x [lat | 180] x [lon | 360]
Coordinates:
time: [1192152..1366728]
lat: [-89.5..89.5]
lon: [ 0.. 359]
do j= 0,n-1
iwo = generate_sample_indices( n, 0 )
rcp_40(:,j,:,:) = T2m(:,iwo,:,:) ====>error here fatal:VarVarWrite:
Number of dimensions on left hand side does not match right hand side
end do
printVarSummary(rcp_40)
Could someone help me in this code?
Best
Sri
More information about the ncl-talk
mailing list