Returns list of dicts with the classical and cadence program info.
If no args, returns everything remaining on this semester's schedule.
If args contains a value for "semester" then that is either interpreted
as the semester string (e.g. "2025A") or it can be "current" which
instructs the code to use the current semester.
Source code in kpf/observatoryAPIs/GetScheduledPrograms.py
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 | @classmethod
def perform(cls, args):
'''Returns list of dicts with the classical and cadence program info.
If no args, returns everything remaining on this semester's schedule.
If args contains a value for "semester" then that is either interpreted
as the semester string (e.g. "2025A") or it can be "current" which
instructs the code to use the current semester.
'''
utnow = datetime.datetime.utcnow()
semester, semester_start, semester_end = get_semester_dates(utnow)
if args.get('semester', None) == 'current':
start = semester_start
numdays = (semester_end-start).days + 2
elif str(args.get('semester', None)) in ['today', 'tonight']:
start = datetime.datetime.utcnow() - datetime.timedelta(days=1)
numdays = 1
elif str(args.get('semester', None))[0] == '2':
semester, semester_start, semester_end = get_semester_dates(args.get('semester'))
start = semester_start
numdays = (semester_end-start).days + 2
else:
# Pull programs from the rest of the semester
start = utnow
numdays = (semester_end-start).days + 2
date_str = (start-datetime.timedelta(days=1)).strftime('%Y-%m-%d')
query = 'getSchedule'
params = {'date': date_str,
'numdays': numdays,
'telnr': args.get('telnr', 1),
'instrument': 'KPF'}
all_programs = query_observatoryAPI('schedule', query, params)
classical_programs = [p for p in all_programs if p['Instrument'] == 'KPF' and p['Semester'] == semester]
cadence_programs = [p for p in all_programs if p['Instrument'] == 'KPF-CC' and p['Semester'] == semester]
return classical_programs, cadence_programs
|