SetGuiderExpTime

Bases: KPFTranslatorFunction

Set the guider exposure time (in seconds) via the kpfguide.EXPTIME keyword.

The guider exposure time is governed by several factors. The exposure time controlled here is generated by stacking (averaging) multiple frames as needed to obtain the specified exposure time. Those individual frames are controlled by the FPS, AVERAGE, STACK, and EXPTIME keywords.

From Kyle:

If you want to tweak an exposure setting, I recommend MAGIQ use the EXPTIME keyword as its preferred knob. This will translate to changing the number of frames averaged together. You can also choose to stack frames, but I doubt that will be necessary.

Notice how EXPTIME remains unchanged when I change the STACK keyword:

[klanclos@kpffiuserver ~]$ gshow -s kpfguide fps average stack exptime FPS = 100.0000 frames/second AVERAGE = 100 frames STACK = 1 averaged frames EXPTIME = 1.000000 seconds

[klanclos@kpffiuserver ~]$ modify -s kpfguide stack=2 setting stack = 2 (wait) [klanclos@kpffiuserver ~]$ gshow -s kpfguide fps average stack exptime FPS = 100.0000 frames/second AVERAGE = 50 frames STACK = 2 averaged frames EXPTIME = 1.000000 seconds

...but if I change AVERAGE, EXPTIME reflects the change:

[klanclos@kpffiuserver ~]$ modify -s kpfguide average=20 setting average = 20 (wait) [klanclos@kpffiuserver ~]$ gshow -s kpfguide fps average stack exptime FPS = 100.0000 frames/second AVERAGE = 20 frames STACK = 1 averaged frames EXPTIME = 0.200000 seconds

Stick to changing EXPTIME and you won't have to worry about it. Changing the frames per second is not recommended, because the tip/tilt system will be consuming this image stream, and it needs to retain full control of what an individual frame looks like.

Parameters:
  • exptime (float) –

    The exposure time in seconds.

KTL Keywords Used:

  • kpfguide.EXPTIME
Source code in kpf/guider/SetGuiderExpTime.py
 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class SetGuiderExpTime(KPFTranslatorFunction):
    '''Set the guider exposure time (in seconds) via the kpfguide.EXPTIME
    keyword.

    The guider exposure time is governed by several factors.  The exposure time
    controlled here is generated by stacking (averaging) multiple frames as
    needed to obtain the specified exposure time.  Those individual frames are
    controlled by the FPS, AVERAGE, STACK, and EXPTIME keywords.

    From Kyle:

    If you want to tweak an exposure setting, I recommend MAGIQ use the
    EXPTIME keyword as its preferred knob. This will translate to changing
    the number of frames averaged together. You can also choose to stack
    frames, but I doubt that will be necessary.

    Notice how EXPTIME remains unchanged when I change the STACK keyword:

    [klanclos@kpffiuserver ~]$ gshow -s kpfguide fps average stack exptime
             FPS =  100.0000 frames/second
         AVERAGE =  100 frames
           STACK =  1 averaged frames
         EXPTIME =  1.000000 seconds

    [klanclos@kpffiuserver ~]$ modify -s kpfguide stack=2
    setting stack = 2 (wait)
    [klanclos@kpffiuserver ~]$ gshow -s kpfguide fps average stack exptime
             FPS =  100.0000 frames/second
         AVERAGE =  50 frames
           STACK =  2 averaged frames
         EXPTIME =  1.000000 seconds

    ...but if I change AVERAGE, EXPTIME reflects the change:

    [klanclos@kpffiuserver ~]$ modify -s kpfguide average=20
    setting average = 20 (wait)
    [klanclos@kpffiuserver ~]$ gshow -s kpfguide fps average stack exptime
             FPS =  100.0000 frames/second
         AVERAGE =  20 frames
           STACK =  1 averaged frames
         EXPTIME =  0.200000 seconds

    Stick to changing EXPTIME and you won't have to worry about it.
    Changing the frames per second is not recommended, because the tip/tilt
    system will be consuming this image stream, and it needs to retain full
    control of what an individual frame looks like.

    Args:
        exptime (float): The exposure time in seconds.

    KTL Keywords Used:

    - `kpfguide.EXPTIME`
    '''
    @classmethod
    def pre_condition(cls, args, logger, cfg):
        check_input(args, 'exptime', value_min=0)

    @classmethod
    def perform(cls, args, logger, cfg):
        exptimekw = ktl.cache('kpfguide', 'EXPTIME')
        exptime = args.get('exptime')
        exptimekw.write(exptime)

    @classmethod
    def post_condition(cls, args, logger, cfg):
        exptol = cfg.getfloat('tolerances', 'guider_exptime_tolerance', fallback=0.01)

        exptimekw = ktl.cache('kpfguide', 'EXPTIME')
        exptimeread = exptimekw.read(binary=True)
        exptime = args.get('exptime')

        expr = (f'($kpfguide.EXPTIME >= {exptime-exptol}) and '\
                f'($kpfguide.EXPTIME <= {exptime+exptol})')
        success = ktl.waitFor(expr, timeout=exptimeread+1)
        if not success:
            raise FailedToReachDestination(exptimekw.read(), exptime)

    @classmethod
    def add_cmdline_args(cls, parser, cfg=None):
        parser.add_argument('exptime', type=float,
                            help='The exposure time in seconds')
        return super().add_cmdline_args(parser, cfg)