CleanupAfterScience

Bases: KPFTranslatorFunction

Script which cleans up at the end of Science OBs.

Can be called by ddoi_script_functions.post_observation_cleanup.

ARGS:

:OB: dict A fully specified science observing block (OB).

Source code in kpf/scripts/CleanupAfterScience.py
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
class CleanupAfterScience(KPFTranslatorFunction):
    '''Script which cleans up at the end of Science OBs.

    Can be called by `ddoi_script_functions.post_observation_cleanup`.

    ARGS:
    =====
    :OB: `dict` A fully specified science observing block (OB).
    '''
    @classmethod
    def pre_condition(cls, OB, logger, cfg):
        pass

    @classmethod
    def perform(cls, OB, logger, cfg):
        log.info('-------------------------')
        log.info(f"Running {cls.__name__}")
        log.info('-------------------------')

        StopTipTilt.execute({})

        kpfconfig = ktl.cache('kpfconfig')
        kpfconfig['SCRIPTMSG'].write('')
        runagitator = kpfconfig['USEAGITATOR'].read(binary=True)
        if runagitator is True:
            StopAgitator.execute({})

        # Clear target info
        log.debug('Clearing target info')
        SetTargetInfo.execute({})
        # Turn off exposure meter controlled exposure
        log.debug('Clearing kpf_expmeter.USETHRESHOLD')
        kpf_expmeter = ktl.cache('kpf_expmeter')
        kpf_expmeter['USETHRESHOLD'].write('No')
        # Set SKY_OFFSET back to 0 0
        log.debug('Clearing kpfguide.SKY_OFFSET')
        sky_offset = ktl.cache('kpfguide', 'SKY_OFFSET')
        sky_offset.write('0 0')

        clear_script_keywords()

    @classmethod
    def post_condition(cls, OB, logger, cfg):
        pass