Bases: KPFFunction
Continuously display latest guider images to ds9 using xpaset
.
KTL Keywords Used:
Source code in kpf/guider/DisplayGuiderContinuous.py
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 | class DisplayGuiderContinuous(KPFFunction):
'''Continuously display latest guider images to ds9 using `xpaset`.
KTL Keywords Used:
- `kpfguide.LASTFILE`
'''
@classmethod
def pre_condition(cls, args):
pass
@classmethod
def perform(cls, args):
display_name = cfg.get('display', 'guider_xpa_target', fallback='CRED2')
lastfile = ktl.cache('kpfguide', 'LASTFILE')
initial_lastfile = lastfile.read()
while True:
expr = f"($kpfguide.LASTFILE != '{initial_lastfile}')"
is_there_a_newfile = ktl.waitFor(expr, timeout=10)
if is_there_a_newfile is True:
initial_lastfile = lastfile.read()
print(f"Displaying {initial_lastfile}")
ds9cmd = ['xpaset', display_name, 'fits', f"{initial_lastfile}",
'<', f"{initial_lastfile}"]
# log.debug(f"Running: {' '.join(ds9cmd)}")
subprocess.call(' '.join(ds9cmd), shell=True)
regfile = Path(f'/home/kpfeng/fibers_on_cred2.reg')
if regfile.exists() is True:
overlaycmd = ['xpaset', '-p', display_name, 'regions', 'file',
f"{regfile}"]
# log.debug(f"Running: {' '.join(overlaycmd)}")
subprocess.call(' '.join(overlaycmd), shell=True)
time.sleep(0.5)
@classmethod
def post_condition(cls, args):
pass
|