Skip to content

Commit 97af967

Browse files
Closes #23: Unify launch scripts for stages 6 to 8
1 parent ec22497 commit 97af967

File tree

7 files changed

+63
-208
lines changed

7 files changed

+63
-208
lines changed

ehthops/hops-b1/6.uvfits/bin/0.launch

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@ show_help() {
1212
echo " SET_WRKDIR Working directory for pipeline process (default: PWD)"
1313
echo " SET_TOPDIR Top level dir for all stages (default: WRKDIR/..)"
1414
echo " SET_METADIR Location of preset control files, META tables, ZBL flux estimates for netcal, etc"
15-
echo " SET_INPUTDIR Data source directory. This is the DATADIR from the previous stage in stage 6"
15+
echo " SET_INPUTDIR Used only in post-processing stages. If Stage6 then $DATADIR from Stage5; if Stage7/8, then Stage6/7 base directory"
1616
echo " SET_EHTIMPATH Path to eht-imaging source code"
17-
echo " SET_CAMPAIGN EAT-recognizable campaign name"
17+
echo " SET_OBSYEAR Observing year"
18+
echo " SET_CAMPAIGN EAT-recognizable observing campaign name (\"EHT2017\", \"EHT2018\", \"EHT2021\", \"EHT2022\")"
1819
echo
1920
echo "If these are not set and no command-line options are given, then reasonable defaults are used (not always guaranteed to work!)."
2021
echo
2122
echo "Command-line options:"
2223
echo "====================="
23-
echo " -c <campaign-name> Campaign name recognizable by EAT (\"EHT2017\", \"EHT2018\", \"EHT2021\")"
24-
echo " -S <dir> Set the data source directory. Starting from this stage, this is the DATADIR from the previous stage"
25-
echo " -M <dir> Set the metadata directory (e.g. preset control files, META tables, ZBL flux estimates for netcal)"
24+
echo " -M <dir> Set METADIR"
25+
echo " -I <dir> Set INPUTDIR"
26+
echo " -y <yyyy> Set OBSYEAR"
27+
echo " -c <campaign-name> Set CAMPAIGN"
2628
echo " -h, --help Display this help message and exit"
2729
echo
2830
echo "Note:"
2931
echo " - The equivalent command-line options take precedence over the SET_* environment variables."
3032
echo " - The SET_* environment variables take precedence over the default values."
3133
echo
3234
echo "Example:"
33-
echo " SET_EHTIMPATH=/path/to/eht-imaging && SET_INPUTDIR=/path/to/stage5/data-directory && SET_METADIR=/path/to/metadata && SET_CAMPAIGN=\"EHT2017\" && source bin/0.launch"
35+
echo " SET_EHTIMPATH=/path/to/eht-imaging && SET_INPUTDIR=/path/to/input/files/from/previous/stage && SET_METADIR=/path/to/metadata && SET_CAMPAIGN=\"EHT2017\" && source bin/0.launch"
3436
}
3537

3638
if [ -f /.dockerenv ]; then
@@ -42,12 +44,16 @@ if [ -f /.dockerenv ]; then
4244
fi
4345

4446
# Default values can be adjusted by defining SET_* env variables prior to running launch
47+
OBSYEAR=${SET_OBSYEAR:-"2021"}
4548
CAMPAIGN=${SET_CAMPAIGN:-"EHT2021"}
4649

47-
# Overwrite CAMPAIGN if passed from command line argument as it affects some default values
50+
# Overwrite OBSYEAR and CAMPAIGN if passed as command-line arguments
4851
OPTIND=1 # start from the first argument (ignore existing shell state)
49-
while getopts "c:" opt; do
52+
while getopts "y:c:" opt; do
5053
case $opt in
54+
y)
55+
OBSYEAR=$OPTARG
56+
;;
5157
c)
5258
CAMPAIGN=$OPTARG
5359
;;
@@ -57,16 +63,36 @@ done
5763
# Default values can be adjusted by defining SET_* env variables prior to running launch
5864
WRKDIR=${SET_WRKDIR:-"$PWD"} # working directory for pipeline process
5965
TOPDIR=${SET_TOPDIR:-"$WRKDIR/.."} # top level dir for all stages
60-
INPUTDIR=${SET_INPUTDIR:-"$TOPDIR/5.+close/data"} # single input data location for correlator source data
66+
67+
# infer stage by looking at the first character of the parent directory of WRKDIR
68+
parent_dir=$(basename "$WRKDIR")
69+
case "${parent_dir:0:1}" in
70+
6)
71+
DEFAULT_INPUTDIR="$TOPDIR/5.+close/data"
72+
;;
73+
7)
74+
DEFAULT_INPUTDIR="$TOPDIR/6.uvfits"
75+
;;
76+
8)
77+
DEFAULT_INPUTDIR="$TOPDIR/7.+apriori"
78+
;;
79+
*)
80+
echo "Came here"
81+
# assume stage 7 for any other case
82+
DEFAULT_INPUTDIR="$TOPDIR/6.uvfits"
83+
;;
84+
esac
85+
86+
INPUTDIR=${SET_INPUTDIR:-$DEFAULT_INPUTDIR} # allow override via SET_INPUTDIR or -I flag
6187

6288
# Default values can be adjusted by defining SET_* env variables prior to running launch
63-
DEFAULT_METADIR="$TOPDIR/../meta/eht${CAMPAIGN: -4}/230GHz"
89+
DEFAULT_METADIR="$TOPDIR/../meta/eht$OBSYEAR/230GHz"
6490
METADIR=${SET_METADIR:-$DEFAULT_METADIR} # location of preset control files, META tables, ZBL flux estimates for netcal, etc
6591
EHTIMPATH=${SET_EHTIMPATH:-""} # may use custom path to ehtim source (ehtim module is subdir of this directory)
6692

