-
Notifications
You must be signed in to change notification settings - Fork 3
/
gen_calc_ens_avg.sh
executable file
·72 lines (67 loc) · 2.3 KB
/
gen_calc_ens_avg.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
#$ -cwd
#$ -j y
#$ -S /bin/bash
#$ -q default.q
#$ -N ensavg_allvars
variables="SWE tasmin tasmax TotalSoilMoist pr petNatVeg petShort petTall Transp Evaporation"
#variables="tasmax tasmin pr"
basin="california whites northernrockies southernrockies cascades"
scenario="historical rcp45 rcp85"
models="NorESM1-M CNRM-CM5 CSIRO-Mk3-6-0 CanESM2 MIROC5 bcc-csm1-1-m HadGEM2-CC365 HadGEM2-ES365 CCSM4 IPSL-CM5A-MR"
arr_mod=($models)
arr_bas=($basin)
arr_sc=($scenario)
arr_vars=($variables)
sm_month="march"
## loop over models
## for var in 0 1 2
for var in 0 1 2 3 4 5 6 7 8 9
#for var in 0 1 2
do
#### format of filename depends on which variable it is
if [ "SWE" = "${arr_vars[$var]}" ]
then
timecalc="monday1"
elif [ "TotalSoilMoist" = "${arr_vars[$var]}" ]
then
timecalc="monday1"
elif [ "pr" = "${arr_vars[$var]}" ] || [ "PET_NatVeg" = "${arr_vars[$var]}" ] || [ "PET_Short" = "${arr_vars[$var]}" ] || [ "PET_Tall" = "${arr_vars[$var]}" ] || [ "Transp" = "${arr_vars[$var]}" ] || [ "Evaporation" = "${arr_vars[$var]}" ]
then
timecalc="monsum"
else
timecalc="monmean"
fi
for bas in 0 1 2 3 4
do
for scen in 0 1 2
do
#### and which scenario it is
if [ "historical" = "${arr_sc[$scen]}" ]
then
years="1950_2005"
else
years="2006_2099"
fi
for i in 0 1 2 3 4 5 6 7 8 9
do
if [ "TotalSoilMoist" = "${arr_vars[$var]}" ]
then
eval "ifile${i}="/raid9/gergel/agg_snowpack/goodleap/${arr_bas[$bas]}/${arr_mod[$i]}__${arr_sc[$scen]}.${timecalc}.${arr_vars[$var]}.${years}_${arr_bas[$bas]}_${sm_month}.nc""
else
eval "ifile${i}="/raid9/gergel/agg_snowpack/goodleap/${arr_bas[$bas]}/${arr_mod[$i]}__${arr_sc[$scen]}.${timecalc}.${arr_vars[$var]}.${years}_${arr_bas[$bas]}.nc""
fi
done
if [ "TotalSoilMoist" = "${arr_vars[$var]}" ]
then
ofile="/raid9/gergel/agg_snowpack/goodleap/${arr_bas[$bas]}/${arr_vars[$var]}_ensavg_${arr_sc[$scen]}_${arr_bas[$bas]}_${sm_month}.nc"
else
ofile="/raid9/gergel/agg_snowpack/goodleap/${arr_bas[$bas]}/${arr_vars[$var]}_ensavg_${arr_sc[$scen]}_${arr_bas[$bas]}.nc"
fi
## calculate ensemble mean
echo "now calculating ensemble average for ${arr_vars[$var]} ${arr_bas[$bas]} ${arr_sc[$scen]}"
cdo ensmean $ifile0 $ifile1 $ifile2 $ifile3 $ifile4 $ifile5 $ifile6 $ifile7 $ifile8 $ifile9 $ofile
done
done
done