forked from BrunoCombal/climate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·218 lines (182 loc) · 6.8 KB
/
run.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
# \author Bruno Combal
# \date November 2013
# a series of function to call the different climate processing
# caution: this script is giving as an example, there is no input parameters tests.
# Read carefuly before using.
# _________________________________
# \brief compute warm pool
function wp(){
bindir=${HOME}/github/climate
startYear=$1
endYear=$2
rcpCode=$3
#sstdir='/data/tmp/new_algo/tos_rcp85'
sstdir="/data/tmp/new_algo/tos_rcp${rcpCode}5"
#sstdirHist='/data/cmip5/rcp/rcp8.5/toshist_ensemble'
outdir="/data/cmip5/rcp/rcp${rcpCode}.5/tos_warmpools"
mkdir -p ${outdir}
basename="ensemble_tos_rcp${rcpCode}5"
${bindir}/make_warmpool.py -indir ${sstdir} -var 'mean_mean_tos' -fileBasename ${basename} -start ${startYear} -end ${endYear} -bounds 70 580 -outdir ${outdir}
}
# _________________________________
# \brief Computes tos ensemble means
# $1 decade
# $2 rcp85, rcp45
function omlmaxEM(){
decade=$1
rcp=$2
var=omlmax
if [ ${rcp} = 'rcp85' ]; then
rcp=rcp85
indir=/datater/cmip5/rcp/rcp8.5/${var}/
model=${indir}/modellist_omlmax.txt
elif [ ${rcp} = 'rcp45' ]; then
rcp=rcp45
echo "rcp 4.5 has not been expected. Exit."
exit 1
else
echo "Function omlmaxEM: wrong input parameter '$2'="${rcp}". Exit(1)."
exit 1
fi
if [ ! -e ${model} ]; then
ls ${model}
echo "List of models does not exist ($model). Exit 2."
exit 2
fi
outdir=/datater/tmp/new_algo/${var}_${rcp}
tmpdir=/datater/tmp/new_algo/tmp_${var}_${rcp}
mkdir -p ${outdir}
mkdir -p ${tmpdir}
bindir=${HOME}/github/climate/
dStart=${decade}
dEnd=$((decade + 3))
echo "Processing ensembleMean from "${dStart}" to "${dEnd}
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -rcp ${rcp}
dStart=$((dEnd + 1))
dEnd=$((dStart + 3))
echo "Processing ensembleMean from "${dStart}" to "${dEnd}
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -rcp ${rcp}
dStart=$((dEnd + 1))
dEnd=$((decade + 9))
echo "Processing ensembleMean from "${dStart}" to "${dEnd}
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -rcp ${rcp}
}
# ________________________________
# \brief compute TOS ensemble mean
function tosEM(){
decade=$1
rcp=$2
var=tos
if [ ${rcp} = 'rcp85' ]; then
rcp=rcp85
model=modellist_tos.txt
indir=/data/cmip5/rcp/rcp8.5/tos/
elif [ ${rcp} = 'rcp45' ]; then
rcp=rcp45
model=modellist_tos45.txt
indir=/databis/cmip5_bis/rcp/rcp4.5/tos/
else
echo "Function tosEM: wrong input parameter '$2'="${rcp}". Exit(1)."
exit 1
fi
if [ ! -e "${model}" ] ; then
echo "Missing model list file "${model}" Exit(1)."
exit 1
fi
outdir=/data/tmp/new_algo/${var}_${rcp}
tmpdir=/data/tmp/new_algo/tmp_${var}_${rcp}
mkdir -p ${outdir}
mkdir -p ${tmpdir}
bindir='./'
dStart=${decade}
dEnd=$((decade + 3))
echo "Processing ensembleMean from "${dStart}" to "${dEnd}
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -rcp ${rcp}
dStart=$((dEnd + 1))
dEnd=$((dStart + 3))
echo "Processing ensembleMean from "${dStart}" to "${dEnd}
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -rcp ${rcp}
dStart=$((dEnd + 1))
dEnd=$((decade + 9))
echo "Processing ensembleMean from "${dStart}" to "${dEnd}
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -rcp ${rcp}
# produce some extra month for DHM 4 months rolling window
dStart=$((decade - 1))
dEnd=$((decade - 1))
${bindir}/make_ensembleMean_tyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear ${dStart} -endYear ${dEnd} -monthlist '10,11,12' -rcp ${rcp}
}
# ____________________________________
# \brief Computes thetao ensemble means
function thetaoEM(){
rcp=rcp85 #rcp45
model=modellist_thetao_rcp85_test.txt
var=thetao
indir=/databis/cmip5_bis/rcp/rcp8.5/thetao
outdir=/data/tmp/new_algo/${var}_${rcp}
tmpdir=/data/tmp/new_algo/tmp_${var}_${rcp}
bindir='./'
${bindir}/make_ensembleMean_tzyx.py -v ${var} -path ${indir} -outdir ${outdir} -minVar 263 -maxVar 320 -modelList ${model} -startYear 2030 -endYear 2031 -rcp ${rcp} -resolution 1
}
# _____________________________________
# \brief Computes DHM (degree heating month)
function dhm(){
outdir='/data/tmp/new_algo/dhm_rcp'${2}'/'
indir='/data/tmp/new_algo/tos_'${2}
inpref='ensemble_tos_'${2}'_'
variable='mean_mean_tos'
decad=$1
climDir='/data/sst/reynolds_climatology/noaa_oist_v2/resized_fitted/sst.ltm.1971-2000_resized.nc'
maxRealClim='/data/sst/reynolds_climatology/noaa_oist_v2/resized_fitted/max_sst.ltm.1971-2000_resized.nc'
rmsAtMaxClim='/data/sst/reynolds_climatology/noaa_oist_v2/resized_fitted/rms_at_maxsst_resized.nc'
modelClimDir='/data/cmip5/rcp/toshist_ensemble/'
modelClim='climato_tos_1971_2000_'
bindir='./'
${bindir}/make_dhm.py -o ${outdir} -in ${indir} ${inpref} -var ${variable} -decad ${decad} -clim ${climDir} ${maxRealClim} ${rmsAtMaxClim} -modelClim ${modelClimDir} ${modelClim}
}
# ___________________________________________
# \brief computes model trends
# $1: variable, eg. 'tos'
# $2: trendType, eg. 'esm'
function trends(){
variable=$1
trendType=$2
indir='/data/cmip5/rcp/tos_controlrun'
modelList=${indir}/lst_${variable}_ctrlrun_${trendType}_edited.txt
outdir=/data/tmp/new_algo/control_run/${tos}_${trendType}
degree=1
./make_modelTrend.py -deg 1 -o ${outdir} -p $indir -v ${variable} -trendType ${trendType} -modellist ${modelList} -annualAVG yes
}
# ___________________________________________
# \brief Main
# use thise section to call the functions
# uv-cdat library must first be sourced
source /usr/local/uvcdat/1.2.0/bin/setup_cdat.sh
wp 2010 2059 8
#for ii in $(seq 2010 10 2080 )
#do
# omlmaxEM $ii rcp85
#done
#trends 'tos' 'esm'
#tosEM 2010 rcp85
#dhm 2010 rcp85
#tosEM 2020 rcp85
#dhm 2020 rcp85
#tosEM 2030 rcp85
#tosEM 2040 rcp85
#dhm 2040 rcp85
#tosEM 2010 rcp45
#dhm 2010 rcp45
#tosEM 2020 rcp45
#dhm 2020 rcp45
#tosEM 2030 rcp45
#tosEM 2040 rcp45
#tosEM 2050 rcp45
#dhm 2030 rcp85
#dhm 2040 rcp85
#dhm 2050 rcp85
#dhm 2030 rcp45
#dhm 2040 rcp45
#dhm 2050 rcp45
#thetaoEM
# end of script