-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetExposureInfoNFS.py
More file actions
58 lines (45 loc) · 1.6 KB
/
getExposureInfoNFS.py
File metadata and controls
58 lines (45 loc) · 1.6 KB
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
import os
import pandas
import psycopg2
import argparse
import subprocess
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--lastExp', metavar='e',type=int, nargs='+', help='Last exposure found.')
args = parser.parse_args()
lastExp=args.lastExp[0]
#SELECT id as EXPNUM
query = """SELECT id as ID,
TO_CHAR(date - '12 hours'::INTERVAL, 'YYYYMMDD') AS NITE,
EXTRACT(EPOCH FROM date - '1858-11-17T00:00:00Z')/(24*60*60) AS MJD_OBS,
ra AS RADEG,
declination AS DECDEG,
filter AS BAND,
exptime AS EXPTIME,
propid AS PROPID,
flavor AS OBSTYPE,
qc_teff as TEFF,
object as OBJECT
FROM exposure.exposure
WHERE flavor='object' and exptime>29.999 and RA is not NULL and id>"""+str(lastExp)+"""
ORDER BY id"""
#WHERE flavor='object' and exptime>29.999 and RA is not NULL and id>=182809 and expnum>"""+str(lastExp)
conn = psycopg2.connect(database='decam_prd',
user='decam_reader',
host='des61.fnal.gov',
port=5443)
some_exposures = pandas.read_sql(query, conn)
conn.close()
#print some_exposures.keys()
mystrings=''
mystrings=some_exposures.to_string(index_names=False,index=False,justify="left")
myout=open('newdbtest.dat','w')
myout.write(mystrings)
myout.write('\n')
myout.close()
os.system('mv newdbtest.dat exposures.list')
line = subprocess.check_output(['tail', '-1', 'exposures.list'])
lastExp=line.split(' ')[1]
g=open('lastExp.txt', 'w+')
g.write(lastExp)
g.close()