-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetExposureInfo.py
More file actions
executable file
·59 lines (45 loc) · 1.75 KB
/
getExposureInfo.py
File metadata and controls
executable file
·59 lines (45 loc) · 1.75 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
59
import os
import subprocess
import pandas
import psycopg2
#connection = ea.connect('desoper')
#
#q = "select expnum,nite,mjd_obs,radeg,decdeg,band,exptime,propid,obstype,object from prod.exposure where obstype='object' order by expnum"
#os.system('rm -f exposures.tab')
#connection.query_and_save(q,'exposures.tab')
###query = "SELECT expnum,date,ra,declination,band,exptime,propid,obstype,object FROM exposure.exposure where obstype='object' order by expnum LIMIT 100"
### we do not consider exposures before 182809, which was the first exposure taken on MJD 56352, which is 2013-03-01
query = """SELECT id as EXPNUM,
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>=182809
ORDER BY id"""
conn = psycopg2.connect(database='decam_prd',
user='decam_reader',
host='des61.fnal.gov',
# password='THEPASSWORD',
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()