-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcat_noaa_ozone_data.sh
executable file
·82 lines (75 loc) · 1.86 KB
/
cat_noaa_ozone_data.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /bin/bash
#--------------------------------------------------------------------
# Script to loop through a set of file and concatenate them
#
# Author: Stefanie Falk
# Date: January 2020
# Update:
#
#--------------------------------------------------------------------
##### Functions
usage()
{
echo "Usage: ./cat_noaa_ozone_data.sh [[ -s | --start_year start_year ] [ -e | --end_year end_year][ -o | --output output_name] [--station station_identifier]]"
}
check_null()
{
if [ $# -eq 0 ]; then
echo "No arguments provided!"
usage
exit 1
fi
}
options()
{
while [ "${1}" != "" ]; do
case $1 in
-s | --start_year )
shift
start_year=${1}
echo "Start year: ${start_year}"
;;
-e | --end_year )
shift
end_year=${1}
echo "End year: ${end_year}"
;;
-o | --output_dir )
shift
output=${1}
echo "output: ${output}"
;;
-h | --help )
usage
exit
;;
* )
usage
exit 1
esac
shift
done
}
cycle_years() {
year=${start_year}
if [[ $start_year > 0 ]]; then
while [ $year -le $end_year ]; do
# Download data from ftp
concat_files $year
# Update counter
year=$(($year + 1))
done
fi
}
concat_files() {
year=$1
echo "Concatenating files " $year
#for each in `ls brw_o3*`; do cat $each >> BRW_Ozone_Hourly_2013; done
}
### MAIN
# Check if arguments were provided
check_null $@
# Cycle through options
options $@
# Cycle through years
cycle_years