-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_standard_overview_table.py
126 lines (108 loc) · 4.77 KB
/
query_standard_overview_table.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import sys
import warnings
from datetime import datetime, timedelta
from calendar import isleap
from tqdm import tqdm
from astropy.config import set_temp_cache
from astropy.table import Table
from astroquery.eso import Eso
from astroquery.exceptions import NoResultsWarning
warnings.filterwarnings("ignore", category=NoResultsWarning)
'''
Query ESO Archive for standard star exposures of a defined standard.
Check whether at a given night where the standard was observed also a
science exposure was taken with the given setting. Only for those
cases a simple archive query can deliver the standard star observation
and the associated calibration data.
'''
eso_username = 'echerenzops'
year = sys.argv[1] # e.g. 2019
star = 'LTT 3218'
eso = Eso()
num_days = 366 if isleap(int(year)) else 365
date_list = [(datetime.strptime(year, '%Y') + \
timedelta(days=i)).strftime('%Y-%m-%d')
for i in range(num_days)] #
wfm_noao_n = []
wfm_noao_e = []
wfm_ao_n = []
wfm_ao_e = []
date_out_list = []
for date in tqdm(date_list):
std_table_noao_n = eso.query_instrument('muse',
column_filters={'target': star,
'ins_mode': 'WFM-NOAO-N',
'night': date,
'dp_type': 'STD'})
std_table_noao_e = eso.query_instrument('muse',
column_filters={'target': star,
'ins_mode': 'WFM-NOAO-E',
'night': date,
'dp_type': 'STD'})
std_table_ao_n = eso.query_instrument('muse',
column_filters={'target': star,
'ins_mode': 'WFM-AO-N',
'night': date,
'dp_type': 'STD'})
std_table_ao_e = eso.query_instrument('muse',
column_filters={'target': star,
'ins_mode': 'WFM-AO-E',
'night': date,
'dp_type': 'STD'})
if type(std_table_noao_n) != type(None):
obj_table = eso.query_instrument('muse',
column_filters={'ins_mode': 'WFM-NOAO-N',
'night': date,
'dp_type': 'OBJECT'})
if type(obj_table) == type(None):
wfm_noao_n.append('NOSCI')
else:
wfm_noao_n.append('SCI')
else:
wfm_noao_n.append('')
if type(std_table_noao_e) != type(None):
obj_table = eso.query_instrument('muse',
column_filters={'ins_mode': 'WFM-NOAO-E',
'night': date,
'dp_type': 'OBJECT'})
if type(obj_table) == type(None):
wfm_noao_e.append('NOSCI')
else:
wfm_noao_e.append('SCI')
else:
wfm_noao_e.append('')
if type(std_table_ao_n) != type(None):
obj_table = eso.query_instrument('muse',
column_filters={'ins_mode': 'WFM-AO-N',
'night': date,
'dp_type': 'OBJECT'})
if type(obj_table) == type(None):
wfm_ao_n.append('NOSCI')
else:
wfm_ao_n.append('SCI')
else:
wfm_ao_n.append('')
if type(std_table_ao_e) != type(None):
obj_table = eso.query_instrument('muse',
column_filters={'ins_mode': 'WFM-AO-E',
'night': date,
'dp_type': 'OBJECT'})
if type(obj_table) == type(None):
wfm_ao_e.append('NOSCI')
else:
wfm_ao_e.append('SCI')
else:
wfm_ao_e.append('')
if wfm_noao_n[-1] == wfm_noao_e[-1] == wfm_ao_n[-1] == wfm_ao_e[-1] == '':
del wfm_noao_n[-1]
del wfm_noao_e[-1]
del wfm_ao_n[-1]
del wfm_ao_e[-1]
else:
date_out_list.append(date)
out_table = Table([date_out_list,
wfm_noao_n, wfm_noao_e, wfm_ao_n, wfm_ao_e],
names=['DATE',
'WFM_NOAO_N', 'WFM_NOAO_E', 'WFM_AO_N', 'WFM_AO_E'])
out_table.write('standard_overview_table_' + str(year) + '.ascii',
format='ascii.fixed_width')