-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_desdm.py
59 lines (43 loc) · 1.81 KB
/
get_desdm.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
#!/usr/bin/env python
import os,argparse
import cx_Oracle
parser = argparse.ArgumentParser(description='Run single file')
parser.add_argument('--exposure',type=int,help='exposure number',default=-1)
parser.add_argument('--file',help='exposures from a file',
default="")
parser.add_argument('--start',type=int,default=-1,
help='starting exposure number')
parser.add_argument('--end',type=int,help='end exposure number')
parser.add_argument('--run',default='',help='run')
parser.add_argument('--outdir',default='',help='run')
args = parser.parse_args()
exp_list=[]
if args.exposure>0:
exp_list.append(args.exposure)
elif args.file!="":
file=open(args.file)
for line in file:
exp=int(line)
exp_list.append(exp)
else:
exp_list=range(args.start,args.end+1)
for exp in exp_list:
print "Downloading exposure %d"%exp
connection = cx_Oracle.connect('[user]/[password]@leovip148.ncsa.uiuc.edu/desoper')
cursor = connection.cursor()
run=args.run
if run=="":
query="select distinct(run) from exposure,image where image.imagetype='red' and image.exposureid=exposure.id and expnum=%d order by run desc" % exp
cursor.execute(query)
results=cursor.fetchall();
if len(results)==0:
print 'Could not find exposure %d'%exp
continue
if len(results)>1:
print 'Found multitple runs using latest'
run=results[0][0]
outdir='%s/DECam_%d' % (args.outdir,exp)
loc=('ftp://desar.cosmology.illinois.edu/DESFiles/desardata/OPS/red/%s/red/DECam_%08d/*' % (run,exp))
print loc
if not os.path.exists(outdir): os.makedirs (outdir)
os.system('wget -q -P %s %s ' % (outdir,loc))