6793
# Determine the band to process -- used by hops2uvfits.py in 3.import
6894
# special handling for 2017, only two bands exist ("b3" => "lo" and "b4" => "hi")
69-
if [[ $CAMPAIGN = "EHT2017" ]]; then
95+
if [[ $OBSYEAR = "2017" ]]; then
7096
BAND=${SET_BAND:-$(echo $WRKDIR | sed 's|.*/hops-\(..\)/.*$|\1|')} # band to process
7197
if [[ $BAND = "b3" ]]; then
7298
BAND="lo"
@@ -79,17 +105,21 @@ fi
79105

80106
# Parse command-line arguments. overwrite any existing settings
81107
OPTIND=1 # start from the first argument (ignore existing shell state)
82-
while getopts "c:S:M:h" opt; do
108+
while getopts "y:c:M:I:h" opt; do
83109
case $opt in
110+
y)
111+
OBSYEAR=$OPTARG
112+
;;
84113
c)
85114
CAMPAIGN=$OPTARG
86115
;;
87-
S)
88-
INPUTDIR=$OPTARG
89-
;;
90116
M)
91117
METADIR=$OPTARG
92118
;;
119+
I)
120+
INPUTDIR=$OPTARG
121+
;;
122+
93123
h|help)
94124
show_help
95125
return 0
@@ -110,11 +140,11 @@ done
110140
# Perform some basic checks
111141
if [ ! -d "$METADIR" ]; then
112142
echo "From $(basename "${BASH_SOURCE[0]}") ERROR:: METADIR=$(METADIR) does not exist! Exiting..."
113-
exit 1
143+
return 1
114144
fi
115145
if [ ! -d "$INPUTDIR" ]; then
116146
echo "From $(basename "${BASH_SOURCE[0]}") ERROR:: INPUTDIR=$(INPUTDIR) does not exist! Exiting..."
117-
exit 1
147+
return 1
118148
fi
119149

120150
# Parse arguments
@@ -135,6 +165,7 @@ if [ x"$USE_DOCKER" == x"true" ]; then
135165
echo " Meta, METADIR: $METADIR"
136166
echo " Path to eht-imaging, EHTIMPATH: $EHTIMPATH"
137167
echo " Band, BAND: $BAND"
168+
echo " Observing year, OBSYEAR: $OBSYEAR"
138169
echo " EAT-recognizable campaign name, CAMPAIGN: $CAMPAIGN"
139170
echo " Command: $@"
140171

@@ -153,6 +184,7 @@ if [ x"$USE_DOCKER" == x"true" ]; then
153184
-e "METADIR=/meta" \
154185
-e "EHTIMPATH=$EHTIMPATH" \
155186
-e "BAND=$BAND" \
187+
-e "OBSYEAR=$OBSYEAR" \
156188
-e "CAMPAIGN=$CAMPAIGN" \
157189
$PORTFORWARD \
158190
eventhorizontelescope/eat-notebook \
@@ -166,6 +198,7 @@ else
166198
echo " Meta, METADIR: $METADIR"
167199
echo " Path to eht-imaging, EHTIMPATH: $EHTIMPATH"
168200
echo " Band, BAND: $BAND"
201+
echo " Observing year, OBSYEAR: $OBSYEAR"
169202
echo " EAT-recognizable campaign name, CAMPAIGN: $CAMPAIGN"
170203
echo " Command: $@"
171204
fi

ehthops/hops-b1/6.uvfits/bin/9.next

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,28 @@ echo "9. Copying standard scripts and metadata to the next stage \"$NEXT\""
1515
# capture the name of this stage dir (e.g. "6.uvfits")
1616
prev_stage=$(basename "$PWD")
1717

18-
for n in 2 3; do
18+
for n in 0 2 3; do
1919
for curr in bin/${n}.*; do
2020
# skip missing files
2121
[ ! -f "$curr" ] && continue
2222

23-
# compute the new step number and dest path
24-
new_prefix=$((n + 1))
23+
# determine new_prefix:
24+
# - if n==0, leave it as 0
25+
# - if n==2 or 3, use n+1
26+
if [ "$n" -eq 0 ]; then
27+
new_prefix=0
28+
else
29+
new_prefix=$((n + 1))
30+
fi
31+
32+
# strip off the "bin/N." to get the rest of the name
2533
rest=${curr#bin/${n}.} # e.g. "import" or "average"
2634
dest=$NEXT/bin/${new_prefix}.${rest}
2735

2836
# skip if dest already exists
2937
[ -e "$dest" ] && continue
3038

31-
echo "Linking $curr $dest"
39+
echo "Linking $curr to $dest"
3240
# always point back to ../../<prev_stage>/bin/n.rest
3341
ln -s "../../${prev_stage}/bin/${n}.${rest}" "$dest"
3442
done

ehthops/hops-b1/7.+apriori/bin/0.launch

Lines changed: 0 additions & 183 deletions
This file was deleted.

ehthops/hops-b1/7.+apriori/bin/9.next

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ for n in 0 3 4; do
3636
# skip if dest already exists
3737
[ -e "$dest" ] && continue
3838

39-
echo "Linking $curr $dest"
39+
echo "Linking $curr to $dest"
4040
# always point back to ../../<prev_stage>/bin/n.rest
4141
ln -s "../../${prev_stage}/bin/${n}.${rest}" "$dest"
4242
done

ehthops/hops-b2/7.+apriori/bin/0.launch

Lines changed: 0 additions & 1 deletion
This file was deleted.

ehthops/hops-b3/7.+apriori/bin/0.launch

Lines changed: 0 additions & 1 deletion
This file was deleted.

ehthops/hops-b4/7.+apriori/bin/0.launch

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)