Skip to content

Commit a63360d

Browse files
Streamline control flow between stages 7 and 8
1 parent f6f0f2b commit a63360d

File tree

9 files changed

+66
-7
lines changed

9 files changed

+66
-7
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ show_help() {
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"
1515
echo " SET_INPUTDIR Data source directory. Starting from this stage, this is the base directory of the previous stage (containing directories named by HOPS expt_no)"
16+
echo " SET_EHTIMPATH Path to eht-imaging source code"
1617
echo " SET_OBSYEAR Campaign year"
18+
echo " SET_CAMPAIGN EAT-recognizable campaign name"
1719
echo
1820
echo "If these are not set and no command-line options are given, then reasonable defaults are used (not always guaranteed to work!)."
1921
echo
2022
echo "Command-line options:"
2123
echo "====================="
2224
echo " -y <yyyy> Campaign year"
25+
echo " -c <campaign-name> Campaign name recognizable by EAT (\"EHT2017\", \"EHT2018\", \"EHT2021\")"
2326
echo " -S <dir> Set the data source directory. Starting from this stage, this is the base directory of the previous stage (containing directories named by HOPS expt_no)"
2427
echo " -M <dir> Set the metadata directory (e.g. preset control files, META tables, ZBL flux estimates for netcal)"
2528
echo " -h, --help Display this help message and exit"
@@ -29,7 +32,7 @@ show_help() {
2932
echo " - The SET_* environment variables take precedence over the default values."
3033
echo
3134
echo "Example:"
32-
echo " SET_INPUTDIR=/path/to/6.uvfits/ && SET_METADIR=/path/to/metadata && SET_OBSYEAR=2017 && source bin/0.launch"
35+
echo " SET_EHTIMPATH=/path/to/eht-imaging && SET_INPUTDIR=/path/to/6.uvfits/ && SET_METADIR=/path/to/metadata && SET_OBSYEAR=2017 && SET_CAMPAIGN=\"EHT2017\" && source bin/0.launch"
3336
}
3437

3538
if [ -f /.dockerenv ]; then
@@ -42,14 +45,18 @@ fi
4245

4346
# Default values can be adjusted by defining SET_* env variables prior to running launch
4447
OBSYEAR=${SET_OBSYEAR:-"2021"}
48+
CAMPAIGN=${SET_CAMPAIGN:-"EHT2021"}
4549

4650
# Overwrite OBSYEAR if passed from command line argument as it affects some default values
4751
OPTIND=1 # start from the first argument (ignore existing shell state)
48-
while getopts "y:" opt; do
52+
while getopts "y:c:" opt; do
4953
case $opt in
5054
y)
5155
OBSYEAR=$OPTARG
5256
;;
57+
c)
58+
CAMPAIGN=$OPTARG
59+
;;
5360
esac
5461
done
5562

@@ -61,6 +68,7 @@ INPUTDIR=${SET_INPUTDIR:-"$TOPDIR/6.uvfits"} # stage 6 directory containing exp
6168
# Default values can be adjusted by defining SET_* env variables prior to running launch
6269
DEFAULT_METADIR="$TOPDIR/../meta/eht$OBSYEAR/230GHz"
6370
METADIR=${SET_METADIR:-$DEFAULT_METADIR} # location of preset control files, META tables, ZBL flux estimates for netcal, etc
71+
EHTIMPATH=${SET_EHTIMPATH:-""} # may use custom path to ehtim source (ehtim module is subdir of this directory)
6472

6573
# Determine the band to process -- used by hops2uvfits.py in 3.import
6674
# special handling for 2017, only two bands exist ("b3" => "lo" and "b4" => "hi")
@@ -77,11 +85,14 @@ fi
7785

