gen_refdata.sh 7.53 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
#!/bin/sh
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
3
CDO=cdo
Uwe Schulzweida's avatar
Uwe Schulzweida committed
4
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
5
6
FORMAT="-f srv -b F32"
########################################################################
Uwe Schulzweida's avatar
Uwe Schulzweida committed
7
#
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Timstat Yearstat Monstat Daystat Runstat
#
IFILE=$HOME/data/cdt/cera/EH5_AMIP_1_TSURF_6H_1991-1995.grb
OFILE=ts_6h_5years
$CDO $FORMAT remapnn,lon=55_lat=10 $IFILE $OFILE
#
IFILE=$OFILE
OFILE=ts_1d_5years
$CDO $FORMAT daymean $IFILE $OFILE
$CDO selmonth,1 -selyear,1991 $IFILE ts_6h_1mon
#
IFILE=$OFILE
OFILE=ts_mm_5years
$CDO $FORMAT -settime,12:00:00 -setday,15 -monmean $IFILE $OFILE
$CDO selyear,1991 $IFILE ts_1d_1year
#
STATS="min max sum avg mean std std1 var var1 range"
STATS="range"
#
IFILE=ts_mm_5years
28
29
30
for STAT in $STATS; do
  $CDO $FORMAT seas${STAT} $IFILE seas${STAT}_ref
done
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
#
IFILE=ts_mm_5years
#for STAT in $STATS; do
#  $CDO $FORMAT run${STAT},12 $IFILE run${STAT}_ref
#done
#
IFILE=ts_mm_5years
for STAT in $STATS; do
  $CDO $FORMAT tim$STAT $IFILE tim${STAT}_ref
done
#
IFILE=ts_mm_5years
for STAT in $STATS; do
  $CDO $FORMAT year$STAT $IFILE year${STAT}_ref
done
#
IFILE=ts_1d_1year
for STAT in $STATS; do
  $CDO $FORMAT mon$STAT $IFILE mon${STAT}_ref
done
#
IFILE=ts_6h_1mon
for STAT in $STATS; do
  $CDO $FORMAT day$STAT $IFILE day${STAT}_ref
done
exit
########################################################################
#
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
# Remap regional grid
#
GRID=spain.grid
cat > $GRID <<EOF
gridtype=lonlat
xsize=20
ysize=18
xfirst=-13
yfirst=33
xinc=.8
yinc=.8
EOF
RMODS="bil bic dis nn con ycon laf"
IFILE=tsurf_spain.grb
for RMOD in $RMODS; do
  OFILE=tsurf_spain_${RMOD}
  for extra in def off on; do
      EXTRA="$extra"
      if [ "$EXTRA" = "def" ]; then EXTRA=""; fi
      REMAP_EXTRAPOLATE=$EXTRA $CDO $FORMAT remap${RMOD},${GRID} $IFILE ${OFILE}_${extra}_ref
  done
done
exit
########################################################################
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
84
85
86
87
88
89
# EOF
#
export CDO_FILE_SUFFIX=NULL
#export CDO_SVD_MODE=danielson_lanczos
export CDO_WEIGHT_MODE=off
#
90
91
92
IFILE=psl_DJF_anom.grb
cdo $FORMAT eof,1 $IFILE eval_ref eof_ref
cdo $FORMAT eofcoeff eof_ref $IFILE pcoeff
Uwe Schulzweida's avatar
Uwe Schulzweida committed
93
94
95
exit
########################################################################
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
96
97
98
99
100
101
102
103
104
105
# Vertstat
#
STATS="min max sum avg mean std std1 var var1 int"
IFILE=pl_data.grb
for STAT in $STATS; do
  $CDO $FORMAT vert$STAT $IFILE vert${STAT}_ref
done
exit
########################################################################
#
106
107
108
109
110
111
112
113
114
115
116
117
# Comparision
#
STATS="eqc nec lec ltc gec gtc"
#
IFILE=comptest.srv
cdo $FORMAT copy t21_geosp_tsurf.grb $IFILE
for STAT in $STATS; do
  $CDO $FORMAT $STAT,300 $IFILE comp_${STAT}_ref
