diff --git a/remap.sh b/remap.sh index 7d9891c4df87833999a7769409f776b449e6fba1..486a8a4df26af45647015217050cacd976201bd9 100755 --- a/remap.sh +++ b/remap.sh @@ -19,17 +19,21 @@ tgt_grid="hpz9" infile=$1 outdir=$(dirname $infile)/healpix outfile=${outdir}/$(basename $infile) +outfile_part=${outdir}/$(basename $infile).partial mkdir -p $outdir -# Remap, chunk, and compress the given input file -cdo \ - --format nc4 \ - --compression_type zstd \ - --chunktype auto \ - --chunksize $((4**9)) \ - --num_threads 4 \ - -remap,$tgt_grid,"$weightsdir/weights_${src_grid}_${tgt_grid}.nc" \ - $infile $outfile - -ncrename -d cells,cell $outfile +if [ ! -f $outfile ]; then + # Remap, chunk, and compress the given input file + cdo \ + --format nc4 \ + --compression_type zstd \ + --chunktype auto \ + --chunksize $((4**9)) \ + --num_threads 4 \ + -remap,$tgt_grid,"$weightsdir/weights_${src_grid}_${tgt_grid}.nc" \ + $infile $outfile_part + + ncrename -d cells,cell $outfile_part + mv $outfile_part $outfile +fi