Skip to content

Commit bdf6677

Browse files
Improving the scripts for CONUS II
Given that there might be descrepencies between various versions of the CONUS II dataset files (what is locally available and what is offered by NCAR,) minor changes are proposed to alleviate issues that may come up. Reported-by: Logan Fang <[email protected]> Signed-off-by: Kasra Keshavarz <[email protected]>
1 parent 2f82dd2 commit bdf6677

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

scripts/gwf-ncar-conus_ii/conus_ii.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,25 @@ function concat_files () {
312312
shift 2 # shift arguments by 2 positions
313313
local filesArr=("$@") # array of file names
314314

315-
# concatenating $files and producing a single $fName.nc
316-
ncrcat "${filesArr[@]}" "${fTempDir}/${fName}_cat.nc"
315+
# Create temp directory for intermediate files
316+
local ctmpdir="${fTempDir}/tmp_concat_$$"
317+
mkdir -p "$ctmpdir"
318+
319+
# Process each file to add Time variable
320+
for f in "${filesArr[@]}"; do
321+
if [ -f "$f" ]; then
322+
local basename_f=$(basename "$f")
323+
ncap2 -s 'Time=XTIME' "$f" "${ctmpdir}/${basename_f}"
324+
else
325+
echo "Warning: File $f does not exist, skipping"
326+
fi
327+
done
328+
329+
# Concatenate processed files
330+
ncrcat "${ctmpdir}"/* "${fTempDir}/${fName}_cat.nc"
331+
332+
# Clean up
333+
rm -rf "$ctmpdir"
317334
}
318335

319336

0 commit comments

Comments
 (0)