forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexgdas_atmos_verfrad.sh
executable file
·165 lines (130 loc) · 5.12 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
#! /usr/bin/env bash
source "${USHgfs}/preamble.sh"
################################################################################
#### 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
#
################################################################################
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.${PDY}${cyc}"
${NCP} "${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_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
type_count=$(echo "${SATYPE}" | grep "${type}" | wc -l)
if (( type_count == 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 == 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
if [[ $(find . -maxdepth 1 -type f -name "diag_${type}_anl.${PDY}${cyc}*.${Z}" | wc -l) -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"
rc_angle=$?
"${USHgfs}/radmon_verf_bcoef.sh"
rc_bcoef=$?
"${USHgfs}/radmon_verf_bcor.sh"
rc_bcor=$?
"${USHgfs}/radmon_verf_time.sh"
rc_time=$?
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}