GuiderLastfile

Bases: KPFFunction

Print the value of the kpfguide.LASTFILE keyword to STDOUT

Parameters:
  • wait (bool) –

    Return only after lastfile is updated? (default = False)

KTL Keywords Used:

  • kpfguide.LASTFILE
Source code in kpf/guider/GuiderLastfile.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
class GuiderLastfile(KPFFunction):
    '''Print the value of the kpfguide.LASTFILE keyword to STDOUT

    Args:
        wait (bool): Return only after lastfile is updated? (default = False)

    KTL Keywords Used:

    - `kpfguide.LASTFILE`
    '''
    @classmethod
    def pre_condition(cls, args):
        pass

    @classmethod
    def perform(cls, args):
        kpfguide = ktl.cache('kpfguide')
        if args.get('wait', True) is True:
            exptime = kpfguide['EXPTIME'].read(binary=True)
            initial_lastfile = kpfguide['LASTFILE'].read()
            timeout = cfg.getfloat('times', 'kpfguide_shim_time', fallback=0.01)
            expr = f"($kpfguide.LASTFILE != '{initial_lastfile}')"
            ktl.waitFor(expr, timeout=exptime+timeout)
        lastfile = kpfguide['LASTFILE'].read()
        print(lastfile)
        return lastfile

    @classmethod
    def post_condition(cls, args):
        pass

    @classmethod
    def add_cmdline_args(cls, parser):
        parser.add_argument("--nowait", dest="wait",
                            default=True, action="store_false",
                            help="Send exposure command and return immediately?")
        return super().add_cmdline_args(parser)