-
Notifications
You must be signed in to change notification settings - Fork 1
/
getawsobs.sh
223 lines (220 loc) · 9.58 KB
/
getawsobs.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
219
220
221
222
223
obtyp_default="all"
YYYYMMDDHH=${1:-$analdate}
OUTPATH=${2:-$obs_datapath}
obtyp=${3:-$obtyp_default} # specify single ob type, default is all obs.
nbackmax=${nbackmax:-10}
dryrun=${dryrun:="false"} # if "true", just print aws download command, check to see if file exists on aws
which aws
if [ $? -ne 0 ]; then
echo "SLURM_CLUSTER_NAME=$SLURM_CLUSTER_NAME machine=${machine}"
if [ $SLURM_CLUSTER_NAME == 'es' ]; then
if [ $machine == "gaeac5" ]; then
module use /ncrc/proj/epic/spack-stack/spack-stack-1.6.0/envs/unified-env/install/modulefiles/Core
elif [ $machine == "gaeac6" ]; then
module use /ncrc/proj/epic/spack-stack/c6/spack-stack-1.6.0/envs/unified-env/install/modulefiles/Core
fi
module load stack-intel
module load awscli-v2
elif [ $SLURM_CLUSTER_NAME == 'hercules' ]; then
module purge
module use /work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.6.0/envs/unified-env/install/modulefiles/Core
module load stack-intel/2021.9.0
module load awscli-v2
elif [ $SLURM_CLUSTER_NAME == 'hera' ]; then
module purge
module use /scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.6.0/envs/unified-env-rocky8/install/modulefiles/Core
module load stack-intel/2021.5.0
module load awscli-v2
else
echo "cluster must be 'hera', 'hercules' or 'es' (gaea)"
exit 1
fi
fi
which aws
if [ $? -ne 0 ]; then
echo "awscli not found"
exit 1
fi
NNJA_PRVIATE_PROFILE=nnja-private-eumetsat-read
YYYYMM=`echo $YYYYMMDDHH | cut -c1-6`
YYYYMMDD=`echo $YYYYMMDDHH | cut -c1-8`
HH=`echo $YYYYMMDDHH | cut -c9-10`
DD=`echo $YYYYMMDDHH | cut -c7-8`
MM=`echo $YYYYMMDDHH | cut -c5-6`
YYYY=`echo $YYYYMMDDHH | cut -c1-4`
CDUMP='gdas'
S3PATH=/noaa-reanalyses-pds/observations/reanalysis
S3PATH_PRIVATE=/nnja-private-eumetsat/observations/reanalysis
# directory structure required by global-workflow
TARGET_DIR=${OUTPATH}/${CDUMP}.${YYYYMMDD}/${HH}/atmos
mkdir -p $TARGET_DIR
obtypes=("airs" "amsua" "amsua" "amsub" "amv" "atms" "cris" "cris" "geo" "geo" "geo" "geo" "gps" "hirs" "hirs" "hirs" "iasi" "mhs" "msu" "saphir" "seviri" "ssmi" "ssmis" "ssu")
dirs=("nasa" "nasa" "1bamua" "1bamub" "satwnd" "atms" "cris" "crisf4" "goesnd" "goesfv" "gsrcsr" "ahicsr" "gpsro" "1bhrs2" "1bhrs3" "1bhrs4" "mtiasi" "1bmhs" "1bmsu" "saphir" "sevcsr" "ssmit" "ssmisu" "1bssu")
obnames=("aqua" "aqua" "1bamua" "1bamub" "satwnd" "atms" "cris" "crisf4" "goesnd" "goesfv" "gsrcsr" "ahicsr" "gpsro" "1bhrs2" "1bhrs3" "1bhrs4" "mtiasi" "1bmhs" "1bmsu" "saphir" "sevcsr" "ssmit" "ssmisu" "1bssu")
dumpnames=("airs_disc_final" "amsua_disc_final" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas" "gdas")
nback=0
for n in ${!obtypes[@]}; do
if [ ${obtypes[$n]} == $obtyp ] || [ $obtyp == "all" ]; then
if [ ${obtypes[$n]} == "airs" ] && [ ${dirs[$n]} == "nasa" ]; then
# NASA airs obs
s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${obnames[$n]}/${YYYY}/${MM}/bufr/${dumpnames[$n]}.${YYYYMMDD}.t${HH}z.bufr"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.airsev.tm00.bufr_d"
#elif [ ${obtypes[$n]} == "airs" ] && [ ${dirs[$n]} == "airsev" ]; then
# # obtype=airs obname=airsev dir=airsev dumpname=gdas
# # amsua data from NCEP airsev file
# s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${YYYY}/${MM}/bufr/${dumpnames[$n]}.${YYYYMMDD}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
# localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.aquaamua.tm00.bufr_d"
elif [ ${obtypes[$n]} == "amsua" ] && [ ${dirs[$n]} == "nasa" ]; then
# obtype=amsua obname=aqua dir=nasa dumpname=amsua_disc_final
# NASA airs obs
s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${obnames[$n]}/${YYYY}/${MM}/bufr/${dumpnames[$n]}.${YYYYMMDD}.t${HH}z.bufr"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.aquaamua.tm00.bufr_d"
elif [ ${obtypes[$n]} == "amsua" ] && [ ${dirs[$n]} == "nasa/r21c_repro" ]; then
s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${YYYY}/${MM}/bufr/${dumpnames[$n]}.${YYYYMMDD}.t${HH}z.${obnames[$n]}.tm00.bufr"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.1bamua.tm00.bufr_d"
else
s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${YYYY}/${MM}/bufr/${dumpnames[$n]}.${YYYYMMDD}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
fi
nback=$[$nback+1]
if [ $dryrun == "true" ]; then
echo "aws s3 cp --no-sign-request --only-show-errors $s3file $localfile"
aws s3 ls --no-sign-request $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --no-sign-request --only-show-errors $s3file $localfile &
if [ $nback -eq $nbackmax ]; then
wait
nback=0
fi
fi
#ls -l $localfile
fi
done
wait
# prepbufr
obtypes="prepbufr prepbufr.acft_profiles"
for obtype in $obtypes; do
if [ ${obtypes[$n]} == $obtyp ] || [ $obtyp == "all" ]; then
if [ $obtype == "prepbufr" ]; then
s3file=s3:/"${S3PATH}/conv/${obtype}/${YYYY}/${MM}/prepbufr/gdas.${YYYYMMDD}.t${HH}z.${obtype}.nr"
else
s3file=s3:/"${S3PATH}/conv/${obtype}/${YYYY}/${MM}/bufr/gdas.${YYYYMMDD}.t${HH}z.${obtype}.nr"
fi
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.${obtype}"
#aws s3 ls --no-sign-request $s3file
if [ $dryrun == "true" ]; then
echo "aws s3 cp --no-sign-request --only-show-errors $s3file $localfile"
aws s3 ls --no-sign-request $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --no-sign-request --only-show-errors $s3file $localfile &
fi
#ls -l $localfile
fi
done
# ozone
# CFSR
if [ $obtyp == "osbuv8" ] || [ $obtyp == "all" ]; then
s3file=s3:/"${S3PATH}/ozone/cfsr/${YYYY}/${MM}/bufr/gdas.${YYYYMMDD}.t${HH}z.osbuv8.tm00.bufr_d"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.osbuv8.tm00.bufr_d"
#aws s3 ls --no-sign-request $s3file
if [ $dryrun == "true" ]; then
echo "aws s3 cp --no-sign-request --only-show-errors $s3file $localfile"
aws s3 ls --no-sign-request $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --no-sign-request --only-show-errors $s3file $localfile &
fi
#ls -l $localfile
fi
# NCEP bufr
obtypes=("ozone" "ozone" "ozone")
dirs=("ncep" "ncep" "ncep")
obnames=("ompslp" "ompsn8" "ompst8")
dumpnames=("gdas" "gdas" "gdas")
for n in ${!obtypes[@]}; do
if [ ${obtypes[$n]} == $obtyp ] || [ $obtyp == "all" ]; then
s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${obnames[n]}/${YYYY}/${MM}/bufr/${dumpnames[$n]}.${YYYYMMDD}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
#aws s3 ls --no-sign-request $s3file
if [ $dryrun == "true" ]; then
echo "aws s3 cp --no-sign-request --only-show-errors $s3file $localfile"
aws s3 ls --no-sign-request $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --no-sign-request --only-show-errors $s3file $localfile &
fi
#ls -l $localfile
fi
done
# NASA bufr
if [ $obtyp == "sbuv_v87" ] || [ $obtyp == "all" ]; then
s3file=s3:/"${S3PATH}/ozone/nasa/sbuv_v87/${YYYY}/${MM}/bufr/sbuv_v87.${YYYYMMDD}.${HH}z.bufr"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.sbuv_v87.tm00.bufr_d"
#aws s3 ls --no-sign-request $s3file
if [ $dryrun == "true" ]; then
echo "aws s3 cp --no-sign-request --only-show-errors $s3file $localfile"
aws s3 ls --no-sign-request $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --no-sign-request --only-show-errors $s3file $localfile &
fi
#ls -l $localfile
fi
# NASA netcdf
obtypes=("ozone" "ozone" "ozone" "ozone" "ozone")
dirs=("nasa" "nasa" "nasa" "nasa" "nasa")
obnames=("mls" "omi-eff" "omps-lp" "omps-nm-eff" "omps-nm")
dumpnames=("MLS-v5.0-oz" "OMIeff-adj" "OMPS-LPoz-Vis" "OMPSNM" "OMPSNP")
for n in ${!obtypes[@]}; do
if [ ${obtypes[$n]} == $obtyp ] || [ $obtyp == "all" ]; then
s3file=s3:/"${S3PATH}/${obtypes[$n]}/${dirs[$n]}/${obnames[$n]}/${YYYY}/${MM}/netcdf/${dumpnames[$n]}.${YYYYMMDD}_${HH}z.nc"
localfile="${TARGET_DIR}/${dumpnames[$n]}.${YYYYMMDD}_${HH}z.nc"
#aws s3 ls --no-sign-request $s3file
if [ $dryrun == "true" ]; then
echo "aws s3 cp --no-sign-request --only-show-errors $s3file $localfile"
aws s3 ls --no-sign-request $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --no-sign-request --only-show-errors $s3file $localfile &
fi
#ls -l $localfile
fi
done
wait
# over-write with private eumetsat data if available
obtypes=("gps" "ssmi" "amv" "ssmis")
dirs=("eumetsat" "eumetsat" "merged" "eumetsat")
obnames=("gpsro" "ssmit" "satwnd" "ssmisu")
for n in ${!obtypes[@]}; do
if [ ${obtypes[$n]} == $obtyp ] || [ $obtyp == "all" ]; then
s3file=s3:/"${S3PATH_PRIVATE}/${obtypes[$n]}/${dirs[$n]}/${YYYY}/${MM}/bufr/gdas.${YYYYMMDD}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
localfile="${TARGET_DIR}/${CDUMP}.t${HH}z.${obnames[$n]}.tm00.bufr_d"
if [ $dryrun == "true" ]; then
echo "aws s3 cp --profile ${NNJA_PRVIATE_PROFILE} --only-show-errors $s3file $localfile"
aws s3 ls --profile ${NNJA_PRVIATE_PROFILE} $s3file
if [ $? -ne 0 ]; then
echo "$s3file not found"
fi
else
aws s3 cp --profile ${NNJA_PRVIATE_PROFILE} --only-show-errors $s3file $localfile &
fi
fi
done
wait
if [ $dryrun != "true" ]; then
ls -l ${TARGET_DIR}
fi