Skip to content

Commit 0ac000b

Browse files
Rewinding back to using CDO for RDRS spatial subsetting (#61)
Since using spatial indices and `ncks` proved to be problematic and missing the full spatial extents given. This commit rewinds the script to use `CDO` again. Reported-by: Wouter Knoben <[email protected]> Signed-off-by: Kasra Keshavarz <[email protected]>
1 parent 6b0f0af commit 0ac000b

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

scripts/eccc-rdrs/rdrs.sh

+15-9
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ maxLat=$(bc <<< "$maxLat + 0.1")
222222
minLon=$(bc <<< "$minLon - 0.1")
223223
maxLon=$(bc <<< "$maxLon + 0.1")
224224

225+
# updating $latLims and $lonLims based on new values
226+
latLims="${minLat},${maxLat}"
227+
lonLims="${minLon},${maxLon}"
228+
225229
# extract the associated indices corresponding to $latLims and $lonLims
226230
coordIdx="$(ncl -nQ 'coord_file='\"$domainFile\" 'minlat='"$minLat" 'maxlat='"$maxLat" 'minlon='"$minLon" 'maxlon='"$maxLon" "$coordIdxScript")"
227231

@@ -288,15 +292,15 @@ for yr in $yearsRange; do
288292
# creating file name
289293
file="${toDateFormatted}12.nc" # current file name
290294

291-
# extracting variables from the files and spatial subsetting
292-
# assuring the process finished using an `until` loop
293-
until ncks -A -v ${variables} \
294-
-d "$latDim","${latLimsIdx}" \
295-
-d "$lonDim","${lonLimsIdx}" \
296-
${datasetDir}/${yr}/${file} \
297-
${cache}/${yr}/${file}; do
295+
# extracting spatial extents and variables
296+
until cdo -z zip \
297+
-s -L \
298+
-sellonlatbox,"$lonLims","$latLims" \
299+
-selvar,"$variables" \
300+
"${datasetDir}/${yr}/${file}" \
301+
"${cache}/${yr}/${file}"; do
298302
echo "$(logDate)$(basename $0): Process killed: restarting process in 10 sec" >&2
299-
echo "NCKS [...] failed" >&2
303+
echo "CDO [...] failed" >&2
300304
sleep 10;
301305
done # until ncks
302306

@@ -306,6 +310,7 @@ for yr in $yearsRange; do
306310
fi
307311

308312
# wait for any left-over processes to finish
313+
# note to self: not sure this even does anything, but anyways
309314
wait
310315

311316
# change lon values so the extents are from ~-180 to 0
@@ -318,13 +323,14 @@ for yr in $yearsRange; do
318323
echo "$(logDate)$(basename $0): NCAP2 -s [...] failed" >&2
319324
sleep 10;
320325
done
321-
326+
322327
# remove any left-over .tmp file
323328
if [[ -e ${cache}/${yr}/${file}*.tmp ]]; then
324329
rm -r "${cache}/${yr}/${file}*.tmp"
325330
fi
326331

327332
# wait for any left-over processes to finish
333+
# note to self: not sure this even does anything, but anyways
328334
wait
329335

330336
# increment time-step by one unit

0 commit comments

Comments
 (0)