Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/IceSheet/Greenland/DATA/scripts/VELOCITY_TO_NETCDF.sh
5267 views
1
#!/bin/bash
2
3
function usage {
4
echo
5
echo "sh VELOCITY_TO_NETCDF.sh FILE_Ux.tif FILE_Ux.tif FILE.nc"
6
echo
7
echo " convert and concatenate .tif files of the ux and uy component of the obs. velocity "
8
echo " to netcdf FILE.nc"
9
echo
10
exit 1
11
}
12
13
if [ ! $# -eq 3 ]
14
then
15
echo "not enough arguments supplied -- Aborting !!"
16
echo
17
usage
18
fi
19
20
21
echo "convert vx ($1) and vy ($2) files to netcdf ($3)"
22
23
## convert ux to netcdf
24
gdal_translate -of netcdf -a_nodata -2000000000 $1 $3
25
ncrename -h -v Band1,vx $3
26
27
## convert uy to netcdf
28
gdal_translate -of netcdf -a_nodata -2000000000 $2 tmp.nc
29
ncrename -h -v Band1,vy tmp.nc
30
31
## append data files
32
ncks -h -A tmp.nc $3
33
34
## compute velocity norm
35
ncap2 -h -A -s"vnorm=sqrt(vx*vx+vy*vy)" $3
36
ncatted -h -a _FillValue,vnorm,o,f,0.0 $3
37
38
rm -rf tmp.nc
39
40
41
42