! bn_agg_member_syntax

! *sh* 11/16

! running of this benchmark assumes that a tmp directory has been created 
! and that it contains the aggregation member files created by bn_aggregate_f


! define an 11-member FMRC aggregation
let files = SPAWN("ls -1 tmp/fcst_*.nc")
fmrc my_fmrc = files
show data/members my_fmrc   ! /FILES is deprecated

show data 12.3   ! turns out to be dset=5

! these are now all allowable references to the parent aggregation
stat fcst[d=12]
stat/br fcst[d=12.]
stat/br fcst[d=12.0]

! reference a member
stat fcst[d=12.3]
stat fcst[d=12.3] - fcst[d=5]   ! v-v=0

! note that FMRC members have distinct time axes. Specify "L=1"
stat fcst[d=12.3,l=1] - fcst[d=12.1,l=1]

! deliberate errors
set mode ignore

stat/br fcst[d=5.3]       ! d=5 is not an aggregation
stat/br fcst[d=12.30]     ! not this many members
stat/br fcst[d=12.300000]

set mode/last ignore

cancel data/all
cancel var/all

! Union datasets and SHOW DATA/MEMBERS
union tmp/uagg_1.nc,tmp/uagg_2.nc,tmp/uagg_3.nc,tmp/uagg_4.nc
show data/members
show data 5.2
show data 5.3

cancel data/all

! Tests for Ensembles
let files = SPAWN("ls -1 ens*.nc")
ensemble my_ens = files
sh data/members my_ens

show data 5.3
stat sst[d=5]
stat sst[d=5.2]

can data my_ens

! do them in another order
ENSEMBLE fourfiles = ens1, ens3, ens2, ens4

! not this is dataset 2
show data 5.3

stat sst[d=5] - sst[d=5.3]   ! ensemble minus member #3


! deliberate errors
set mode ignore

stat/br sst[d=4.1]     ! not an ensemble
stat/br sst[d=5.30]    ! not this many members

set mode/last ignore

