Path: blob/devel/elmerice/IceSheet/Greenland/DATA/scripts/VELOCITY_TO_NETCDF.sh
5267 views
#!/bin/bash12function usage {3echo4echo "sh VELOCITY_TO_NETCDF.sh FILE_Ux.tif FILE_Ux.tif FILE.nc"5echo6echo " convert and concatenate .tif files of the ux and uy component of the obs. velocity "7echo " to netcdf FILE.nc"8echo9exit 110}1112if [ ! $# -eq 3 ]13then14echo "not enough arguments supplied -- Aborting !!"15echo16usage17fi181920echo "convert vx ($1) and vy ($2) files to netcdf ($3)"2122## convert ux to netcdf23gdal_translate -of netcdf -a_nodata -2000000000 $1 $324ncrename -h -v Band1,vx $32526## convert uy to netcdf27gdal_translate -of netcdf -a_nodata -2000000000 $2 tmp.nc28ncrename -h -v Band1,vy tmp.nc2930## append data files31ncks -h -A tmp.nc $33233## compute velocity norm34ncap2 -h -A -s"vnorm=sqrt(vx*vx+vy*vy)" $335ncatted -h -a _FillValue,vnorm,o,f,0.0 $33637rm -rf tmp.nc3839404142