@@ -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
3638if [ -f /.dockerenv ]; then
@@ -42,12 +44,16 @@ if [ -f /.dockerenv ]; then
4244fi
4345
4446# Default values can be adjusted by defining SET_* env variables prior to running launch
47+ OBSYEAR=${SET_OBSYEAR:- " 2021" }
4548CAMPAIGN=${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
4851OPTIND=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 ;;
5763# Default values can be adjusted by defining SET_* env variables prior to running launch
5864WRKDIR=${SET_WRKDIR:- " $PWD " } # working directory for pipeline process
5965TOPDIR=${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"
6490METADIR=${SET_METADIR:- $DEFAULT_METADIR } # location of preset control files, META tables, ZBL flux estimates for netcal, etc
6591EHTIMPATH=${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"
79105
80106# Parse command-line arguments. overwrite any existing settings
81107OPTIND=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
111141if [ ! -d " $METADIR " ]; then
112142 echo " From $( basename " ${BASH_SOURCE[0]} " ) ERROR:: METADIR=$( METADIR) does not exist! Exiting..."
113- exit 1
143+ return 1
114144fi
115145if [ ! -d " $INPUTDIR " ]; then
116146 echo " From $( basename " ${BASH_SOURCE[0]} " ) ERROR:: INPUTDIR=$( INPUTDIR) does not exist! Exiting..."
117- exit 1
147+ return 1
118148fi
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 \
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: $@ "
171204fi
0 commit comments