forked from jmccreight/ncoScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncks_file_concatenator.sh
executable file
·68 lines (63 loc) · 1.92 KB
/
ncks_file_concatenator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Script to append individual netcdf files together into a single file using ncks
# Usage: ./ncks_file_concatenator.sh
# Usage: ./ncks_file_concatenator.sh -k ## keeps input files
# Output: A single WRF-Hydro input file called 'Fulldom_hires_netcdf_file.nc' that contains all the individual high-res
# netcdf file layers.
#
# Notes: This script is frequently used to concatenate the individual netcdf file layers that are generated for use as
# the 'routing grids' in WRF-Hydro. You will first need to 'unzip' the zipfile that is created from either the stand-alone
# routing grid tool or the one downloaded from the ArcGIS WRF-Hydro pre-processing web service first to create the individual
# file layers that will be concatenated. This script also erases those individual layers when finishing so be sure to keep
# your original zip file.
# Optionally, files are not erased with the -k flag
# Developed: 12/1/2012, D. Gochis
# Tweaks: 9/2/2015, J. McCreight
### EDIT THESE FILENAMES AS NEEDED....
outfile="Fulldom_hires_netcdf_file.nc"
file1="topography.nc"
file2="flowdirection.nc"
file3="CHANNELGRID.nc"
file4="str_order.nc"
file5="gw_basns.nc"
file6="retdeprtfac.nc"
file7="ovroughrtfac.nc"
file8="LAKEGRID.nc"
file9="frxst_pts.nc"
file10="latitude.nc"
file11="longitude.nc"
file12="LINKID.nc"
### NO EDITS NECESSARY BELOW HERE ####
echo $file1
ncks $file1 $outfile
echo $file2
ncks -A $file2 $outfile
echo $file3
ncks -A $file3 $outfile
echo $file4
ncks -A $file4 $outfile
echo $file5
ncks -A $file5 $outfile
echo $file6
ncks -A $file6 $outfile
echo $file7
ncks -A $file7 $outfile
echo $file8
ncks -A $file8 $outfile
echo $file9
ncks -A $file9 $outfile
echo $file10
ncks -A $file10 $outfile
echo $file11
ncks -A $file11 $outfile
if [ -e "$file12" ]
then
echo $file12
ncks -A $file12 $outfile
fi
if [ "$1" == "-k" ]
then
exit 0
fi
rm $file1 $file2 $file3 $file4 $file5 $file6 $file7 $file8 $file9 $file10 $file11 $file12
exit 0