done
exit
########################################################################
#
118
119
120
121
122
123
124
125
126
127
# Ydrunstat
#
STATS="min max sum avg mean std std1 var var1"
#
IFILE=ts_mm_5years
for STAT in $STATS; do
  $CDO $FORMAT ydrun$STAT,8 $IFILE ydrun${STAT}_ref
done
########################################################################
#
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Ymonstat
#
STATS="min max sum avg mean std std1 var var1"
#
IFILE=ts_mm_5years
for STAT in $STATS; do
  $CDO $FORMAT ymon$STAT $IFILE ymon${STAT}_ref
done
#
IFILE=ts_mm_5years
for STAT in $STATS; do
  $CDO $FORMAT yseas$STAT $IFILE yseas${STAT}_ref
done
########################################################################
#
143
144
# Zonstat
#
145
STATS="min max sum avg mean std std1 var var1 range"
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
IFILE=t21_geosp_tsurf.grb
for STAT in $STATS; do
  $CDO $FORMAT zon$STAT $IFILE zon${STAT}_ref
done
exit
########################################################################
#
# Merstat
#
STATS="min max sum avg mean std std1 var var1"
IFILE=t21_geosp_tsurf.grb
for STAT in $STATS; do
  $CDO $FORMAT mer$STAT $IFILE mer${STAT}_ref
done
exit
########################################################################
#
163
164
165
166
167
168
169
170
171
172
173
174
175
# MapReduce
#
for grid  in r18x9 icon_cell; do
  REFGRID="${grid}_grid"
  $CDO -f nc -temp,$REFGRID data_${grid}.nc
  $CDO -f nc -gtc,273.15 -temp,$REFGRID mask_${grid}.nc
  $CDO -f nc reducegrid,mask_${grid}.nc data_${grid}.nc reduced_${grid}.nc
  $CDO griddes reduced_${grid}.nc > griddes.${grid}
  rm -f data_${grid}.nc mask_${grid}.nc reduced_${grid}.nc
done
exit
########################################################################
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
176
177
178
179
180
181
182
183
184
185
# Arith
#
IFILE=arith1.srv
MASK=arithmask.srv
OPS="add sub mul div"
for OP in $OPS; do
  $CDO $FORMAT $OP $IFILE $MASK arith${OP}_ref
done
exit
########################################################################
Uwe Schulzweida's avatar
Uwe Schulzweida committed
186
#
187
188
189
190
191
192
193
194
195
196
197
198
199
# Fldpctl
#
IFILE=t21_geosp_tsurf.grb
PCTLS="1 20 25 33 50 66 75 80 99 100"
for PCTL in $PCTLS; do
  $CDO $FORMAT fldpctl,$PCTL $IFILE fldpctl${PCTL}_ref
done
rm -f $IFILE
exit
########################################################################
#
# Fldstat
#
200
STATS="min max sum avg mean std std1 var var1 range"
201
202
203
204
205
206
207
IFILE=t21_geosp_tsurf.grb
for STAT in $STATS; do
  $CDO $FORMAT fld$STAT $IFILE fld${STAT}_ref
done
exit
########################################################################
#
208
209
# Enspctl
#
210
IFILE=ts_mm_5year
211
212
213
214
215
216
217
218
219
220
221
export CDO_FILE_SUFFIX=NULL
$CDO splityear $IFILE ts_year
IFILE="ts_year????"
PCTLS="1 20 25 33 50 66 75 80 99 100"
for PCTL in $PCTLS; do
  $CDO $FORMAT enspctl,$PCTL $IFILE enspctl${PCTL}_ref
