SetGuiderGain

Bases: KPFFunction

Set the guider gain via the kpfguide.GAIN keyword.

Parameters:
  • GuideCamGain (str) –

    The desired gain. Allowed values: high, medium, or low.

KTL Keywords Used:

  • kpfguide.GAIN
Source code in kpf/guider/SetGuiderGain.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
class SetGuiderGain(KPFFunction):
    '''Set the guider gain via the kpfguide.GAIN keyword.

    Args:
        GuideCamGain (str): The desired gain. Allowed values: high, medium, or
            low.

    KTL Keywords Used:

    - `kpfguide.GAIN`
    '''
    @classmethod
    def pre_condition(cls, args):
        check_input(args, 'GuideCamGain', allowed_values=['high', 'medium', 'low'])

    @classmethod
    def perform(cls, args):
        gainkw = ktl.cache('kpfguide', 'GAIN')
        gain = args.get('GuideCamGain')
        log.debug(f'Setting guider gain to {gain}')
        gainkw.write(gain)

    @classmethod
    def post_condition(cls, args):
        gainkw = ktl.cache('kpfguide', 'GAIN')
        gain = args.get('GuideCamGain')
        expr = (f"($kpfguide.GAIN == '{gain}')")
        success = ktl.waitFor(expr, timeout=1)
        if not success:
            raise FailedToReachDestination(gainkw.read(), gain)

    @classmethod
    def add_cmdline_args(cls, parser):
        parser.add_argument('GuideCamGain', type=str,
                            choices=['high', 'medium', 'low'],
                            help='The gain')
        return super().add_cmdline_args(parser)