-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher_rho.py
63 lines (49 loc) · 2.31 KB
/
launcher_rho.py
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
import argparse
import errno
import sys
import os
import glob
def main(args):
submission_folder = 'launchers_rho'
try:
os.makedirs(submission_folder)
except:
pass
f = open(args.exposure_list)
exposure_filenames = f.readlines()
f.close()
N = len(exposure_filenames)
if not args.all_chips:
raise NotImplementedError
else:
for idx, exposure_filename in enumerate(exposure_filenames):
try:
try:
exposure_filename = exposure_filename.split('\n')[0]
except:
pass
try:
exp, ccd = exposure_filename.split('/')[-1].split('_')[1:]
except:
exp = '00' + exposure_filename.split('_')[-1]
print "Create submission script for exposure DECam_%s - %d/%d" % (exp, idx+1, N)
launch_template = open('job_specs.rho.submission').read()
flag = '--all_chips'
ccd = 'all'
launch_script = launch_template.format(exp=exp, ccd=ccd, psf=args.psf_model, flag=flag)
launch_output = '%s/DECam_%s.%s' % (submission_folder, exp, args.psf_model)
open(launch_output,'w').write(launch_script)
if args.submit:
os.system('wq %s' % launch_output)
except:
continue
if __name__=="__main__":
# Set up and parse the command line arguments using the nice Python argparse module
description = "Launch computation of rho statistics for PSF analysis on BNL"
parser = argparse.ArgumentParser(description=description, add_help=True)
parser.add_argument('exposure_list', type=str, help='list of exposure filenames that need to be processed')
parser.add_argument('psf_model', type=str, help='which psf model, psfex, psfex_im3shape or shapelet')
parser.add_argument('--submit', action='store_true', help='Whether to submit with wq')
parser.add_argument('--all_chips', action='store_true', help='Whether to process all 62 chips in one go. In this case the input is only a exposure ID without ccd id. In this case exposure_list is interpreted as folder names containing single exposures.')
args = parser.parse_args()
main(args)