done
rm -f $IFILE
exit
########################################################################
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
222
223
224
# Test File
#
$CDO $FORMAT cdiwrite,1,global_10,3,3,3 file_F32_srv_ref
Uwe Schulzweida's avatar
Uwe Schulzweida committed
225
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
226
227
########################################################################
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
228
229
230
231
232
233
234
235
236
237
238
239
240
# Test GRIB files
#
IFILES="testfile01 testfile02"
for FILE in $IFILES; do
  IFILE=grib_${FILE}.grb
  OFILE=grib_${FILE}_sinfon_ref
  $CDO sinfo $IFILE > $OFILE
  OFILE=grib_${FILE}_infon_ref
  $CDO info $IFILE > $OFILE
done
#
########################################################################
#
241
242
# Test netCDF files
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
243
IFILES="testfile01 testfile02"
244
245
for FILE in $IFILES; do
  IFILE=netcdf_${FILE}.nc
Uwe Schulzweida's avatar
Uwe Schulzweida committed
246
247
248
249
  OFILE=netcdf_${FILE}_sinfon_ref
  $CDO sinfon $IFILE > $OFILE
  OFILE=netcdf_${FILE}_infon_ref
  $CDO infon $IFILE > $OFILE
250
done
251
exit
252
253
########################################################################
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
254
255
# Vertint
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
256
257
258
259
260
261
IFILE=ECHAM5_T21L19monavg.grb
OFILE=hl_l19.grb
$CDO fldmean -sp2gp -selcode,129,130,152 $IFILE $OFILE
IFILE=$OFILE
OFILE=ml2pl_ref
$CDO $FORMAT ml2pl,92500,85000,50000,20000 $IFILE $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
262
########################################################################
Uwe Schulzweida's avatar
Uwe Schulzweida committed
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#
# Spectral
#
IFILE=ECHAM5_T21L19monavg.grb
OFILE=t21_geosp_tsurf.grb
$CDO selname,geosp,tsurf $IFILE $OFILE
#
IFILE=$OFILE
OFILE=gp2sp_ref
$CDO gp2sp $IFILE $OFILE
OFILE=gp2spl_ref
$CDO gp2spl $IFILE $OFILE
IFILE=gp2sp_ref
OFILE=sp2gp_ref
$CDO sp2gp $IFILE $OFILE
IFILE=gp2spl_ref
OFILE=sp2gpl_ref
$CDO sp2gpl $IFILE $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
281
282
283
284
285
286
287
########################################################################
#
# Remap
#
cdo -f grb setrtomiss,0,10000  -gridboxmean,8,8 -topo bathy4.grb
#
GRIDS="n16 n32"
288
RMODS="bil bic dis nn con laf"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
289
290
291
292
293
294
295
296
IFILE=bathy4.grb
for GRID in $GRIDS; do
  for RMOD in $RMODS; do
    OFILE=${GRID}_${RMOD}
    $CDO $FORMAT remap${RMOD},$GRID $IFILE ${OFILE}_ref
  done
done
########################################################################
Uwe Schulzweida's avatar
Uwe Schulzweida committed
297
298
299
300
301
302
303
304
#
# Select
#
IFILE=ECHAM5_T21L19.grb
OFILE=pl_data.grb
$CDO -ml2pl,90000,9000,900,90 -remapbil,global_30 -sp2gp -seltimestep,1/5 -dayavg -selcode,129,130,152 $IFILE $OFILE
IFILE=$OFILE
OFILE=select1_ref
305
$CDO select,code=130,152 $IFILE $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
306
OFILE=select2_ref
307
$CDO select,code=130,152,level=9000,90 $IFILE $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
308
OFILE=select3_ref
309
$CDO select,code=130,152,level=9000,90,timestep=2,3,5 $IFILE $OFILE
310
311
312
313
OFILE=select4_ref
$CDO select,code=130 $IFILE $OFILE
OFILE=select5_ref
$CDO select,level=90000 $IFILE $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
314
########################################################################
Uwe Schulzweida's avatar
Uwe Schulzweida committed
315
316
317
318
319
320
321
322
323
#
# Detrend
#
OFILE=detrend_data
$CDO $FORMAT -sqr -for,1,100 $OFILE
IFILE=$OFILE
OFILE=detrend_ref
$CDO detrend $IFILE $OFILE
########################################################################