-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathexgdas_atmos_verfrad.sh
executable file
·211 lines (170 loc) · 6.28 KB
/
exgdas_atmos_verfrad.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
#! /usr/bin/env bash
source "$HOMEgfs/ush/preamble.sh"
################################################################################
#### UNIX Script Documentation Block
# . .
# Script name: exgdas_vrfyrad.sh
# Script description: Runs data extract/validation for global radiance diag data
#
# Author: Ed Safford Org: NP23 Date: 2012-01-18
#
# Abstract: This script runs the data extract/validation portion of the
# RadMon package.
#
# Condition codes
# 0 - no problem encountered
# >0 - some problem encountered
#
################################################################################
export VERBOSE=${VERBOSE:-YES}
export NET=${NET:-gfs}
export RUN=${RUN:-gdas}
export envir=${envir:-prod}
# Filenames
biascr=${biascr:-${COM_ATMOS_ANALYSIS}/gdas.t${cyc}z.abias}
radstat=${radstat:-${COM_ATMOS_ANALYSIS}/gdas.t${cyc}z.radstat}
satype_file=${satype_file:-${FIXgdas}/gdas_radmon_satype.txt}
# Other variables
export RAD_AREA=${RAD_AREA:-glb}
export MAKE_CTL=${MAKE_CTL:-1}
export MAKE_DATA=${MAKE_DATA:-1}
export USE_ANL=${USE_ANL:-1}
export PDATE=${PDY}${cyc}
export DO_DIAG_RPT=${DO_DIAG_RPT:-1}
export DO_DATA_RPT=${DO_DATA_RPT:-1}
export NCP=${NCP:-/bin/cp}
###########################################################################
# ensure TANK dir exists, verify radstat and biascr are available
#
if [[ ! -d ${TANKverf_rad} ]]; then
mkdir -p $TANKverf_rad
fi
if [[ "$VERBOSE" = "YES" ]]; then
if [[ -s ${radstat} ]]; then
echo ${radstat} is available
fi
if [[ -s ${biascr} ]]; then
echo ${biascr} is available
fi
fi
#####################################################################
data_available=0
if [[ -s ${radstat} && -s ${biascr} ]]; then
data_available=1
#------------------------------------------------------------------
# Copy data files file to local data directory.
# Untar radstat file.
#------------------------------------------------------------------
$NCP $biascr ./biascr.$PDATE
$NCP $radstat ./radstat.$PDATE
tar -xvf radstat.$PDATE
rm radstat.$PDATE
#------------------------------------------------------------------
# SATYPE is the list of expected satellite/instrument sources
# in the radstat file. It should be stored in the $TANKverf
# directory. If it isn't there then use the $FIXgdas copy. In all
# cases write it back out to the radmon.$PDY directory. Add any
# new sources to the list before writing back out.
#------------------------------------------------------------------
radstat_satype=$(ls d*ges* | awk -F_ '{ print $2 "_" $3 }')
if [[ "$VERBOSE" = "YES" ]]; then
echo $radstat_satype
fi
echo satype_file = $satype_file
#------------------------------------------------------------------
# Get previous cycle's date, and look for the satype_file. Using
# the previous cycle will get us the previous day's directory if
# the cycle being processed is 00z.
#------------------------------------------------------------------
if [[ $cyc = "00" ]]; then
use_tankdir=${TANKverf_radM1}
else
use_tankdir=${TANKverf_rad}
fi
echo satype_file = $satype_file
export SATYPE=$(cat ${satype_file})
#-------------------------------------------------------------
# Update the SATYPE if any new sat/instrument was
# found in $radstat_satype. Write the SATYPE contents back
# to $TANKverf/radmon.$PDY.
#-------------------------------------------------------------
satype_changes=0
new_satype=$SATYPE
for type in ${radstat_satype}; do
test=$(echo $SATYPE | grep $type | wc -l)
if [[ $test -eq 0 ]]; then
if [[ "$VERBOSE" = "YES" ]]; then
echo "Found $type in radstat file but not in SATYPE list. Adding it now."
fi
satype_changes=1
new_satype="$new_satype $type"
fi
done
#------------------------------------------------------------------
# Rename the diag files and uncompress
#------------------------------------------------------------------
netcdf=0
for type in ${SATYPE}; do
if [[ netcdf -eq 0 && -e diag_${type}_ges.${PDATE}.nc4.${Z} ]]; then
netcdf=1
fi
if [[ $(find . -maxdepth 1 -type f -name "diag_${type}_ges.${PDATE}*.${Z}" | wc -l) -gt 0 ]]; then
mv diag_${type}_ges.${PDATE}*.${Z} ${type}.${Z}
${UNCOMPRESS} ./${type}.${Z}
else
echo "WARNING: diag_${type}_ges.${PDATE}*.${Z} not available, skipping"
fi
if [[ $USE_ANL -eq 1 ]]; then
if [[ $(find . -maxdepth 1 -type f -name "diag_${type}_anl.${PDATE}*.${Z}" | wc -l) -gt 0 ]]; then
mv diag_${type}_anl.${PDATE}*.${Z} ${type}_anl.${Z}
${UNCOMPRESS} ./${type}_anl.${Z}
else
echo "WARNING: diag_${type}_anl.${PDATE}*.${Z} not available, skipping"
fi
fi
done
export RADMON_NETCDF=$netcdf
#------------------------------------------------------------------
# Run the child sccripts.
#------------------------------------------------------------------
${USHradmon}/radmon_verf_angle.sh ${PDATE}
rc_angle=$?
${USHradmon}/radmon_verf_bcoef.sh ${PDATE}
rc_bcoef=$?
${USHradmon}/radmon_verf_bcor.sh "${PDATE}"
rc_bcor=$?
${USHradmon}/radmon_verf_time.sh "${PDATE}"
rc_time=$?
#--------------------------------------
# optionally run clean_tankdir script
#
if [[ ${CLEAN_TANKVERF:-0} -eq 1 ]]; then
"${USHradmon}/clean_tankdir.sh" glb 60
rc_clean_tankdir=$?
echo "rc_clean_tankdir = $rc_clean_tankdir"
fi
fi
#####################################################################
# Postprocessing
err=0
if [[ ${data_available} -ne 1 ]]; then
err=1
elif [[ $rc_angle -ne 0 ]]; then
err=$rc_angle
elif [[ $rc_bcoef -ne 0 ]]; then
err=$rc_bcoef
elif [[ $rc_bcor -ne 0 ]]; then
err=$rc_bcor
elif [[ $rc_time -ne 0 ]]; then
err=$rc_time
fi
#####################################################################
# Restrict select sensors and satellites
export CHGRP_CMD=${CHGRP_CMD:-"chgrp ${group_name:-rstprod}"}
rlist="saphir"
for rtype in $rlist; do
if compgen -G "$TANKverf_rad/*${rtype}*" > /dev/null; then
${CHGRP_CMD} "${TANKverf_rad}"/*${rtype}*
fi
done
exit ${err}