SetGuiderFPS

Bases: KPFFunction

Set the guider FPS (frames per second) via the kpfguide.FPS keyword.

Parameters:
  • GuideFPS (float) –

    Number of frames per second.

KTL Keywords Used:

  • kpfguide.FPS
Source code in kpf/guider/SetGuiderFPS.py
 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
class SetGuiderFPS(KPFFunction):
    '''Set the guider FPS (frames per second) via the kpfguide.FPS
    keyword.

    Args:
        GuideFPS (float): Number of frames per second.

    KTL Keywords Used:

    - `kpfguide.FPS`
    '''
    @classmethod
    def pre_condition(cls, args):
        check_input(args, 'GuideFPS', value_min=0.0001, value_max=400)
        return True

    @classmethod
    def perform(cls, args):
        fpskw = ktl.cache('kpfguide', 'FPS')
        fps = args.get('GuideFPS')
        log.debug(f'Setting guider FPS to {fps}')
        fpskw.write(fps)

    @classmethod
    def post_condition(cls, args):
        fpstol = cfg.getfloat('tolerances', 'guider_fps_tolerance', fallback=0.01)
        fpskw = ktl.cache('kpfguide', 'FPS')
        fps = args.get('GuideFPS')
        expr = (f'($kpfguide.FPS >= {fps-fpstol}) and '\
                f'($kpfguide.FPS <= {fps+fpstol})')
        success = ktl.waitFor(expr, timeout=1)
        if not success:
            raise FailedToReachDestination(fpskw.read(), fps)

    @classmethod
    def add_cmdline_args(cls, parser):
        parser.add_argument('GuideFPS', type=float,
                            help='The frames per second (FPS)')
        return super().add_cmdline_args(parser)