forked from gnarayan/decat_pointings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_json.py
More file actions
33 lines (30 loc) · 1.48 KB
/
make_json.py
File metadata and controls
33 lines (30 loc) · 1.48 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
import numpy as np
def individual(json_outpath,json_prefixs,pointRAs,pointDECs,obss,propids,objects,exptypes,programs):
for json_prefix,pointRA,pointDEC,obs,propid,tobject,exptype,program in zip(json_prefixs,pointRAs,pointDECs,obss,propids,objects,exptypes,programs):
json_out = []
json_out.append('[')
cntr = 0
lenobs = len(obs.split(','))
for ob in obs.split(','):
cntr += 1
filt = ob[0]
exptime = ob[1:]
json_out.append('\t{')
json_out.append('\t\t"count": 1,')
json_out.append('\t\t"filter": "%s",'%filt)
json_out.append('\t\t"exptime": %.1f,'%float(exptime.strip()))
json_out.append('\t\t"RA": %f,' % round(float(pointRA), 5))
json_out.append('\t\t"dec": %f,' % round(float(pointDEC), 5))
json_out.append('\t\t"object": "%s",'%tobject)
json_out.append('\t\t"program": "%s",'%program)
json_out.append('\t\t"expType": "%s",'%exptype)
json_out.append('\t\t"note": "None",')
json_out.append('\t\t"comment": "%s",'%json_prefix)
json_out.append('\t\t"wait": "False",')
json_out.append('\t\t"propid": "%s"'%propid)
if cntr == lenobs:
json_out.append('\t}')
else:
json_out.append('\t},')
json_out.append(']')
np.savetxt(json_outpath+'/'+json_prefix+'.json', json_out, fmt='%s')