forked from rudolffu/pyfosc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyfosc_init
executable file
·94 lines (87 loc) · 3.69 KB
/
pyfosc_init
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
#!/usr/bin/env bash
cat << "EOF"
__ __ _ _
\ \ / /__| | ___ ___ _ __ ___ ___ | |_ ___
\ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \ | __/ _ \
\ V V / __/ | (_| (_) | | | | | | __/ | || (_) |
\_/\_/ \___|_|\___\___/|_| |_| |_|\___| \__\___/
____ _____ ___ ____ ____
| _ \ _ _| ___/ _ \/ ___| / ___|
| |_) | | | | |_ | | | \___ \| |
| __/| |_| | _|| |_| |___) | |___
|_| \__, |_| \___/|____/ \____|
|___/
EOF
CWD=$(pwd -P)
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
function render_template() {
eval "echo \"$(cat $1)\""
}
printf "Make sure you have already prepared the data and initiated\niraf before doing the following.\n"
printf "The current working directory is $CWD.\n"
printf "The source directory is $BASEDIR.\n"
if [ ! -d "./raw" ]; then
mkdir ./raw
printf "Directory \"raw\" is created.\n"
else
printf "Directory \"raw\" already exists.\n"
fi
printf "============================================================\n"
title="Please select the instrument with which you took the spectra."
prompt="Enter number after the prompt:"
options=("BFOSC, Xinglong 2m16 telescope" "YFOSC, Lijiang 2m4 telescope" "HFOSC, HCT at IAO")
echo "$title"
PS3="$prompt "
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1 ) printf "============================================================\n"
TELESCOPE="XLT"
echo "You picked $opt which is option $REPLY."
while true; do
# read -p "Enter the slit you have used (e.g. slit2.5):" slit
read -p "Enter the Grism you have used (e.g. G4):" Grism
render_template $BASEDIR/config/instrconfig.json.temp > ./myfosc.json
read -p "Do you want to copy the raw files to ./raw?[y/n]" yn
case $yn in
[Yy]* ) python $BASEDIR/src/list_back_2mdata.py; echo "Raw data is backuped and copied to ./raw."; exit;;
[Nn]* ) echo "Otherwise you have to do it yourself."; exit;;
* ) echo "Please answer y or n.";;
esac
done
break;;
2 ) printf "============================================================\n"
TELESCOPE="LJT"
echo "You picked $opt which is option $REPLY."
while true; do
read -p "Enter the slit you have used (e.g. slit2.5):" slit
read -p "Enter the Grism you have used (e.g. G3):" Grism
render_template $BASEDIR/config/instrconfig.json.temp > ./myfosc.json
read -p "Do you want to copy the raw files to ./raw?[y/n]" yn
case $yn in
[Yy]* ) python $BASEDIR/src/list_back_2mdata.py; echo "Raw data is backuped and copied to ./raw."; exit;;
[Nn]* ) echo "Otherwise you have to do it yourself."; exit;;
* ) echo "Please answer y or n.";;
esac
done
break;;
3 ) printf "============================================================\n"
TELESCOPE="HCT"
echo "You picked $opt which is option $REPLY."
while true; do
read -p "Enter the slit you have used (e.g. s167; s134):" slit
read -p "Enter the Grism you have used (e.g. Gr7):" Grism
render_template $BASEDIR/config/instrconfig.json.temp > ./myfosc.json
read -p "Do you want to copy the raw files to ./raw?[y/n]" yn
case $yn in
[Yy]* ) python $BASEDIR/src/list_back_2mdata.py; echo "Raw data is backuped and copied to ./raw."; exit;;
[Nn]* ) echo "Otherwise you have to do it yourself."; exit;;
* ) echo "Please answer y or n.";;
esac
done
break;;
4 ) printf "============================================================\n"
echo "You picked $opt which is option $REPLY.";;
$(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done