Skip to content

Instantly share code, notes, and snippets.

@ashiklom
Created June 30, 2023 22:15
Show Gist options
  • Save ashiklom/b1c6e9c832698b47c9daeea6df830262 to your computer and use it in GitHub Desktop.
Save ashiklom/b1c6e9c832698b47c9daeea6df830262 to your computer and use it in GitHub Desktop.
Re-chunking GOES data
#!/usr/bin/env bash
source ~/.bash_functions
mod_py39
conda activate vdp-common
FILES=$(find css-geo/GOES-16-ABI-L1B-FULLD/2022/203 -type f)
# Define directory where outptus will be saved
OUTDIR=GOES-16-ABI-L1B-FULLD-rc1000
for infile in $FILES; do
echo "Processing $(basename $infile)"
# Define the output file by replacing the base directory of the input file
# with the output directory.
outfile=${infile/css-geo\/GOES-16-ABI-L1B-FULLD/$OUTDIR}
mkdir -p $(dirname $outfile)
if [ -f $outfile ]; then
echo "File exists. Skipping..."
continue
fi
# Re-chunk in the X and Y dimensions, setting both X and Y chunk sizes to 100
ncks $infile \
--chunk_dimension x,1000 \
--chunk_dimension y,1000 \
$outfile
done
@ashiklom
Copy link
Author

Change $outfile to $outfile & and add wait at the very bottom of the file (outside the loop) to process these in parallel. But make sure you're on a compute node, not an interactive node!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment