forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexgdas_atmos_verfrad.sh
More file actions
executable file
·171 lines (138 loc) · 5.29 KB
/
exgdas_atmos_verfrad.sh
File metadata and controls
executable file
·171 lines (138 loc) · 5.29 KB
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
#! /usr/bin/env bash
################################################################################
#### UNIX Script Documentation Block
# . .
# Script name: exgdas_atmos_verfrad.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
#
################################################################################
# Do not exit on errors so that restricted data can be protected
unset_strict
if [[ ! -s "${radstat}" || ! -s "${biascr}" ]]; then
export err=1
err_exit "Required data files ${radstat} and/or ${biascr} are missing!!"
fi
#------------------------------------------------------------------
# Copy data files file to local data directory.
# Untar radstat file.
#------------------------------------------------------------------
cpreq "${biascr}" "./biascr.${PDY}${cyc}"
cpreq "${radstat}" "./radstat.${PDY}${cyc}"
tar -xvf "radstat.${PDY}${cyc}"
rm "radstat.${PDY}${cyc}"
#------------------------------------------------------------------
# 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 gdas fix 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_files=$(find ./ -name 'd*ges*')
radstat_satype=$(awk -F_ '{ print $2 "_" $3 }' <<< "${radstat_files}")
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
export use_tankdir
echo satype_file = "${satype_file}"
SATYPE=$(cat "${satype_file}")
export SATYPE
#-------------------------------------------------------------
# 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
type_count=$(grep -c "${type}" <<< "${SATYPE}")
if [[ ${type_count} -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
if [[ ${satype_changes} -eq 1 ]]; then
SATYPE=${new_satype}
fi
#------------------------------------------------------------------
# Rename the diag files and uncompress
#------------------------------------------------------------------
netcdf=0
for type in ${SATYPE}; do
if [[ ${netcdf} -eq 0 && -e "diag_${type}_ges.${PDY}${cyc}.nc4.${Z}" ]]; then
netcdf=1
fi
if [[ $(find . -maxdepth 1 -type f -name "diag_${type}_ges.${PDY}${cyc}*.${Z}" | wc -l) -gt 0 ]]; then
mv "diag_${type}_ges.${PDY}${cyc}"*".${Z}" "${type}.${Z}"
${UNCOMPRESS} "./${type}.${Z}"
else
echo "WARNING: diag_${type}_ges.${PDY}${cyc}*.${Z} not available, skipping"
fi
if [[ ${USE_ANL} -eq 1 ]]; then
file_count=$(find . -maxdepth 1 -type f -name "diag_${type}_anl.${PDY}${cyc}*.${Z}" | wc -l)
if [[ ${file_count} -gt 0 ]]; then
mv "diag_${type}_anl.${PDY}${cyc}"*".${Z}" "${type}_anl.${Z}"
${UNCOMPRESS} "./${type}_anl.${Z}"
else
echo "WARNING: diag_${type}_anl.${PDY}${cyc}*.${Z} not available, skipping"
fi
fi
done
export RADMON_NETCDF=${netcdf}
#------------------------------------------------------------------
# Run the child scripts.
#------------------------------------------------------------------
"${USHgfs}/radmon_verf_angle.sh" && true
rc_angle=$?
"${USHgfs}/rstprod.sh"
# Allow all scripts to run. Call err_exit at the end, after files are restricted.
if [[ ${rc_angle} -ne 0 ]]; then
echo "FATAL ERROR: radmon_verf_angle.sh failed!"
fi
"${USHgfs}/radmon_verf_bcoef.sh" && true
rc_bcoef=$?
"${USHgfs}/rstprod.sh"
if [[ ${rc_bcoef} -ne 0 ]]; then
echo "FATAL ERROR: radmon_verf_bcoef.sh failed!"
fi
"${USHgfs}/radmon_verf_bcor.sh" && true
rc_bcor=$?
"${USHgfs}/rstprod.sh"
if [[ ${rc_bcoef} -ne 0 ]]; then
echo "FATAL ERROR: radmon_verf_bcor.sh failed!"
fi
"${USHgfs}/radmon_verf_time.sh" && true
rc_time=$?
"${USHgfs}/rstprod.sh"
if [[ ${rc_bcoef} -ne 0 ]]; then
echo "FATAL ERROR: radmon_verf_time.sh failed!"
fi
#####################################################################
# Error handling
export err=$((rc_angle + rc_bcoef + rc_bcor + rc_time))
if [[ ${err} -ne 0 ]]; then
err_exit "One or more radiance monitor subtasks failed!"
fi
exit 0