-
Notifications
You must be signed in to change notification settings - Fork 0
/
07_OLD_extract_RVs.sh
executable file
·118 lines (106 loc) · 3.64 KB
/
07_OLD_extract_RVs.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
#
# Pull RV information out of tarballs and raw spectra.
#
# Rob Siverd
# Created: 2018-04-17
# Last updated: 2018-10-09
#--------------------------------------------------------------------------
#**************************************************************************
#--------------------------------------------------------------------------
## Default options:
debug=0 ; clobber=0 ; force=0 ; timer=0 ; vlevel=0
script_version="0.03"
this_prog="${0##*/}"
#shopt -s nullglob
# Propagate errors through pipelines: set -o pipefail
# Exit if uninitialized variable used (set -u): set -o nounset
# Exit in case of nonzero status (set -e): set -o errexit
## Program options:
#save_file=""
#shuffle=0
#confirmed=0
## Standard scratch files/dirs:
tmp_name="$(date +%Y%m%d.%H%M%S).$$.$(whoami)"
tmp_root="/tmp"
[ -d /dev/shm ] && [ -w /dev/shm ] && tmp_root="/dev/shm"
tmp_dir="$tmp_root"
#tmp_dir="$tmp_root/$tmp_name"
#mkdir -p $tmp_dir
foo="$tmp_dir/foo_$$.txt"
bar="$tmp_dir/bar_$$.txt"
baz="$tmp_dir/baz_$$.fits"
qux="$tmp_dir/qux_$$.fits"
jnk="$foo $bar $baz $qux" # working copy
def_jnk="$jnk" # original set
dir_cleanup='(echo -e "\nAutomatic clean up ... " ; cmde "rm -vrf $tmp_dir")'
jnk_cleanup='for X in $jnk ; do [ -f $X ] && cmde "rm -vf $X" ; done'
trap "$jnk_cleanup" EXIT
##trap '[ -d $tmp_dir ] && cmde "rm -vrf $tmp_dir"' EXIT
#trap "[ -d $tmp_dir ] && $dir_cleanup" EXIT
#trap "[ -d $tmp_dir ] && $dir_cleanup ; $jnk_cleanup" EXIT
#trap 'oops=$? ; echo ; exit $oops' HUP INT TERM
## Required programs:
declare -a need_exec
need_exec+=( awk cat extract-specproc-RVs FuncDef iltk sed tr )
#need_exec+=( shuf shuffle sort ) # for randomization
for need in ${need_exec[*]}; do
if ! ( /usr/bin/which $need >& /dev/null ); then
echo "Error: can't find '$need' in PATH !!" >&2
exit 1
fi
done
## Helper function definitions:
fd_args="--argchk --colors --cmde --echo"
#fd_args+=" --Critical"
fd_args+=" --rowwrite"
#fd_args+=" --timers"
fd_args+=" --warnings"
FuncDef $fd_args >/dev/null || exit $?
eval "$(FuncDef $fd_args)" || exit $?
## Check for arguments:
usage () {
Recho "\nSyntax: $this_prog --START\n\n"
#Recho "\nSyntax: $this_prog arg1\n\n"
}
if [ "$1" != "--START" ]; then
#if [ -z "$1" ]; then
usage >&2
exit 1
fi
##**************************************************************************##
##==========================================================================##
##--------------------------------------------------------------------------##
## Load config:
cmde "source config.sh"
##--------------------------------------------------------------------------##
## Extract data:
for object in `cat $object_list`; do
echo "-------------------------------------------"
obs_list="$meta_dir/tb_list_$object.txt"
obs_data="$meta_dir/spectra_$object.txt"
cmde "grep $object $recent_all_img_hdrs > tmp.txt"
cmde "iltk -Lr $recent_cln_tarballs -c tmp.txt -o $obs_list"
cmde "extract-specproc-RVs $obs_list -co $obs_data"
done
rm tmp.txt
##--------------------------------------------------------------------------##
## Clean up:
#[ -d $tmp_dir ] && [ -O $tmp_dir ] && rm -rf $tmp_dir
#[ -f $foo ] && rm -f $foo
#[ -f $bar ] && rm -f $bar
#[ -f $baz ] && rm -f $baz
#[ -f $qux ] && rm -f $qux
exit 0
######################################################################
# CHANGELOG (02_extract_RVs.sh):
#---------------------------------------------------------------------
#
# 2018-05-07:
# -- Increased script_version to 0.02.
# -- Now pull from 'clean' data files (blacklisted files removed).
#
# 2018-04-17:
# -- Increased script_version to 0.01.
# -- First created 02_extract_RVs.sh.
#