Bases: KPFFunction
Check whether the tip tilt system's target pixel (kpffiu.CURRENT_BASE)
is consistent with the selected pointing origin (dcs.PONAME)
KTL Keywords Used:
dcs1.PONAME
kpfguide.CURRENT_BASE
kpfguide.SCIENCE_BASE
kpfguide.SKY_BASE
Source code in kpf/fiu/VerifyCurrentBase.py
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 | class VerifyCurrentBase(KPFFunction):
'''Check whether the tip tilt system's target pixel (kpffiu.CURRENT_BASE)
is consistent with the selected pointing origin (dcs.PONAME)
KTL Keywords Used:
- `dcs1.PONAME`
- `kpfguide.CURRENT_BASE`
- `kpfguide.SCIENCE_BASE`
- `kpfguide.SKY_BASE`
'''
@classmethod
def pre_condition(cls, args):
pass
@classmethod
def perform(cls, args):
ponamekw = ktl.cache('dcs1', 'PONAME')
poname = ponamekw.read().upper()
kpfguide = ktl.cache('kpfguide')
current_base = kpfguide['CURRENT_BASE'].read(binary=True)
science_base = kpfguide['SCIENCE_BASE'].read(binary=True)
sky_base = kpfguide['SKY_BASE'].read(binary=True)
science_match = np.all(np.isclose(current_base, science_base, atol=0.01))
sky_match = np.all(np.isclose(current_base, sky_base, atol=0.01))
msg = f"CURRENT_BASE="
if science_match:
log.debug(f"CURRENT_BASE is science fiber, PO = {poname}")
msg += 'SCIENCE_BASE'
elif sky_match:
log.debug(f"CURRENT_BASE is sky fiber, PO = {poname}")
msg += 'SKY_BASE'
else:
log.debug(f"CURRENT_BASE is {current_base}, PO = {poname}")
msg += 'custom'
poname_match = (science_match and poname == 'KPF')\
or (sky_match and poname == 'SKY')
if poname_match:
msg += f" which is consistent with PONAME={poname}"
log.debug(msg)
else:
msg += f" which is NOT consistent with PONAME={poname}"
log.error(msg)
print(msg)
if args.get('query_user', False) == True and poname_match == False:
# Check with user
log.debug('Asking for user input')
print()
print("#####################################################")
print("The dcs.PONAME value is incosistent with CURRENT_BASE")
print("Please double check that the target object is where you")
print("want it to be before proceeding.")
print()
print("Do you wish to continue executing this OB?")
print("(y/n) [y]:")
print("#####################################################")
print()
user_input = input()
log.debug(f'response: "{user_input}"')
if user_input.lower().strip() in ['n', 'no', 'a', 'abort', 'q', 'quit']:
raise KPFException("User chose to halt execution")
return poname_match
@classmethod
def post_condition(cls, args):
pass
|