Saturday, September 25, 2010

Pack netcdf file

#!/bin/bash
# A simple usage of ncpdq from nco (http://nco.sourceforge.net)
# Please check more details from the nco website.
#   Usage:  packnc.sh myncfile(s)
#   NOTE: There will be a loss of precision in type conversion
#         (converted to short by default)
# Copyright by http://scriptdemo.blogspot.com/
 
IsNCPDQ=`which ncpdq`
if [ ${#IsNCPDQ} -eq 0 ]; then
   echo "ncpdq can not be found in the path..."
   echo "Please double check your NetCDF Operator (NCO) Path"
   exit
fi

if [ $# -eq 0 ]; then
   sed -n '4p' packnc.sh
   exit
else
   Nfiles=$*
   for ncfile in ${Nfiles}
   do
      [ -f ${ncfile} ] && ncpdq -P all_xst ${ncfile}  tmpout_${ncfile} && mv tmpout_${ncfile} ${ncfile}
   done
fi

No comments:

ShowCalendar