Skip to content

Commit

Permalink
Improving the scripts for CONUS II
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kasra-keshavarz committed Dec 4, 2024
1 parent 2f82dd2 commit bdf6677
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/gwf-ncar-conus_ii/conus_ii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,25 @@ function concat_files () {
shift 2 # shift arguments by 2 positions
local filesArr=("$@") # array of file names

# concatenating $files and producing a single $fName.nc
ncrcat "${filesArr[@]}" "${fTempDir}/${fName}_cat.nc"
# Create temp directory for intermediate files
local ctmpdir="${fTempDir}/tmp_concat_$$"
mkdir -p "$ctmpdir"

# Process each file to add Time variable
for f in "${filesArr[@]}"; do
if [ -f "$f" ]; then
local basename_f=$(basename "$f")
ncap2 -s 'Time=XTIME' "$f" "${ctmpdir}/${basename_f}"
else
echo "Warning: File $f does not exist, skipping"
fi
done

# Concatenate processed files
ncrcat "${ctmpdir}"/* "${fTempDir}/${fName}_cat.nc"

# Clean up
rm -rf "$ctmpdir"
}


Expand Down

0 comments on commit bdf6677

Please sign in to comment.