-
Notifications
You must be signed in to change notification settings - Fork 0
/
SSC_ramshifts.sh
executable file
·65 lines (51 loc) · 1.62 KB
/
SSC_ramshifts.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
#!/bin/bash
# Author: Daryn White, [email protected]
if [ -z "$1" ] && [ -z "$2" ]; then
echo '
SSC_ramshifts readjusts the SSC data column in temp, sal, cond, & dens files
to undo erroneous shifts that happened during a deployment
It is assumed to be run inside the working deployment directory,
thus this file should be copied into that directory for use
Use: SSC_ramshifts [Deploy ID] [listfile]
Deploy ID = the id of the deployment, [ra|pi]###[a|b]
listfile = output listfile from SSC_ClockAdjusted script
Examples:
SSC_ramshifts ra169a SSC_ClockAdjusted.lst
'
exit 1
fi
if [[ $1 =~ ..\d\d\d[a-c] ]]; then
echo "Need the deployment leg please"
printf 'Did you mean?\n %sa' "$1"
exit
elif [[ $2 =~ ..\w.lst ]]; then
echo "Need the output listfile please"
printf 'Did you mean?\n %sa' "$2"
exit
fi
id=${1: -4}
file=$(find "$2")
# check for ram_orig files and create them if they do not exist
for fl in {temp,cond,sal,dens}; do
if [ -f "$fl""$id".ram_orig ]; then
echo "Original $fl$id.ram_orig exists"
else
echo "No original files"
cp "$fl""$id".ram "$fl""$id".ram_orig
fi
done
exec 5<"$file"
len=$(awk 'END { print NR }' "$file")
# for i in $len; do TMP$i=$(mktemp); done;
while read -ru 5 d s; do
l=$c
((c = "$c" + 1))
echo "adjustment date: $d | # of samples: $s | l=$l | c=$c"
if [[ $c == 1 ]]; then
ram_shift --at="$d" --col=1 --samples="$s" temp"$id".ram_orig >"$c"
else
ram_shift --at="$d" --col=1 --samples="$s" "$l" >"$c"
fi
done
cat "$len" >temp"$id".ram
rm -f $(seq 1 "$len")