7886
# Parse command-line arguments. overwrite any existing settings
7987
OPTIND=1 # start from the first argument (ignore existing shell state)
80-
while getopts "y:S:M:h" opt; do
88+
while getopts "y:c:S:M:h" opt; do
8189
case $opt in
8290
y)
8391
OBSYEAR=$OPTARG
8492
;;
93+
c)
94+
CAMPAIGN=$OPTARG
95+
;;
8596
S)
8697
INPUTDIR=$OPTARG
8798
;;
@@ -131,8 +142,10 @@ if [ x"$USE_DOCKER" == x"true" ]; then
131142
echo " Work dir, WRKDIR: $WRKDIR"
132143
echo " Top level work dir, TOPDIR: $TOPDIR"
133144
echo " Meta, METADIR: $METADIR"
145+
echo " Path to eht-imaging, EHTIMPATH: $EHTIMPATH"
134146
echo " Band, BAND: $BAND"
135147
echo " Campaign year, OBSYEAR: $OBSYEAR"
148+
echo " EAT-recognizable campaign name, CAMPAIGN: $CAMPAIGN"
136149
echo " Command: $@"
137150

138151
if [ $# == 0 ]; then # no command line argument
@@ -148,8 +161,10 @@ if [ x"$USE_DOCKER" == x"true" ]; then
148161
-e "TOPDIR=/top" \
149162
-e "INPUTDIR=/data" \
150163
-e "METADIR=/meta" \
164+
-e "EHTIMPATH=$EHTIMPATH" \
151165
-e "BAND=$BAND" \
152166
-e "OBSYEAR=$OBSYEAR" \
167+
-e "CAMPAIGN=$CAMPAIGN" \
153168
$PORTFORWARD \
154169
eventhorizontelescope/eat-notebook \
155170
"$@"
@@ -160,7 +175,9 @@ else
160175
echo " Work dir, WRKDIR: $WRKDIR"
161176
echo " Top level work dir, TOPDIR: $TOPDIR"
162177
echo " Meta, METADIR: $METADIR"
178+
echo " Path to eht-imaging, EHTIMPATH: $EHTIMPATH"
163179
echo " Band, BAND: $BAND"
164180
echo " Campaign year, OBSYEAR: $OBSYEAR"
181+
echo " EAT-recognizable campaign name, CAMPAIGN: $CAMPAIGN"
165182
echo " Command: $@"
166183
fi
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -f /.dockerenv ]; then
4+
echo "This script copies control files to the next stage; \
5+
avoid running it inside a container"
6+
exit 1
7+
fi
8+
9+
N=$(basename $PWD | sed 's/^\([0-9]*\)\..*/\1/')
10+
NEXT=$(echo ../$(expr $N + 1).*)
11+
12+
#------------------------------------------------------------------------------
13+
echo "9. Copying standard scripts and metadata to the next stage \"$NEXT\""
14+
15+
# capture the name of this stage dir (e.g. "6.uvfits")
16+
prev_stage=$(basename "$PWD")
17+
18+
for n in 0 3 4; do
19+
for curr in bin/${n}.*; do
20+
# skip missing files
21+
[ ! -f "$curr" ] && continue
22+
23+
# determine new_prefix:
24+
# - if n==0, leave it as 0
25+
# - if n==3 or 4, 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
33+
rest=${curr#bin/${n}.} # e.g. "import" or "average"
34+
dest=$NEXT/bin/${new_prefix}.${rest}
35+
36+
# skip if dest already exists
37+
[ -e "$dest" ] && continue
38+
39+
echo "Linking $curr$dest"
40+
# always point back to ../../<prev_stage>/bin/n.rest
41+
ln -s "../../${prev_stage}/bin/${n}.${rest}" "$dest"
42+
done
43+
done

ehthops/hops-b1/8.+polcal/bin/0.launch

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../hops-b1/7.+apriori/bin/9.next

ehthops/hops-b2/8.+polcal/bin/0.launch

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../hops-b1/7.+apriori/bin/9.next

ehthops/hops-b3/8.+polcal/bin/0.launch

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../hops-b1/7.+apriori/bin/9.next

ehthops/hops-b4/8.+polcal/bin/0.launch

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

0 commit comments

Comments
 (0)