SetFlatFieldFiberPos

Bases: KPFFunction

Description

Set the flat field fiber aperture via the kpfcal.FF_FIBERPOS keyword.

Parameters:
  • FF_FiberPos (str) –

    The name of the flat field fiber position desired. Allowed Values: "Blank", "6 mm f/5", "7.5 mm f/4", "10 mm f/3", "13.2 mm f/2.3", "Open".

  • wait (bool) –

    Wait for move to complete before returning? default: True

KTL Keywords Used

  • kpfcal.FF_FIBERPOS
Source code in kpf/calbench/SetFlatFieldFiberPos.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
47
48
49
50
51
52
53
54
class SetFlatFieldFiberPos(KPFFunction):
    '''# Description
    Set the flat field fiber aperture via the `kpfcal.FF_FIBERPOS` keyword.

    Args:
        FF_FiberPos (str): The name of the flat field fiber position desired.
            Allowed Values: "Blank", "6 mm f/5", "7.5 mm f/4", "10 mm f/3",
            "13.2 mm f/2.3", "Open".
        wait (bool): Wait for move to complete before returning? default: True

    ## KTL Keywords Used

    - `kpfcal.FF_FIBERPOS`
    '''
    @classmethod
    def pre_condition(cls, args):
        FF_FIBERPOS = ktl.cache('kpfcal', 'FF_FIBERPOS')
        allowed_values = list(FF_FIBERPOS._getEnumerators())
        if 'Unknown' in allowed_values:
            allowed_values.pop(allowed_values.index('Unknown'))
        check_input(args, 'FF_FiberPos', allowed_values=allowed_values)

    @classmethod
    def perform(cls, args):
        target = args.get('FF_FiberPos')
        log.debug(f"Setting FF_FiberPos to {target}")
        FF_FIBERPOS = ktl.cache('kpfcal', 'FF_FIBERPOS')
        FF_FIBERPOS.write(target, wait=args.get('wait', True))

    @classmethod
    def post_condition(cls, args):
        target = args.get('FF_FiberPos')
        timeout = cfg.getfloat('times', 'nd_move_time', fallback=20)
        FF_FIBERPOS = ktl.cache('kpfcal', 'FF_FIBERPOS')
        if FF_FIBERPOS.waitFor(f"== '{target}'", timeout=timeout) is not True:
            raise FailedToReachDestination(FF_FIBERPOS.read(), target)

    @classmethod
    def add_cmdline_args(cls, parser):
        parser.add_argument('FF_FiberPos', type=str,
                            choices=["Blank", "6 mm f/5", "7.5 mm f/4",
                                     "10 mm f/3", "13.2 mm f/2.3", "Open"],
                            help='Wide flat aperture to use.')
        parser.add_argument("--nowait", dest="wait",
                            default=True, action="store_false",
                            help="Send move and return immediately?")
        return super().add_cmdline_args(parser)